/* Sahab Cloud dashboard.
   One accent (burnt orange), neutral greys, the same tokens in light and dark.
   Radius rule: surfaces 14px, buttons and inputs 10px, pills fully round. */
:root {
  color-scheme: light;
  --bg: #f1f2f4;
  --surface: #ffffff;
  --surface-2: #f6f7f8;
  --line: #e3e5e9;
  --text: #15171a;
  --text-2: #565a63;
  --text-3: #868a93;
  --accent: #c2410c;
  --accent-soft: #fbeae1;
  --accent-ink: #ffffff;
  --good: #157f3c;
  --good-soft: #e3f3e8;
  --bad: #b42318;
  --bad-soft: #fbe7e5;
  --warn: #9a6408;
  --warn-soft: #fbf1dc;
  --term-bg: #121316;
  --term-text: #d7d9de;
  --term-dim: #6c707a;
  --grid: #eceef1;
  --shadow: 0 1px 2px rgba(21, 23, 26, .05), 0 1px 1px rgba(21, 23, 26, .03);
  --r-surface: 14px;
  --r-control: 10px;
  --gutter: 16px;
  --font: "Geist", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #17181b;
  --surface-2: #1d1f23;
  --line: #2a2c31;
  --text: #ecedef;
  --text-2: #a5a8b0;
  --text-3: #71757e;
  --accent: #f2783e;
  --accent-soft: rgba(242, 120, 62, .14);
  --accent-ink: #1b0e06;
  --good: #4fd08a;
  --good-soft: rgba(79, 208, 138, .12);
  --bad: #f6776b;
  --bad-soft: rgba(246, 119, 107, .12);
  --warn: #e9b949;
  --warn-soft: rgba(233, 185, 73, .12);
  --term-bg: #0a0b0d;
  --grid: #24262b;
  --shadow: none;
}
:root[lang="ar"] { --font: "IBM Plex Sans Arabic", "Geist", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.ph, .ph-fill { font-size: 18px; line-height: 1; flex: none; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand .ph-fill { color: var(--accent); font-size: 20px; }
.plan {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.plan b { font-weight: 650; }
.plan .sep { color: var(--text-3); }

main { padding: 0 var(--gutter); max-width: 720px; margin: 0 auto; }

/* surfaces */
.surface { background: var(--surface); border-radius: var(--r-surface); box-shadow: var(--shadow); }
:root[data-theme="dark"] .surface { border: 1px solid var(--line); }

/* free cycle */
.cycle { padding: 16px; margin-top: 6px; }
.cycle-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.label { font-size: 13px; color: var(--text-2); }
.big { font-size: 30px; font-weight: 650; letter-spacing: -.02em; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.big small { font-size: 15px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.meter { height: 4px; border-radius: 999px; background: var(--grid); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter.rest > i { background: var(--warn); }
.hint { margin: 10px 0 0; font-size: 13.5px; color: var(--text-2); }
.link {
  border: 0; background: none; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}

/* figures row */
.figures { display: grid; grid-template-columns: 1fr 1fr; margin-top: 10px; }
.figures.three { grid-template-columns: repeat(3, 1fr); }
.figure { padding: 14px 16px; min-width: 0; }
.figure + .figure { border-inline-start: 1px solid var(--line); }
.figure .value { font-size: 20px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.figure .value small { font-size: 13px; font-weight: 500; color: var(--text-3); }
.figures.three .value { font-size: 17px; }

/* bot list */
.list-head { display: flex; align-items: baseline; gap: 8px; margin: 26px 2px 10px; }
.list-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.list-head .count { color: var(--text-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.list { overflow: hidden; }
.row {
  width: 100%; border: 0; background: none; padding: 13px 14px; cursor: pointer; text-align: start;
  display: flex; align-items: center; gap: 12px; min-height: 64px;
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }
.lang {
  width: 38px; height: 38px; border-radius: var(--r-control); flex: none;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2);
  font: 600 11.5px var(--mono); letter-spacing: .02em; border: 1px solid var(--line);
}
.lang.large { width: 48px; height: 48px; font-size: 13px; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); margin-top: 1px; }
.state { font-weight: 600; }
.state.on { color: var(--good); }
.state.off { color: var(--text-3); }
.state.wait { color: var(--warn); }
.state.bad { color: var(--bad); }
.spark { flex: none; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.caret { color: var(--text-3); }
:root[dir="rtl"] .caret { transform: scaleX(-1); }

.empty { text-align: center; padding: 34px 20px; }
.empty .ph { font-size: 30px; color: var(--text-3); }
.empty h3 { margin: 10px 0 4px; font-size: 16px; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 30ch; color: var(--text-2); font-size: 14px; }
.empty .btn { margin-top: 14px; }

/* buttons */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--r-control); min-height: 42px; padding: 8px 14px;
  font-weight: 600; font-size: 14.5px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .12s ease, background-color .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.stop { color: var(--bad); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13.5px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-control); border: 0; background: none;
  color: var(--text-3); cursor: pointer; display: grid; place-items: center; flex: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

/* bot detail */
.head { display: flex; align-items: center; gap: 14px; margin: 10px 2px 16px; }
.head h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.015em; overflow-wrap: anywhere; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-top: 10px;
  border-radius: var(--r-surface); background: var(--warn-soft); color: var(--warn); font-size: 14px;
}
.notice.bad { background: var(--bad-soft); color: var(--bad); }

.tabs { display: flex; gap: 22px; margin: 22px 2px 12px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; padding: 8px 0 10px; margin-bottom: -1px; cursor: pointer;
  font-weight: 600; font-size: 15px; color: var(--text-3); border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* logs */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface);
}
.search .ph { color: var(--text-3); font-size: 16px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 14px; }
.search:focus-within { border-color: var(--accent); }
.toggle {
  height: 38px; padding: 0 12px; border-radius: var(--r-control); border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.toggle[aria-pressed="true"] { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.terminal {
  background: var(--term-bg); color: var(--term-text); border-radius: var(--r-surface);
  height: calc(100dvh - 330px); min-height: 280px; overflow: auto; padding: 10px 0;
  font: 12.5px/1.6 var(--mono); direction: ltr; text-align: left;
}
.line { display: flex; gap: 12px; padding: 0 12px; }
.line .ts { color: var(--term-dim); flex: none; user-select: none; }
.line .msg { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.line.err .msg { color: #ff8a7a; }
.terminal .empty { color: var(--term-dim); }
.terminal .empty h3 { color: var(--term-text); }
.terminal .empty p { color: var(--term-dim); }

/* files */
.file {
  display: flex; align-items: center; gap: 12px; padding: 0 6px 0 14px; min-height: 54px;
}
.file + .file, .newfile + .file { border-top: 1px solid var(--line); }
.file .ph { color: var(--text-3); font-size: 20px; }
.file .open {
  flex: 1; min-width: 0; border: 0; background: none; padding: 14px 0; cursor: pointer; text-align: start;
  font: 14px/1.3 var(--mono); direction: ltr; overflow-wrap: anywhere;
}
:root[dir="rtl"] .file .open { text-align: right; }
.file .open .dir { color: var(--text-3); }
.file.locked .open { color: var(--text-3); cursor: default; }
.file .size { font-size: 12.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag {
  font-size: 11.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.newfile { display: flex; align-items: center; gap: 8px; padding: 10px; }
.newfile input {
  flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: var(--r-control);
  border: 1px solid var(--line); background: var(--surface-2); font: 14px var(--mono); direction: ltr; outline: 0;
}
.newfile input:focus { border-color: var(--accent); }
.add {
  width: 100%; border: 0; background: none; cursor: pointer; color: var(--accent); font-weight: 600;
  display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 52px; font-size: 14.5px;
}

/* editor */
.editor-bar { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; }
.editor-bar .path {
  flex: 1; min-width: 0; font: 600 14px var(--mono); direction: ltr;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.editor-bar .path.dirty::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-start: 8px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.CodeMirror {
  height: calc(100dvh - 140px); min-height: 320px; border-radius: var(--r-surface);
  background: var(--surface); color: var(--text); font: 13px/1.55 var(--mono); direction: ltr;
  border: 1px solid var(--line);
}
.CodeMirror-gutters { background: var(--surface); border-inline-end: 1px solid var(--line); }
.CodeMirror-linenumber { color: var(--text-3); }
.CodeMirror-cursor { border-left-color: var(--accent); border-left-width: 2px; }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: var(--accent-soft) !important; }
.CodeMirror-matchingbracket { color: var(--accent) !important; text-decoration: underline; }
.cm-keyword, .cm-def { color: #9b3f8f; } .cm-string, .cm-string-2 { color: #237a45; }
.cm-number, .cm-atom { color: #a8530a; } .cm-comment { color: var(--text-3); font-style: italic; }
.cm-variable-2, .cm-builtin, .cm-property, .cm-meta { color: #2c63b8; }
:root[data-theme="dark"] .cm-keyword, :root[data-theme="dark"] .cm-def { color: #d496e4; }
:root[data-theme="dark"] .cm-string, :root[data-theme="dark"] .cm-string-2 { color: #8fd6a2; }
:root[data-theme="dark"] .cm-number, :root[data-theme="dark"] .cm-atom { color: #f4a66a; }
:root[data-theme="dark"] .cm-variable-2, :root[data-theme="dark"] .cm-builtin,
:root[data-theme="dark"] .cm-property, :root[data-theme="dark"] .cm-meta { color: #7fb0f2; }

/* charts (single series each, own axis) */
.chart { padding: 16px; position: relative; }
.chart + .chart { margin-top: 10px; }
.chart h3 { margin: 0; font-size: 15px; font-weight: 600; }
.chart .sub { font-size: 12.5px; color: var(--text-3); margin: 2px 0 10px; }
.chart svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; direction: ltr; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .limit { stroke: var(--text-3); stroke-width: 1; }
.chart .limit-label { fill: var(--text-2); font-size: 11px; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .barmark { fill: var(--accent); }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart details { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.chart summary { cursor: pointer; }
.chart table { border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.chart td, .chart th { padding: 2px 14px 2px 0; text-align: start; font-weight: 500; }
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--text); color: var(--surface); border-radius: 8px; padding: 5px 8px;
  font-size: 12px; white-space: nowrap; transform: translate(-50%, -100%); font-variant-numeric: tabular-nums;
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); z-index: 5;
  display: flex; align-items: center; gap: 8px;
  background: var(--text); color: var(--surface); border-radius: 12px; padding: 10px 14px; font-size: 14px;
  box-shadow: 0 8px 28px rgba(14, 15, 17, .22);
}
.toast.bad { background: var(--bad); color: #fff; }

/* loading skeleton, shaped like the list */
.skeleton { margin-top: 6px; }
.skeleton .block { background: var(--surface); border-radius: var(--r-surface); }
.skeleton .block + .block { margin-top: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton .block { animation: breathe 1.4s ease-in-out infinite; }
  .view-in { animation: rise .22s cubic-bezier(.16, 1, .3, 1); }
}
@keyframes breathe { 50% { opacity: .55; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
