:root {
  --bg: #f4f3fb;
  --surface: #ffffff;
  --border: #e6e3f5;
  --text: #241f3a;
  --text-muted: #746e94;
  --primary: #6c4de6;
  --primary-dark: #5636c9;
  --primary-soft: #efeafd;
  --success: #1ba672;
  --danger: #e5484d;
  --warn: #c98a12;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(76, 60, 140, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

[hidden] { display: none !important; }

/* ── Login ── */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #efeafd 0%, var(--bg) 60%);
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { font-size: 40px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-sub { color: var(--text-muted); font-size: 14px; margin: 0 0 20px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
  background: var(--bg);
  color: var(--text);
}
.login-card input:focus { outline: 2px solid var(--primary); }
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--text); }
.btn-block { width: 100%; }

/* ── App shell ── */
.app-view { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-sub { font-size: 13px; font-weight: 400; color: var(--text-muted); margin-left: 8px; }

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; }
.stat-card .stat-value.accent { color: var(--primary); }

/* ── Panels ── */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-head input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  min-width: 220px;
  background: var(--bg);
  color: var(--text);
}
.panel-body { padding: 18px 20px; }

.settings-row { display: flex; gap: 24px; flex-wrap: wrap; }
.setting-item label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.inline-form-wide input { flex: 1; min-width: 140px; }
.form-msg { margin-top: 10px; font-size: 13px; }
.form-msg.ok { color: var(--success); }
.form-msg.err { color: var(--danger); }

/* ── Table ── */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 12px 20px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-soft); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-done { background: #e3f7ee; color: var(--success); }
.badge-waiting { background: #fdf2e0; color: var(--warn); }
.badge-cancelled { background: #fdeaea; color: var(--danger); }
.badge-received { background: #e9f0ff; color: #2f6fed; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 24px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171423;
    --surface: #201c33;
    --border: #322c4d;
    --text: #f1eefc;
    --text-muted: #a099c2;
    --primary-soft: #2a2447;
    --shadow: 0 2px 12px rgba(0,0,0,0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #171423;
  --surface: #201c33;
  --border: #322c4d;
  --text: #f1eefc;
  --text-muted: #a099c2;
  --primary-soft: #2a2447;
  --shadow: 0 2px 12px rgba(0,0,0,0.35);
}
