/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1520;
  --bg2: #111c2b;
  --card: #162030;
  --border: #1e2d3d;
  --primary: #00838F;
  --primary-light: #00BCD4;
  --accent: #E65100;
  --text: #d0dce8;
  --text-muted: #607080;
  --text-dim: #8a9bb0;
  --success: #4CAF50;
  --danger: #EF5350;
  --warning: #E65100;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; font-size: 14px; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== Pages — 统一用 display:none / display:flex|block 控制，避免特异度冲突 ===== */
#page-login {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #0d2535 0%, #0d1520 70%);
}
#page-login.active { display: flex; }

#page-app {
  display: none;
  flex-direction: row;
  min-height: 100vh;
}
#page-app.active { display: flex; }

/* ===== Login ===== */
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.brand-icon { font-size: 36px; }
.brand h1 { font-size: 20px; font-weight: 700; color: var(--primary-light); }
.brand-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-light);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  transition: background .15s, color .15s;
  position: relative;
  cursor: pointer;
}
.nav-item:hover { background: rgba(0,188,212,.08); color: var(--text); }
.nav-item.active { background: rgba(0,188,212,.12); color: var(--primary-light); font-weight: 600; }
.nav-icon { font-size: 16px; }

.badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.badge.hidden { display: none !important; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  word-break: break-all;
}
.btn-logout {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(239,83,80,.1);
  color: var(--danger);
  font-size: 13px;
  border: 1px solid rgba(239,83,80,.3);
  transition: background .15s;
}
.btn-logout:hover { background: rgba(239,83,80,.2); }

.btn-setting {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(0,188,212,.08);
  color: var(--primary-light);
  font-size: 13px;
  border: 1px solid rgba(0,188,212,.25);
  transition: background .15s;
  margin-bottom: 8px;
}
.btn-setting:hover { background: rgba(0,188,212,.16); }

/* ===== 密码输入框（带显示/隐藏按钮）===== */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-input-wrap input {
  flex: 1;
  padding-right: 40px;
}
.toggle-pwd {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
  transition: color .15s;
}
.toggle-pwd:hover { color: var(--primary-light); }

/* ===== 修改密码 Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none !important; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 48px rgba(0,0,0,.5);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,.06); }
.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-footer .btn-secondary { flex: 0 0 auto; }
.modal-footer .btn-primary   { flex: 1; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
  overflow-y: auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card.no-padding { padding: 0; }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--primary-light); }
.form-group select option { background: var(--bg2); }

/* ===== Buttons ===== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  transition: background .15s, opacity .15s;
  width: 100%;
  margin-top: 8px;
  border: none;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color .15s, color .15s;
}
.btn-secondary:hover { border-color: var(--primary-light); color: var(--primary-light); }
.btn-sm {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  background: rgba(239,83,80,.12);
  border: 1px solid rgba(239,83,80,.3);
  color: var(--danger);
  cursor: pointer;
}
.btn-sm:hover { background: rgba(239,83,80,.22); }

/* ===== Messages ===== */
.error-msg {
  background: rgba(239,83,80,.1);
  border: 1px solid rgba(239,83,80,.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}
.success-msg {
  background: rgba(76,175,80,.1);
  border: 1px solid rgba(76,175,80,.3);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}
.hidden { display: none !important; }

/* ===== Printer Grid (Dashboard) ===== */
.printer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.printer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.printer-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.printer-name { font-weight: 700; font-size: 15px; }
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
}
.status-badge.online  { background: rgba(76,175,80,.15);  color: var(--success); }
.status-badge.offline { background: rgba(96,112,128,.15); color: var(--text-muted); }

.level-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.level-label { width: 48px; flex-shrink: 0; }
.level-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.level-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}
.level-bar.ink   { background: var(--primary-light); }
.level-bar.paper { background: #90A4AE; }
.level-value { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.printer-card-footer {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.printer-action-btn {
  flex: 1;
  padding: 7px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: all .15s;
  cursor: pointer;
}
.printer-action-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.printer-action-btn.primary { background: rgba(0,131,143,.12); border-color: var(--primary); color: var(--primary-light); }

.printer-meta { font-size: 11px; color: var(--text-dim); margin-top: 6px; }

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary-light);
  background: rgba(0,188,212,.04);
}
.drop-icon { font-size: 36px; margin-bottom: 8px; }
.drop-zone p { color: var(--text-muted); font-size: 13px; }
.drop-zone .hint { font-size: 11px; margin-top: 4px; }

.file-selected {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,188,212,.08);
  border: 1px solid rgba(0,188,212,.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--primary-light);
}

/* ===== Params Grid ===== */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 16px;
}

/* ===== Mode Toggle ===== */
.mode-toggle { display: flex; gap: 10px; }
.mode-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
}
.mode-btn.active {
  border-color: var(--primary);
  background: rgba(0,131,143,.12);
  color: var(--primary-light);
}

/* ===== USB Notice ===== */
.usb-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,188,212,.06);
  border: 1px solid rgba(0,188,212,.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--primary-light);
  margin-bottom: 16px;
}

/* ===== Scan Status ===== */
.scan-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,188,212,.06);
  border: 1px solid rgba(0,188,212,.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--primary-light);
  margin-bottom: 12px;
}

/* ===== Data Table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.02);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.empty-cell { text-align: center; color: var(--text-muted); padding: 32px !important; }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.sp-completed { background: rgba(76,175,80,.15);  color: var(--success); }
.sp-pending   { background: rgba(96,112,128,.15); color: var(--text-muted); }
.sp-printing  { background: rgba(0,188,212,.15);  color: var(--primary-light); }
.sp-scanning  { background: rgba(0,188,212,.15);  color: var(--primary-light); }
.sp-failed    { background: rgba(239,83,80,.15);  color: var(--danger); }
.sp-cancelled { background: rgba(96,112,128,.15); color: var(--text-muted); }
.sp-scheduled { background: rgba(230,81,0,.15);   color: var(--accent); }

/* ===== Notifications ===== */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(255,255,255,.02); }
.notif-item.unread { background: rgba(0,188,212,.03); }

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.notif-body { flex: 1; min-width: 0; }
.notif-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.notif-item.read .notif-title { color: var(--text-muted); font-weight: 400; }
.notif-msg { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: 11px; color: var(--text-dim); flex-shrink: 0; margin-left: 8px; padding-top: 2px; }
.unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0; margin-top: 6px;
}

/* ===== Install Guide ===== */
.install-guide { margin-bottom: 0; }
.install-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.install-guide-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 14px;
}
.install-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(0,188,212,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.install-guide-body { margin-top: 16px; }
.install-intro { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.install-steps { display: flex; flex-direction: column; }
.install-step {
  display: flex;
  gap: 14px;
  padding-bottom: 16px;
  position: relative;
}
.install-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px; top: 36px;
  width: 1px; bottom: 0;
  background: var(--border);
}
.step-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  z-index: 1;
}
.step-content strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 4px; }
.step-content p { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.install-warning {
  background: rgba(230,81,0,.08);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
}

/* ===== Loading placeholder ===== */
.loading-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 56px; }
  .sidebar-brand span:last-child,
  .nav-item > span:not(.nav-icon),
  .sidebar-footer .user-info,
  .btn-setting,
  .btn-logout { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .main-content { padding: 16px; }
  .params-grid { grid-template-columns: 1fr 1fr; }
  .printer-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }
}
