:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3f8;
  --text: #172033;
  --muted: #667085;
  --brand: #155eef;
  --brand-dark: #0040c1;
  --danger: #c01048;
  --success: #067647;
  --warning: #b54708;
  --border: #d0d5dd;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: #101828; color: white; padding: 28px 20px; }
.brand { font-size: 24px; font-weight: 800; letter-spacing: -.04em; margin-bottom: 28px; }
.brand span { color: #84adff; }
.nav { display: grid; gap: 8px; }
.nav a { color: #d0d5dd; padding: 11px 14px; border-radius: 10px; font-weight: 650; }
.nav a:hover, .nav a.active { background: #1d2939; color: white; text-decoration: none; }
.main { padding: 34px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 28px; }
h1, h2, h3 { margin: 0 0 16px; letter-spacing: -.025em; }
h1 { font-size: clamp(28px, 4vw, 40px); }
.muted { color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.card { background: var(--surface); border: 1px solid #e4e7ec; border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 24px rgba(16,24,40,.04); }
.metric { font-size: 32px; font-weight: 800; margin-top: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font: inherit; background: white; color: var(--text); }
input:focus, textarea:focus, select:focus { outline: 3px solid #d1e0ff; border-color: var(--brand); }
label { display: grid; gap: 7px; font-weight: 650; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
button, .button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; border: 0; border-radius: 10px; padding: 10px 17px; font: inherit; font-weight: 750; cursor: pointer; background: var(--brand); color: white; }
button:hover, .button:hover { background: var(--brand-dark); text-decoration: none; }
.button.secondary, button.secondary { background: var(--surface-soft); color: var(--text); }
.button.danger, button.danger { background: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid #eaecf0; vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 750; background: var(--surface-soft); }
.badge.ready, .badge.printed { color: var(--success); background: #dcfae6; }
.badge.problem, .badge.upload_error { color: var(--danger); background: #ffe4e8; }
.badge.recording, .badge.processing, .badge.uploading { color: var(--brand); background: #e0eaff; }
.notice { padding: 14px 16px; border-radius: 10px; background: #fffaeb; color: #93370d; margin-bottom: 18px; }
.error { padding: 14px 16px; border-radius: 10px; background: #fff1f3; color: var(--danger); margin-bottom: 18px; }
.auth-page, .public-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #d1e9ff, transparent 45%), var(--bg); }
.auth-card, .public-card { width: min(100%, 460px); background: white; padding: 34px; border-radius: 24px; box-shadow: 0 28px 70px rgba(16,24,40,.15); }
.auth-card form { display: grid; gap: 18px; }
.public-card { width: min(100%, 760px); text-align: center; }
.public-icon { width: 72px; height: 72px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 22px; background: #e0eaff; font-size: 34px; }
.user { display: flex; gap: 10px; align-items: center; }
.user form { margin: 0; }
.label-editor-grid { display:grid; grid-template-columns:minmax(360px,1fr) minmax(320px,1fr); gap:22px; margin-top:20px; align-items:start; }
.label-canvas { position:relative; width:100%; aspect-ratio:58/40; background:white; border:1px solid var(--border); box-shadow:0 4px 18px #10182818; overflow:hidden; }
.label-element { position:absolute; border:1px dashed #155eef; background:#e0eaffaa; display:grid; place-items:center; font-size:12px; cursor:move; user-select:none; overflow:hidden; color:#0040c1; }

@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { padding: 16px; }
  .brand { margin-bottom: 12px; }
  .nav { display: flex; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .main { padding: 22px 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .label-editor-grid { grid-template-columns:1fr; }
}
