/* Design system: dark, high contrast, large touch targets, RTL first. */
:root {
  --bg: #080b10;
  --bg-2: #0d131b;
  --panel: #111923;
  --panel-2: #16202c;
  --panel-3: #1d2937;
  --line: #22303f;
  --line-2: #2d3d4f;
  --text: #e9f0f7;
  --muted: #93a4b7;
  --muted-2: #6b7d90;
  --brand: #3b9dff;
  --brand-2: #1c6fd0;
  --cyan: #22d3ee;
  --ok: #2fd07a;
  --warn: #ffb020;
  --danger: #ff5c5c;
  --violet: #a78bfa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --tap: 44px;
  --font: "Alexandria", "Segoe UI", "Noto Kufi Arabic", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 80% -10%, #10243a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
html[dir="ltr"] body { font-family: var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #24303e; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.boot { display: grid; place-items: center; align-content: center; justify-items: center; width: 100%; min-height: 100vh; gap: 12px; text-align: center; }
.boot-logo { font-size: 34px; font-weight: 800; color: var(--brand); letter-spacing: .04em; }
.boot-text { color: var(--muted); }

/* ---------- shell ---------- */
.app-shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
html[dir="ltr"] .app-shell { grid-template-columns: 236px 1fr; }
.sidebar {
  background: linear-gradient(180deg, #0c141d, #0a1017);
  border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 16px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), #0f5fb5); color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 18px rgba(59, 157, 255, .35);
}
.brand-name { font-weight: 800; font-size: 15px; }
.brand-sub { color: var(--muted-2); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px; border-radius: 11px;
  color: var(--muted); border: 1px solid transparent; background: none; cursor: pointer; text-align: start; width: 100%;
  font-size: 14.5px; font-weight: 600;
}
.nav-item:hover { background: #111b26; color: var(--text); }
.nav-item.active { background: #12293f; color: #cfe6ff; border-color: #1d4a70; }
.nav-item .ico { width: 20px; text-align: center; opacity: .95; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 10px 6px 2px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line);
  background: rgba(9, 14, 20, .82); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 700; font-size: 17px; }
.topbar-sub { color: var(--muted); font-size: 12.5px; }
.spacer { flex: 1; }
.content { padding: 20px 22px 60px; display: grid; gap: 18px; align-content: start; max-width: 1500px; }

/* ---------- pills, badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.pill.ok { color: #b9f5d4; border-color: #1d5c3f; background: #0f2a1f; }
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.pill.warn { color: #ffe2ad; border-color: #6b4d13; background: #2a1f08; }
.pill.warn .dot { background: var(--warn); }
.pill.bad { color: #ffc9c9; border-color: #6d2525; background: #2a1010; }
.pill.bad .dot { background: var(--danger); }
.pill.info { color: #cfe6ff; border-color: #1d4a70; background: #10243a; }
.pill.info .dot { background: var(--brand); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: var(--panel-3); color: var(--muted); border: 1px solid var(--line-2);
}
.badge.available { background: #0f2a1f; color: #9df0c2; border-color: #1d5c3f; }
.badge.occupied { background: #33230a; color: #ffd48a; border-color: #6b4d13; }
.badge.paused { background: #241a3d; color: #d3c4ff; border-color: #4a3777; }
.badge.reserved { background: #10243a; color: #b6dbff; border-color: #1d4a70; }
.badge.maintenance { background: #2a1010; color: #ffc0c0; border-color: #6d2525; }
.badge.disabled { background: #1a1f26; color: var(--muted-2); }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; }
.card-sub { color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.devs { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.pos { grid-template-columns: 1fr 380px; align-items: start; }
@media (max-width: 1100px) { .grid.pos { grid-template-columns: 1fr; } .app-shell { grid-template-columns: 76px 1fr; } .nav-item span:not(.ico) { display: none; } .brand-name, .brand-sub { display: none; } }

.kpi { background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.kpi-sub { color: var(--muted-2); font-size: 12px; margin-top: 4px; }
.kpi.accent { border-color: #1d4a70; background: linear-gradient(160deg, #12293f, #0e1b28); }

/* device cards */
.dev {
  position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; display: grid; gap: 8px; cursor: pointer; transition: .15s; min-height: 132px;
}
.dev:hover { border-color: var(--line-2); transform: translateY(-1px); }
.dev.occupied { border-color: #6b4d13; background: linear-gradient(160deg, #241a09, #14120c); }
.dev.paused { border-color: #4a3777; background: linear-gradient(160deg, #1d1730, #12101c); }
.dev.maintenance { border-color: #6d2525; background: linear-gradient(160deg, #241010, #150d0d); }
.dev.reserved { border-color: #1d4a70; }
.dev-top { display: flex; align-items: center; gap: 8px; }
.dev-code { font-weight: 800; font-size: 16px; letter-spacing: .01em; }
.dev-zone { color: var(--muted-2); font-size: 11.5px; }
.dev-timer { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.dev-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.dev-actions { display: flex; gap: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 0 16px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--panel-3);
  color: var(--text); font-weight: 700; font-size: 14.5px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { background: #22303f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--brand), var(--brand-2)); border-color: #2a7fd4; color: #fff; box-shadow: 0 6px 18px rgba(59,157,255,.25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ok { background: #0f3a26; border-color: #1d5c3f; color: #b9f5d4; }
.btn.warn { background: #3a2a08; border-color: #6b4d13; color: #ffe2ad; }
.btn.danger { background: #3a1111; border-color: #6d2525; color: #ffc9c9; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn.lg { min-height: 52px; font-size: 16px; padding: 0 22px; }
.btn.block { width: 100%; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.input, .select, .textarea {
  min-height: var(--tap); padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line-2);
  background: #0c131b; color: var(--text); width: 100%; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,157,255,.16); }
.textarea { min-height: 84px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.hint { color: var(--muted-2); font-size: 12px; }
.err-text { color: #ffb4b4; font-size: 12.5px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: start; color: var(--muted); font-weight: 700; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #182230; }
tr:hover td { background: #0f1620; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: end; }

/* ---------- modal / sheet ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 6, 10, .72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 60; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow);
  width: min(720px, 100%); max-height: 90vh; overflow: auto; padding: 20px;
}
.modal.wide { width: min(1080px, 100%); }
.modal.narrow { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- session panel ---------- */
.session-clock { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.session-price { font-size: 30px; font-weight: 800; color: var(--brand); }
.panel-line { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed #1b2733; font-size: 13.5px; }
.panel-line span:first-child { color: var(--muted); }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; inset-block-end: 20px; inset-inline-start: 20px; display: grid; gap: 10px; z-index: 90; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-2); border-inline-start: 4px solid var(--brand);
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); min-width: 260px; font-size: 13.5px;
  animation: slide .18s ease-out;
}
.toast.ok { border-inline-start-color: var(--ok); }
.toast.bad { border-inline-start-color: var(--danger); }
.toast.warn { border-inline-start-color: var(--warn); }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.login-brand { display: grid; gap: 6px; margin-bottom: 6px; }
.login-brand .mark { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(145deg, var(--brand), #0f5fb5); font-weight: 800; }
.demo-users { display: grid; gap: 6px; margin-top: 4px; }
.demo-user { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); background: #0c131b; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; cursor: pointer; }
.demo-user:hover { border-color: var(--line-2); color: var(--text); }

/* ---------- misc ---------- */
.empty { display: grid; place-items: center; gap: 8px; padding: 40px 10px; color: var(--muted-2); text-align: center; }
.empty .big { font-size: 30px; opacity: .6; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.tab.active { background: #12293f; color: #cfe6ff; border-color: #1d4a70; }
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px;
  border: 1px solid #6b4d13; background: #2a1f08; color: #ffe2ad; font-size: 13.5px; font-weight: 600;
}
.banner.bad { border-color: #6d2525; background: #2a1010; color: #ffc9c9; }
.banner.info { border-color: #1d4a70; background: #10243a; color: #cfe6ff; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.mono { font-variant-numeric: tabular-nums; }
.tiny { font-size: 11.5px; color: var(--muted-2); }
.scroll-y { max-height: 420px; overflow-y: auto; }
.cart-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px solid #182230; }
.qty { display: inline-flex; align-items: center; gap: 8px; }
.qty button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-3); cursor: pointer; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; cursor: pointer; }
.chip.active { background: #12293f; border-color: #1d4a70; color: #cfe6ff; }
.bar { height: 8px; border-radius: 6px; background: #16202c; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--cyan)); }
.kbd { font-family: ui-monospace, monospace; background: #0c131b; border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; font-size: 11.5px; }

.brand-mark-img { width: 38px; height: 38px; border-radius: 11px; }
.brand-logo { height: 22px; width: auto; display: block; }
.login-logo { height: 44px; width: auto; display: block; margin-bottom: 4px; }
.boot-logo-img { height: 54px; width: auto; }

/* ---- phone and small tablet layout ---- */
.menu-btn, .drawer-backdrop { display: none; }
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .app-shell, html[dir="ltr"] .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: 100dvh; width: min(290px, 84vw); z-index: 60;
    transform: translateX(100%); transition: transform .2s ease; overflow-y: auto; padding: 14px 12px 20px;
    box-shadow: 0 0 40px rgba(0, 0, 0, .55);
  }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  .drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 55; }
  body.nav-open .drawer-backdrop { display: block; }
  body.nav-open { overflow: hidden; }
  .nav-item span:not(.ico) { display: inline; }
  .brand-name, .brand-sub { display: block; }
  .nav-item { min-height: 46px; font-size: 15px; }
  .menu-btn {
    display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 22px; cursor: pointer;
  }
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: nowrap; }
  .topbar-title { font-size: 16px; line-height: 1.2; }
  .topbar-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
  .topbar > div:not(.menu-btn) { min-width: 0; }
  .topbar .pill:not(#clock-pill) { display: none; }
  .content { padding: 16px 16px 60px; gap: 14px; max-width: 100vw; }
  .grid.kpi { grid-template-columns: 1fr; }
  .grid.devs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .grid.two, .grid.pos, .split { grid-template-columns: 1fr; }
  .card { padding: 14px; min-width: 0; }
  .card-head { flex-wrap: wrap; }
  .card, .content > * { max-width: 100%; }
  .card table, .content table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 44px; padding: 0 14px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .tabs > * { flex: none; min-height: 44px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.narrow { width: 100%; max-height: 92dvh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
  .row > .field { min-width: 120px; }
}
@media (max-width: 480px) {
  .topbar-sub { display: none; }
  .login-card { padding: 20px 16px; }
}

@media (max-width: 900px) {
  .tabs { flex-wrap: wrap; overflow: visible; }
  .dev-code { white-space: nowrap; font-size: 14px; }
  .dev-top { flex-wrap: nowrap; min-width: 0; }
  /* card-style rows for data tables */
  .content table.rt { display: block; overflow: visible; white-space: normal; }
  table.rt thead { display: none; }
  table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: var(--panel-2); }
  table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border: 0; text-align: start; }
  table.rt td.right, table.rt td.num { text-align: start; }
  table.rt td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; flex: none; }
  table.rt td:empty { display: none; }
}
@media (max-width: 900px) { .dev-top { flex-wrap: wrap; row-gap: 6px; } .dev .badge, .dev .pill { max-width: 100%; } .dev { min-width: 0; overflow: hidden; } }
