:root {
  --bg: #0b0e13; --panel: #12161d; --panel2: #171c24; --panel3: #1d232d;
  --line: #232a34; --line2: #2f3744;
  --text: #e7e9ec; --muted: #8b93a0; --faint: #5f6774;
  --gold: #d4af6a; --gold-2: #e8c98c; --gold-bg: #2a2214; --on-gold: #1a1408;
  --danger: #e57373; --danger-bg: #2c1717; --ok: #66c495; --ok-bg: #142a20; --warn: #f0c27a; --warn-bg: #2d2313;
  --r: 10px; --r-lg: 14px;
  --font: "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, "Geeza Pro", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.hidden { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line2); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------- buttons & fields --------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--panel3); border-color: #3a4352; }
.btn:focus-visible, .field:focus-visible, .icon-btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.btn.primary:hover { background: var(--gold-2); }
.btn.danger { color: var(--danger); border-color: #4a2626; background: transparent; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: wait; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--panel3); color: var(--text); }
.icon-btn.on { color: var(--gold); }

label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.field { width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--bg); transition: border-color .15s; }
.field:hover { border-color: #3a4352; }
.field:focus { border-color: var(--gold); outline: none; }
textarea.field { min-height: 90px; resize: vertical; }
select.field { appearance: none; background-image: none; }
.f { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .field { padding-inline-end: 80px; }
.input-wrap .tools { position: absolute; inset-inline-end: 4px; display: flex; gap: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { margin-top: 4px; accent-color: var(--gold); width: 16px; height: 16px; }
.err { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 6px; }
.meter { height: 5px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .2s, background .2s; }
.meter-txt { font-size: 12px; margin-top: 4px; color: var(--muted); }

/* --------- auth screens --------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 430px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--gold-bg); color: var(--gold); display: flex; align-items: center; justify-content: center; }
.brand .logo svg.i { width: 24px; height: 24px; }
.brand h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: 0; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.auth-card h2 { font-size: 18px; margin: 0 0 8px; }
.auth-card .lead { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.note { border-radius: var(--r); padding: 12px 14px; font-size: 13.5px; background: var(--panel2); border: 1px solid var(--line); margin-bottom: 16px; }
.note.warn { background: var(--warn-bg); border-color: #4a3a1c; color: #f3d9ab; }
.note.danger { background: var(--danger-bg); border-color: #4a2626; color: #f2b8b8; }
.note.ok { background: var(--ok-bg); border-color: #24503b; color: #b9e6cd; }
.note ul { margin: 6px 0 0; padding-inline-start: 18px; }
.code-box { font-family: var(--mono); direction: ltr; text-align: center; font-size: 19px; letter-spacing: 1px; padding: 16px 10px; border-radius: var(--r); border: 1px dashed var(--gold); background: var(--gold-bg); color: var(--gold-2); margin-bottom: 12px; word-break: break-all; user-select: all; }
.link-btn { background: none; border: 0; color: var(--gold-2); cursor: pointer; padding: 0; font-size: 13.5px; }
.link-btn:hover { text-decoration: underline; }
.center { text-align: center; }
.mt { margin-top: 14px; }

/* --------- shell --------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-inline-start: 0; border-inline-end: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { padding: 0 8px; margin-bottom: 18px; }
.side .brand .logo { width: 36px; height: 36px; border-radius: 10px; }
.side .brand h1 { font-size: 19px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r); color: var(--muted); cursor: pointer; text-decoration: none; }
.nav a:hover { background: var(--panel2); color: var(--text); }
.nav a.active { background: var(--gold-bg); color: var(--gold-2); }
.nav a .count { margin-inline-start: auto; font-size: 12px; color: var(--faint); }
.nav a.active .count { color: var(--gold); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.side .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.main { min-width: 0; padding: 22px 28px 60px; }
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.top .menu-btn { display: none; }
.search { flex: 1; position: relative; max-width: 560px; }
.search svg.i { position: absolute; inset-inline-start: 12px; top: 12px; color: var(--faint); }
.search .field { padding-inline-start: 40px; background: var(--panel); }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.page-head .grow { flex: 1; }

/* --------- dashboard --------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.stat .k { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat .v small { font-size: 13px; font-weight: 400; color: var(--muted); }
.stat.warn { background: var(--warn-bg); border-color: #4a3a1c; }
.stat.warn .k, .stat.warn .v { color: var(--warn); }
.stat.bad { background: var(--danger-bg); border-color: #4a2626; }
.stat.bad .k, .stat.bad .v { color: var(--danger); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 16px 10px; margin-bottom: 16px; }
.card > h3 { font-size: 15px; margin: 10px 0 4px; display: flex; align-items: center; gap: 8px; }
.card > h3 .grow { flex: 1; }
.empty { color: var(--muted); font-size: 14px; padding: 18px 4px; text-align: center; }
.empty-big { text-align: center; padding: 50px 16px; background: var(--panel); border: 1px dashed var(--line2); border-radius: var(--r-lg); }
.empty-big .ic { width: 56px; height: 56px; border-radius: 16px; background: var(--gold-bg); color: var(--gold); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.empty-big .ic svg.i { width: 28px; height: 28px; }
.empty-big h3 { margin: 0 0 6px; font-size: 17px; }
.empty-big p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

/* --------- list --------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line2); background: transparent; border-radius: 20px; padding: 4px 12px; font-size: 13px; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--gold-bg); border-color: #5a4825; color: var(--gold-2); }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }
.it { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.it:last-child { border-bottom: 0; }
.it:hover { background: var(--panel2); }
.card .it { padding: 10px 2px; }
.card .it:hover { background: transparent; }
.av { width: 38px; height: 38px; border-radius: 10px; background: var(--panel3); color: var(--gold); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.it .body { flex: 1; min-width: 0; }
.it .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.it .t svg.i { width: 14px; height: 14px; color: var(--gold); }
.it .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it .acts { display: flex; gap: 2px; }
.dots { letter-spacing: 2px; color: var(--faint); font-family: var(--mono); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 9px; border-radius: 20px; background: var(--panel3); color: var(--muted); white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.gold { background: var(--gold-bg); color: var(--gold-2); }
.price { font-weight: 600; white-space: nowrap; }
.tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line2); border-radius: 6px; padding: 0 6px; }

/* --------- modal --------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 6, 9, .72); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; padding: 20px 22px 22px; }
.modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; flex-wrap: wrap; }
.modal-foot .grow { flex: 1; }
.kv { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; }
.kv .r { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.kv .r:last-child { border-bottom: 0; }
.kv .k { width: 110px; flex-shrink: 0; color: var(--muted); font-size: 13px; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; white-space: pre-wrap; }
.typetabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
.typetabs button { border: 1px solid var(--line2); background: var(--bg); border-radius: var(--r); padding: 8px 4px; font-size: 12.5px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.typetabs button.on { border-color: var(--gold); color: var(--gold-2); background: var(--gold-bg); }
.gen { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-top: 8px; font-size: 13px; }
.gen .row { flex-wrap: wrap; gap: 14px; }
.gen input[type=range] { accent-color: var(--gold); width: 140px; }
.frow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.set-sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 14px; }
.set-sec h3 { margin: 0 0 4px; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.set-sec p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.set-sec .row { flex-wrap: wrap; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel3); border: 1px solid var(--line2); color: var(--text); padding: 10px 18px; border-radius: 30px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --------- responsive --------- */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 40; transform: translateX(100%); transition: transform .2s; }
  .shell.nav-open .side { transform: translateX(0); }
  .shell.nav-open .scrim { position: fixed; inset: 0; background: rgba(4, 6, 9, .6); z-index: 30; }
  .top .menu-btn { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat .v { font-size: 21px; }
  .typetabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kv .k { width: 84px; }
  .it .acts .hide-sm { display: none; }
  .frow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; }
  .auth-card { padding: 24px 18px; }
  .top .add-txt { display: none; }
}
.row.centered { justify-content: center; flex-wrap: wrap; }
.spinner.small-spin { width: 14px; height: 14px; border-width: 2px; border-top-color: currentColor; display: inline-block; }
@media print {
  body * { visibility: hidden; }
  .code-box, .code-box * { visibility: visible; }
  .code-box { position: absolute; top: 40px; left: 0; right: 0; color: #000; background: #fff; border-color: #000; }
}
.scrim { display: none; }
@media (max-width: 900px) { .shell.nav-open .scrim { display: block; } }
.code-box { font-size: 17px; }
.input-wrap .field { padding-left: 84px; padding-right: 12px; }
.input-wrap .tools { left: 4px; right: auto; inset-inline-end: auto; }
