:root {
  --bg: #0A0E1A; --panel: #111727; --panel-2: #172036; --line: rgba(255,255,255,.08);
  --text: #F3F5FA; --text-2: rgba(243,245,250,.7); --muted: rgba(243,245,250,.45);
  --accent: #E8336D; --green: #22C55E; --red: #F43F5E; --gold: #F5B83D; --cyan: #22D3EE; --violet: #A78BFA;
  --r: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
a { color: var(--cyan); text-decoration: none; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%); }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; text-align: center; }
.login-card img { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 14px; object-fit: cover; }
.login-card h1 { font-size: 20px; }
.login-card p { color: var(--muted); margin: 4px 0 18px; }
.login-card input { width: 100%; padding: 13px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); outline: 0; margin-bottom: 12px; }
.login-card .err { color: var(--red); margin-top: 10px; min-height: 18px; font-size: 13px; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 250px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--line); }
.side-brand img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.side-brand b { display: block; font-size: 15px; }
.side-brand small { color: var(--muted); font-size: 12px; }
#menu { padding: 10px; flex: 1; }
#menu .grp { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; padding: 14px 10px 6px; }
#menu a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; color: var(--text-2); font-weight: 600; margin-bottom: 2px; }
#menu a:hover { background: rgba(255,255,255,.04); }
#menu a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: #fff; }
#menu a.active svg { color: var(--accent); }
#menu a .cnt { margin-left: auto; font-size: 11px; font-weight: 800; background: var(--red); color: #fff; border-radius: 99px; padding: 1px 7px; }
.side-logout { margin: 10px; padding: 11px; border-radius: 11px; border: 1px solid var(--line); color: var(--text-2); font-weight: 700; }
.side-backdrop { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: rgba(10,14,26,.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top h2 { flex: 1; font-size: 18px; }
#menuBtn { display: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,.05); color: var(--text); }
.page { padding: 20px; max-width: 1200px; width: 100%; }
.tabbar { display: none; }

/* Components */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card h3 small { font-weight: 600; color: var(--muted); font-size: 12px; }
.kpi small { color: var(--muted); font-size: 12px; font-weight: 600; display: block; }
.kpi b { display: block; font-size: 22px; margin-top: 6px; letter-spacing: -.3px; }
.kpi .sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.kpi .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px; background: rgba(255,255,255,.06); }
.kpi .ic svg { width: 18px; height: 18px; }
.mb { margin-bottom: 14px; }
.mt { margin-top: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.t-green { color: var(--green); } .t-red { color: var(--red); } .t-gold { color: var(--gold); } .t-cyan { color: var(--cyan); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 700; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.ghost { background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.inp, .field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); outline: 0; font-size: 14px; }
.field textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.inp:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field select option { background: var(--panel); }
.field input[type=color] { padding: 3px; height: 40px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: rgba(255,255,255,.15); position: relative; transition: .2s; cursor: pointer; flex: none; }
.switch input::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked { background: var(--green); }
.switch input:checked::after { left: 21px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .inp { flex: 1; min-width: 160px; }
.toolbar select.inp { flex: 0 0 auto; min-width: 130px; }

/* Table -> cards on mobile */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 800; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(255,255,255,.025); }
.tbl .nm b { display: block; }
.tbl .nm small { color: var(--muted); font-size: 12px; }
.tbl-wrap { overflow-x: auto; }

.pill { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 99px; white-space: nowrap; background: rgba(255,255,255,.08); color: var(--text-2); }
.pill.green, .pill.PAID { background: rgba(34,197,94,.15); color: var(--green); }
.pill.red, .pill.REJECTED, .pill.EXPIRED, .pill.CANCELED { background: rgba(244,63,94,.15); color: var(--red); }
.pill.gold, .pill.PENDING { background: rgba(245,184,61,.15); color: var(--gold); }
.pill.cyan { background: rgba(34,211,238,.15); color: var(--cyan); }

.pager { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); }

.chart { width: 100%; height: 200px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bar-list .it { margin-bottom: 10px; }
.bar-list .it .row-between { font-size: 13px; margin-bottom: 5px; }
.bar-list .track { height: 7px; border-radius: 9px; background: rgba(255,255,255,.06); overflow: hidden; }
.bar-list .track i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }

.pf-item { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--bg); }
.pf-item img { width: 42px; height: 42px; border-radius: 10px; object-fit: contain; background: rgba(255,255,255,.05); flex: none; }
.pf-item { flex-wrap: wrap; gap: 8px; }
.pf-item img { width: 36px; height: 36px; }
.pf-item .inp { flex: 1 1 88px; min-width: 0; padding: 9px 10px; }
.pf-item .ord { display: flex; flex-direction: column; gap: 3px; }
.pf-item .ord button { width: 26px; height: 20px; border-radius: 6px; background: rgba(255,255,255,.06); display: grid; place-items: center; }
.pf-item .ord svg { width: 14px; height: 14px; }
.logo-prev { display: flex; align-items: center; gap: 12px; }
.logo-prev img { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.status-line { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(34,197,94,.15); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 4px rgba(244,63,94,.15); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { word-break: break-all; }
.notice { padding: 11px 14px; border-radius: 11px; background: rgba(245,184,61,.1); border: 1px solid rgba(245,184,61,.25); color: #FDE68A; font-size: 13px; margin-bottom: 14px; line-height: 1.5; }
.notice.info { background: rgba(34,211,238,.08); border-color: rgba(34,211,238,.25); color: #A5F3FC; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.lvl-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr 40px; gap: 8px; margin-bottom: 8px; align-items: center; }
.list-edit .li { display: flex; gap: 8px; margin-bottom: 8px; }
.list-edit .li .inp { flex: 1; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-box { position: relative; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.modal-box h3 { font-size: 17px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #fff; color: #111; font-weight: 700; padding: 11px 18px; border-radius: 11px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); color: #fff; }

/* ===== Mobile ===== */
@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .side { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .25s; box-shadow: 10px 0 30px rgba(0,0,0,.5); }
  body.menu-open .side { transform: none; }
  body.menu-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); }
  #menuBtn { display: grid; }
  .top { padding: 10px 14px; }
  .top h2 { font-size: 16px; }
  .page { padding: 14px 14px calc(90px + var(--safe-b)); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi b { font-size: 18px; }
  .card { padding: 14px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: rgba(17,23,39,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; color: var(--muted); padding: 5px 0; position: relative; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a .cnt { position: absolute; top: 0; right: 22%; font-size: 9.5px; background: var(--red); color: #fff; border-radius: 99px; padding: 0 5px; }
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg); }
  .tbl.cards td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl.cards td::before { content: attr(data-l); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
  .tbl.cards td.nm { display: block; text-align: left; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  .tbl.cards td.nm::before { display: none; }
  .tbl.cards td.acts { justify-content: flex-end; padding-top: 8px; }
  .tbl.cards td.acts::before { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
  .modal { padding: 0; align-items: end; }
  .modal-box { border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: calc(20px + var(--safe-b)); }
  .lvl-row { grid-template-columns: 1.2fr .8fr .9fr 36px; gap: 6px; }
}
