:root{
  color-scheme: dark;
  --bg: #23262B;
  --surface: #2A2E34;
  --surface-2: #32373D;
  --border: #454B52;
  --border-strong: #5A6169;
  --text: #EDEFF2;
  --text-soft: #ABB1B8;
  --text-faint: #767D85;
  --accent: #4FD9B0;
  --accent-ink: #0E1512;
  --accent-soft: rgba(79,217,176,0.14);
  --accent-soft-strong: rgba(79,217,176,0.25);
  --danger: #D97570;
  --warn: #D9A05F;
  --shadow-sm: 0 1px 3px rgba(20,24,28,0.10);
  --shadow-md: 0 8px 24px rgba(20,24,28,0.16), 0 1px 3px rgba(20,24,28,0.10);
  --radius: 12px;
  --radius-sm: 8px;
}
*{ box-sizing: border-box; scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar{ width: 10px; height: 10px; }
*::-webkit-scrollbar-track{ background: transparent; }
*::-webkit-scrollbar-thumb{ background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
[hidden]{ display: none !important; }
html,body{ height: 100%; margin: 0; }
body{
  background:
    radial-gradient(1100px 750px at 12% -8%, rgba(111,161,220,0.14), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(217,160,95,0.10), transparent 60%),
    linear-gradient(150deg, #284A70 0%, #2B3038 50%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}
button{ font: inherit; cursor: pointer; }
input, textarea, select{ font: inherit; color: inherit; }
:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Sidebar ---------- */
.sidebar{
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
}
.sidebar-head{ padding: 20px 18px 14px; display: flex; align-items: center; gap: 10px; }
.sidebar-head img{ width: 30px; height: 30px; border-radius: 8px; }
.brand{ font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.nav-list{ list-style: none; margin: 0; padding: 4px 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);
  cursor: pointer; color: var(--text-soft); font-size: 13.8px; font-weight: 600; border: 1px solid transparent;
}
.nav-item:hover{ background: var(--surface-2); color: var(--text); }
.nav-item.active{ background: var(--accent-soft); border-color: var(--accent-soft-strong); color: var(--accent); }
.nav-item .icon{ font-size: 15px; }
.sidebar-footer{ margin-top: auto; padding: 12px 18px; font-size: 11.5px; color: var(--text-faint); }
.logoutBtn{
  border: 1px solid var(--border); background: transparent; color: var(--text-soft);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12.5px; width: 100%;
}
.logoutBtn:hover{ border-color: var(--danger); color: var(--danger); }

/* ---------- Main ---------- */
.main{ min-height: 100vh; overflow-y: auto; }
.dashboard{ padding: 30px 32px 90px; max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
h1{ margin: 0 0 2px; font-size: 22px; }
.sub{ color: var(--text-soft); margin: 0 0 6px; font-size: 13.5px; }

.card{
  background: color-mix(in srgb, var(--surface) 66%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid color-mix(in srgb, var(--border-strong) 55%, transparent);
  border-top: 3px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.card h2{ margin: 0 0 12px; font-size: 15.5px; }

table{ width: 100%; border-collapse: collapse; margin-bottom: 10px; }
th, td{ text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 13.5px; }

input[type="text"], input[type="number"], input[type="password"], select{
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 13.5px; width: 100%;
  background: var(--surface-2); color: var(--text);
}
input:focus, select:focus{ outline: none; border-color: var(--accent); }

.project-picker{ display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.project-picker select{ width: auto; flex: 1; }
.project-picker button{ flex-shrink: 0; }
.upload-fallback{ margin-bottom: 4px; }
.upload-fallback summary{ cursor: pointer; font-size: 12.5px; color: var(--text-soft); }
.upload-fallback input[type="file"]{ margin-top: 8px; }
label{ display: block; margin-bottom: 10px; font-size: 13.5px; }
label input[type="checkbox"]{ width: auto; margin-right: 6px; }

button{
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 6px; padding: 6px 12px; font-size: 13.5px;
}
button:hover{ border-color: var(--border-strong); }
button.primary{
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; font-size: 15px;
  padding: 10px 20px; width: 100%; margin-bottom: 4px;
}
button.primary:hover{ filter: brightness(1.05); }
.removeFormatBtn{ color: var(--danger); border: none; background: none; font-size: 16px; }
.duplicateFormatRowBtn{ color: var(--text-soft); border: none; background: none; font-size: 15px; }
.duplicateFormatRowBtn:hover{ color: var(--accent); }
.status{ margin-top: 8px; font-size: 13px; color: var(--text-soft); }
.hint{ font-size: 12.5px; color: var(--text-soft); margin: -6px 0 8px; }
.error{ color: var(--danger); }

.material-group{ border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.material-group h3{ margin: 0 0 8px; font-size: 14px; }
.material-group .addFormatRowBtn{ font-size: 12.5px; }

.plate-summary{ font-size: 16px; background: var(--surface-2); border-radius: 6px; padding: 8px 12px; }
.plate-summary strong{ color: var(--accent); }
.result-table td:nth-child(2), .result-table td:nth-child(3){ text-align: right; }
.showPlatesBtn{ margin-top: 6px; margin-bottom: 6px; }
.plates-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 8px; }
.plate-card{ border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--surface-2); }
.plate-caption{ font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }
.plate-svg{ width: 100%; height: auto; display: block; background: var(--surface); border-radius: 4px; }

/* ---------- Login ---------- */
.login-wrap{ display: flex; align-items: center; justify-content: center; min-height: 100vh; grid-column: 1 / -1; }
.login-card{
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 26px; width: 320px; max-width: calc(100vw - 40px);
}
.login-card h1{ font-size: 18px; margin-bottom: 16px; }
.login-error{ color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
