:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e5ea;
  --primary: #2563eb;
  --primary-text: #fff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }
button {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); cursor: pointer; color: var(--text);
}
button:hover { border-color: #b8bcc6; }
button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--primary); }
input, select, textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.error { color: var(--danger); min-height: 1em; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }

.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 8px; font-size: 20px; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
aside { background: #111827; color: #d1d5db; display: flex; flex-direction: column; padding: 16px 0; }
.brand { font-weight: 700; font-size: 18px; color: #fff; padding: 0 20px 16px; }
nav a {
  display: block; padding: 9px 20px; color: inherit; text-decoration: none;
}
nav a:hover { background: #1f2937; }
nav a.active { background: #1f2937; color: #fff; border-left: 3px solid var(--primary); padding-left: 17px; }
.me { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid #374151; font-size: 13px; }
.me .link { color: #93c5fd; margin-top: 4px; }

main { padding: 20px 24px; min-width: 0; }
main header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
main h2 { margin: 0; font-size: 20px; }
#actions, .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.toolbar { margin-bottom: 12px; }
.toolbar label { min-width: 140px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { background: #f9fafb; font-weight: 600; font-size: 12px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .row-actions { display: flex; gap: 6px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eef2ff; color: #3730a3; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #f3f4f6; color: #4b5563; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .label { color: var(--muted); font-size: 12px; }
.clock { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog form { padding: 20px; }
dialog h3 { margin: 0 0 16px; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid .full { grid-column: 1 / -1; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  aside { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 16px; }
  .brand { padding: 0 12px 0 0; }
  nav { display: flex; overflow-x: auto; flex: 1; }
  nav a { padding: 8px 10px; white-space: nowrap; }
  nav a.active { border-left: 0; padding-left: 10px; border-bottom: 2px solid var(--primary); }
  .me { margin: 0; padding: 0; border: 0; display: flex; gap: 8px; }
  main { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
}
