:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #1a1e24;
  --line: #262b33;
  --line-2: #323844;
  --text: #e9e6df;
  --muted: #8b919b;
  --gold: #c9a227;
  --gold-2: #e2bd45;
  --gold-soft: rgba(201, 162, 39, .12);
  --green: #3fae73;
  --green-soft: rgba(63, 174, 115, .13);
  --red: #d2524c;
  --red-soft: rgba(210, 82, 76, .13);
  --blue: #5b8fd6;
  --blue-soft: rgba(91, 143, 214, .13);
  --radius: 10px;
  --head: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--head); letter-spacing: .02em; margin: 0; font-weight: 600; }
h1 { font-size: 30px; text-transform: uppercase; }
h2 { font-size: 21px; text-transform: uppercase; }
h3 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 18px; border-bottom: 1px solid var(--line); }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand b { display: block; font-family: var(--head); font-size: 19px; line-height: 1; letter-spacing: .06em; text-transform: uppercase; }
.brand span { font-family: var(--head); color: var(--gold); letter-spacing: .32em; font-size: 12px; text-transform: uppercase; }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px; color: var(--muted);
  font-weight: 500; margin-bottom: 2px; position: relative;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--gold-soft); color: var(--gold-2); }
.nav a.on::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--gold); }
.nav .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; font-weight: 600; }
.side-foot { border-top: 1px solid var(--line); padding: 14px 16px; }
.who { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--panel-2); border: 1px solid var(--line-2); font-family: var(--head); font-weight: 700; color: var(--gold);
}
.who b { display: block; line-height: 1.2; }
.who span { font-size: 12px; color: var(--muted); }
.side-foot .row { display: flex; gap: 6px; }

.main { min-width: 0; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 32px; border-bottom: 1px solid var(--line); background: rgba(11, 13, 16, .85);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5;
}
.top .menu-btn { display: none; }
.content { padding: 28px 32px 60px; max-width: 1320px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.duty-pill {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px;
  padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted);
}
.duty-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.duty-pill.on { color: var(--green); border-color: rgba(63, 174, 115, .4); background: var(--green-soft); }
.duty-pill.on i { background: var(--green); box-shadow: 0 0 0 4px rgba(63, 174, 115, .2); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(63, 174, 115, 0); } }

/* ---------- Components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: 600 13px var(--body); padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); white-space: nowrap;
}
.btn:hover { border-color: #47505e; }
.btn svg { width: 16px; height: 16px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #17130a; }
.btn.gold:hover { background: var(--gold-2); }
.btn.green { background: var(--green); border-color: var(--green); color: #07150d; }
.btn.red { background: transparent; border-color: rgba(210, 82, 76, .5); color: var(--red); }
.btn.red:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.big { padding: 14px 26px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .v { font-family: var(--head); font-size: 28px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.accent { border-color: rgba(201, 162, 39, .4); background: linear-gradient(160deg, rgba(201, 162, 39, .1), var(--panel) 60%); }
.kpi .v.pos { color: var(--green); }
.kpi .v.neg { color: var(--red); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; color: var(--muted); font: 600 13px var(--body); padding: 10px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.on { color: var(--gold-2); border-bottom-color: var(--gold); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .015); }
td.act { text-align: right; white-space: nowrap; }
td.act .btn { margin-left: 4px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid; white-space: nowrap; }
.b-gray { color: var(--muted); border-color: var(--line-2); }
.b-gold { color: var(--gold-2); border-color: rgba(201, 162, 39, .45); background: var(--gold-soft); }
.b-green { color: var(--green); border-color: rgba(63, 174, 115, .45); background: var(--green-soft); }
.b-red { color: var(--red); border-color: rgba(210, 82, 76, .45); background: var(--red-soft); }
.b-blue { color: var(--blue); border-color: rgba(91, 143, 214, .45); background: var(--blue-soft); }

.banner {
  display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px;
  background: var(--gold-soft); border: 1px solid rgba(201, 162, 39, .4); color: var(--gold-2);
}

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
label.f { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; font: 14px var(--body); color: var(--text); background: var(--bg);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input[type=checkbox] { width: auto; accent-color: var(--gold); }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.search { max-width: 260px; }

.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.perm-group { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.perm-group h4 { margin: 0 0 6px; font-family: var(--head); text-transform: uppercase; letter-spacing: .06em; font-size: 14px; color: var(--gold-2); }
.perm-group .check { padding: 3px 0; font-size: 13px; }
.perm-group h4 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.perm-group h4 .btn { font-family: var(--body); text-transform: none; letter-spacing: 0; padding: 2px 8px; }
code { font: 12px ui-monospace, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; color: var(--gold-2); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 9px; }
.seg button { background: none; border: 0; color: var(--muted); font: 600 12.5px var(--body); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--gold); color: #17130a; }

.drop { border: 1px dashed var(--line-2); border-radius: 10px; padding: 14px; cursor: pointer; text-align: center; background: var(--bg); }
.drop:hover { border-color: var(--gold); }
.drop-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; }
.drop-preview svg { width: 28px; height: 28px; }
.drop-preview img, .proof-img { max-width: 100%; max-height: 360px; border-radius: 8px; display: block; margin: 8px auto 0; }

.presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .65); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto;
  animation: fade .15s;
}
.modal { width: 100%; max-width: 620px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }

#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 99; display: grid; gap: 8px; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--green); padding: 11px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); max-width: 360px; animation: fade .2s; }
.toast.err { border-left-color: var(--red); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(ellipse at top, rgba(201, 162, 39, .1), transparent 55%), var(--bg); }
.auth-box { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo svg { width: 64px; height: 64px; }
.auth-logo h1 { font-size: 30px; letter-spacing: .08em; margin-top: 10px; line-height: 1; }
.auth-logo span { font-family: var(--head); color: var(--gold); letter-spacing: .4em; text-transform: uppercase; font-size: 14px; }

/* ---------- Service ---------- */
.clock-card { text-align: center; padding: 34px 20px; }
.clock { font-family: var(--head); font-size: 64px; font-weight: 600; letter-spacing: .04em; font-variant-numeric: tabular-nums; line-height: 1; margin: 10px 0 6px; }
.clock.on { color: var(--green); }

/* ---------- Docs / rules ---------- */
.doc { white-space: pre-wrap; line-height: 1.7; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; max-height: 55vh; overflow-y: auto; }
.rule { margin-bottom: 16px; }
.rule .card-head h3 { display: flex; gap: 10px; align-items: center; }

.sig-pad { border: 1px dashed var(--line-2); border-radius: 8px; background: #f4f1e8; touch-action: none; width: 100%; height: 160px; display: block; cursor: crosshair; }
.sig-img { background: #f4f1e8; border-radius: 6px; max-height: 90px; padding: 4px; }

/* ---------- Chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar-pair { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.bar { width: 42%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.in { background: var(--gold); }
.bar.out { background: #5a6170; }
.bar-col span { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.inv-preview { background: #fff; color: #16181c; border-radius: 8px; padding: 26px; font: 14px/1.6 Georgia, 'Times New Roman', serif; }
.inv-preview .hd { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--gold); padding-bottom: 12px; margin-bottom: 20px; }
.inv-preview .hd b { display: block; font: 700 24px/1 var(--head); letter-spacing: .08em; text-transform: uppercase; }
.inv-preview .hd small { color: #8a6d10; letter-spacing: .3em; font: 600 11px var(--body); text-transform: uppercase; }
.inv-preview .hd .r { text-align: right; font: 13px var(--body); }
.inv-preview h2 { color: #16181c; }
.inv-preview .meta { font: 13px var(--body); color: #444; margin-bottom: 14px; }
.inv-preview table { font: 13px var(--body); }
.inv-preview th { background: #f3f0e6; color: #555; }
.inv-preview td, .inv-preview th { border-bottom: 1px solid #ddd; padding: 8px; }
.inv-preview .r { text-align: right; }
.inv-preview .tot td { font-weight: 700; font-size: 16px; border-top: 2px solid #16181c; border-bottom: 0; }
.inv-preview .doc { background: none; border: 0; padding: 0; max-height: none; }
.inv-preview .note { font: 12px var(--body); color: #555; margin-top: 20px; border-top: 1px solid #ddd; padding-top: 10px; }
.inv-preview .stamp { display: inline-block; border: 2px solid #2e8b57; color: #2e8b57; font: 700 13px var(--body); padding: 3px 10px; letter-spacing: 2px; transform: rotate(-4deg); }
.inv-preview tbody tr:hover td { background: none; }

.list-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

.items-table input { padding: 7px 9px; }
.items-table td { padding: 6px 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); }
  .top { padding: 12px 16px; }
  .top .menu-btn { display: inline-flex; }
  .content { padding: 20px 16px 50px; }
  .g2, .g3, .perm-grid { grid-template-columns: 1fr; }
  .form .row2, .form .row3 { grid-template-columns: 1fr; }
  .clock { font-size: 48px; }
}
