:root {
  --bg: #0b1220;
  --bg2: #111827;
  --panel: #151c2c;
  --line: #243044;
  --text: #e8eef8;
  --muted: #93a0b5;
  --accent: #2f6fed;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(47,111,237,.18), transparent 55%),
    radial-gradient(900px 400px at 0% 100%, rgba(34,197,94,.08), transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: #9ec0ff; text-decoration: none; }
code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
code.block, .ws-box code {
  display: block;
  background: #0a101c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  overflow: auto;
  direction: ltr;
  text-align: left;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 24, 39, .92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.02em; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.live-pulse {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(34,197,94,.35);
  background: rgba(34,197,94,.12);
  color: #bbf7d0;
  font-size: .85rem;
}
.live-pulse::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--good);
}
.live-pulse.beat { box-shadow: 0 0 0 4px rgba(34,197,94,.15); }

.container { max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.loading-card { color: var(--muted); text-align: center; padding: 40px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  transition: .15s ease;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost {
  background: transparent;
  color: #dbe4f5;
  border: 1px solid var(--line);
}
.btn.ghost:hover { border-color: #3b4d6b; background: rgba(255,255,255,.03); }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.stat span { display: block; color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.45rem; }
.stat.online b { color: var(--good); }
.stat.offline b { color: #f87171; }
.stat .time { font-size: 1rem; font-weight: 500; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}
.station-list h3 { margin: 0 0 12px; }
.station-list-items { display: grid; gap: 8px; }
.station-item {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: right;
  background: #0f1624;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.station-item.active { border-color: var(--accent); background: rgba(47,111,237,.12); }
.station-item .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bad); flex-shrink: 0;
}
.station-item.is-online .dot { background: var(--good); box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
.station-item .txt { display: grid; gap: 2px; }
.station-item strong { font-size: .95rem; }
.station-item small { color: var(--muted); }
.ws-box { margin-top: 14px; }
.ws-box small { display: block; color: var(--muted); margin-bottom: 6px; }
.grade-legend { margin-top: 16px; display: grid; gap: 8px; }
.grade-legend > small { color: var(--muted); }
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
}
.legend-row i {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}
.legend-row.reserved { opacity: .55; }

.sa-price-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0 18px;
}
.sa-price-board.large .sa-grade { min-height: 120px; }
.sa-grade {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 12px;
  background: #0f1624;
  overflow: hidden;
  text-align: right;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.sa-grade::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--grade, #64748b);
}
.sa-grade .code {
  display: inline-block;
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.sa-grade strong { display: block; margin-bottom: 8px; }
.sa-grade b { display: block; font-size: 1.25rem; }
.sa-grade small { display: block; margin-top: 8px; color: var(--muted); font-size: .78rem; }
.sa-grade.is-reserved {
  opacity: .55;
  cursor: not-allowed;
  border-style: dashed;
}
.sa-grade.no-price b { color: var(--muted); font-size: 1rem; font-weight: 500; }
button.sa-grade:not(:disabled):hover { border-color: var(--grade, var(--accent)); }

.price-form select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a101c;
  color: #fff;
  font: inherit;
}

.station-container { padding: 0; overflow: hidden; }
.station-container-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .8rem;
}
.module-nav {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #0f1624;
}
.module-btn {
  border: 1px solid var(--line);
  background: #121a2b;
  color: inherit;
  border-radius: 12px;
  padding: 10px 8px;
  text-align: right;
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 4px;
}
.module-btn small { color: var(--muted); font-size: .72rem; }
.module-btn.active {
  border-color: var(--accent);
  background: rgba(47,111,237,.16);
}
.module-body { padding: 16px 18px 20px; }
.module-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.module-toolbar h3 { margin: 0; }
.section-title { margin: 18px 0 10px; font-size: 1rem; }
.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.empty-box {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: #0f1624;
}
.empty-box h4 { margin: 0 0 6px; color: var(--text); }
.alert-list { display: grid; gap: 8px; }
.alert-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f1624;
}
.alert-item strong { display: block; }
.alert-item small { color: var(--muted); }
.alert-item.sev-critical, .alert-item.sev-error, .alert-item.sev-high {
  border-color: rgba(239,68,68,.4);
}
.alert-item.sev-warning, .alert-item.sev-medium {
  border-color: rgba(245,158,11,.4);
}
.map-box { display: grid; gap: 10px; }
.map-frame {
  width: 100%;
  min-height: 320px;
  border: 0;
  border-radius: 14px;
  background: #0a101c;
}
.inline-price { margin-top: 18px; }
.price-grid-3 {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.stations-layout { align-items: start; }
.station-hero.online { border-color: rgba(34,197,94,.45); }
.station-hero.offline { border-color: rgba(239,68,68,.35); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card-head h2 { margin: 0 0 4px; }
.meta, .muted { color: var(--muted); font-size: .9rem; }
.hero-status { text-align: left; display: grid; gap: 6px; justify-items: end; }
.pill {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
}
.pill.on { background: rgba(34,197,94,.15); color: #bbf7d0; }
.pill.off { background: rgba(239,68,68,.15); color: #fecaca; }
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.tab {
  border: 1px solid var(--line);
  background: #0f1624;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
}
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tab-body { min-height: 280px; }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.ov-card {
  background: #0f1624;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.ov-card h4 { margin: 0; color: var(--muted); font-size: .85rem; font-weight: 500; }
.ov-card b { display: block; font-size: 1.5rem; margin: 4px 0; }
.ov-card small { color: var(--muted); }
.live-hint {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(47,111,237,.08);
  border: 1px solid rgba(47,111,237,.2);
}
.mini-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.mini-panels h4 { margin: 0 0 8px; }
.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}
.tile {
  background: #0f1624;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.tile header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tile h4 { margin: 0; }
.tile dl { margin: 0; display: grid; gap: 6px; }
.tile dl div { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.tile dt { color: var(--muted); }
.tile dd { margin: 0; }
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(147,197,253,.12);
  color: #bfdbfe;
  font-size: .78rem;
}
.tag.pending { background: rgba(245,158,11,.15); color: #fcd34d; }
.tag.sent { background: rgba(59,130,246,.15); color: #93c5fd; }
.tag.done { background: rgba(34,197,94,.15); color: #86efac; }
.tag.error { background: rgba(239,68,68,.15); color: #fca5a5; }

.tank-bar {
  height: 10px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
  margin-bottom: 10px;
}
.tank-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #22c55e);
}

.prices-layout {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
}
.price-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.price-card {
  text-align: right;
  background: #0f1624;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.price-card:hover { border-color: var(--accent); }
.price-card strong { display: block; color: var(--muted); font-weight: 500; }
.price-card b { display: block; font-size: 1.35rem; margin: 6px 0; }
.price-card small { color: var(--muted); }

.price-form {
  display: grid;
  gap: 10px;
  background: #0f1624;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  align-content: start;
}
.price-form label { display: grid; gap: 6px; font-size: .9rem; }
.price-form input, .login-card input, .inline-form select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a101c;
  color: #fff;
  font: inherit;
}

.cmd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.cmd-table th, .cmd-table td {
  border-top: 1px solid var(--line);
  padding: 8px 6px;
  text-align: right;
}
.cmd-table.wide th { color: var(--muted); font-weight: 500; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(34,197,94,.45); }
.toast.err { border-color: rgba(239,68,68,.45); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(100%, 400px);
  display: grid;
  gap: 12px;
  background: rgba(21, 28, 44, .95);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0; }
.login-card p { margin: 0; color: var(--muted); }
.alert {
  background: rgba(127,29,29,.55);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 10px;
}

.doc {
  max-width: 900px;
  margin: 24px auto;
  padding: 24px;
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid var(--line);
}

@media (max-width: 1100px) {
  .module-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .split-2 { grid-template-columns: 1fr; }
  .price-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .summary-strip, .overview-grid { grid-template-columns: repeat(2, 1fr); }
  .prices-layout, .mini-panels { grid-template-columns: 1fr; }
  .sa-price-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .summary-strip, .overview-grid, .sa-price-board, .module-nav { grid-template-columns: 1fr; }
  .container { padding: 16px; }
  .topbar { padding: 14px 16px; }
}
