:root {
  --bg: #f4f5f8; --surface: #fff; --surface-2: #f9fafb; --border: #e4e6eb;
  --text: #1b1e27; --muted: #6b7280; --accent: #4f46e5; --accent-soft: #eef2ff;
  --ok: #047857; --ok-soft: #ecfdf5; --err: #b91c1c; --err-soft: #fef2f2;
  --warn: #b45309; --warn-soft: #fffbeb; --side: #111827; --side-text: #cbd5e1;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --surface: #181b23; --surface-2: #1e222c; --border: #2a2f3b;
    --text: #e6e8ee; --muted: #9aa3b2; --accent: #818cf8; --accent-soft: #23264a;
    --ok: #34d399; --ok-soft: #10261f; --err: #f87171; --err-soft: #2c1517;
    --warn: #fbbf24; --warn-soft: #2a2110; --side: #0b0d12; --side-text: #9aa3b2;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.layout { display: flex; min-height: 100vh; }
.side { width: 230px; background: var(--side); color: var(--side-text); padding: 20px 14px;
        display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.brand span { color: #818cf8; }
.side a { color: var(--side-text); padding: 9px 10px; border-radius: 8px; display: block; }
.side a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side a.active { background: rgba(129,140,248,.18); color: #fff; }
.side .sep { margin: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.side .bottom { margin-top: auto; padding: 10px; font-size: 12px; }
.side .bottom button { background: none; border: 0; color: var(--side-text); padding: 0; cursor: pointer; font: inherit; }
.main { flex: 1; padding: 28px 32px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .cols-2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; }
textarea { min-height: 120px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; margin: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
       background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-weight: 500; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
         background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.empty { text-align: center; padding: 30px; color: var(--muted); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--err-soft); color: var(--err); }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .panel { width: 100%; max-width: 380px; padding: 28px; }
.auth .field { margin-bottom: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs a { padding: 10px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.vcard { border-radius: 14px; padding: 20px; color: #fff; min-height: 190px; display: flex; flex-direction: column;
         background: linear-gradient(135deg, #4338ca, #7c3aed 60%, #db2777); box-shadow: 0 6px 20px rgba(67,56,202,.25); }
.vcard:nth-child(3n+2) { background: linear-gradient(135deg, #0f766e, #0891b2); }
.vcard:nth-child(3n+3) { background: linear-gradient(135deg, #1f2937, #475569); }
.vcard .top { display: flex; justify-content: space-between; font-weight: 600; }
.vcard .num { font-family: ui-monospace, Menlo, monospace; font-size: 19px; letter-spacing: .08em; margin: 22px 0 14px; }
.vcard .meta { display: flex; gap: 22px; font-size: 12px; opacity: .95; }
.vcard .meta b { display: block; font-size: 10px; opacity: .7; font-weight: 500; text-transform: uppercase; }
.vcard .actions { margin-top: auto; padding-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.vcard .btn { background: rgba(255,255,255,.16); border-color: transparent; color: #fff; }
.vcard .btn:hover { background: rgba(255,255,255,.26); }
.acc-item .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.acc-item .v { font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.acc-item .line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--border); }
.assign-list { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.assign-list .check { padding: 5px 0; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { padding: 8px 10px; width: 100%; }
  .side .sep { display: none; }
  .side .bottom { margin: 0; width: 100%; }
  .main { padding: 18px 16px; }
}
