:root {
  --ink: #1d2433;
  --ink-2: #4a5468;
  --ink-3: #7a8396;
  --paper: #f5f7fa;
  --surface: #ffffff;
  --line: #d8dde6;
  --line-soft: #e8ecf2;
  --accent: #0e7a7e;
  --accent-ink: #0a5c5f;
  --accent-wash: #e3f2f2;
  --live: #be123c;
  --live-wash: #fde7ec;
  --sim: #4f46e5;
  --sim-wash: #ecebfd;
  --warn: #a15c07;
  --warn-wash: #fdf1df;
  --ok: #19744a;
  --ok-wash: #e2f3ea;
  --radius: 6px;
  --radius-lg: 10px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  font-feature-settings: "tnum" 1;
}
a { color: var(--accent-ink); }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink);
  color: #c9d0dc;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: block; color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; padding: 0 10px 18px; }
.brand small { display: block; font-weight: 400; color: #8f9ab0; font-size: .8rem; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; color: #8f9ab0; font-size: .8rem; }
.sidebar a.nav {
  display: block; padding: 6px 10px; border-radius: var(--radius);
  color: #dfe4ec; text-decoration: none;
}
.sidebar a.nav:hover { background: rgba(255,255,255,.07); }
.sidebar a.nav.active { background: rgba(14,122,126,.35); color: #fff; }
.sidebar .count { float: right; background: var(--live); color: #fff; border-radius: 99px; padding: 0 7px; font-size: .75rem; }

.main { min-width: 0; }
.mode-strip {
  display: flex; align-items: center; gap: 14px; padding: 8px 28px;
  font-size: .87rem; color: #fff;
}
.mode-strip.sim {
  background: repeating-linear-gradient(-45deg, var(--sim), var(--sim) 12px, #5b53ea 12px, #5b53ea 24px);
}
.mode-strip.live { background: var(--live); }
.mode-strip strong { font-size: .95rem; }
.mode-strip .spacer { flex: 1; }
.mode-strip form { margin: 0; }
.mode-strip button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; }

.content { padding: 24px 28px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 70ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 18px; }
.panel > h2 { font-size: 1.1rem; margin: 0 0 4px; }
.panel > .hint { color: var(--ink-2); margin: 0 0 14px; font-size: .92rem; max-width: 78ch; }
.panel.flat { padding: 0; overflow: hidden; }
.panel.flat > h2, .panel.flat > .hint { padding: 16px 20px 0; }

.grid { display: grid; gap: 14px 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }

/* Forms */
label.f { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.help { color: var(--ink-3); font-size: .83rem; margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date],
input[type=datetime-local], input[type=time], input[type=file], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; background: #fff;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-wash); border-color: var(--accent); }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.error { color: var(--live); font-size: .85rem; margin-top: 3px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: .92rem;
  padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--live); border-color: #f3b8c6; }
.btn.live { background: var(--live); border-color: var(--live); color: #fff; }
.btn.small { padding: 3px 9px; font-size: .84rem; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; margin: 0; }

/* Tables */
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; }
table.t .muted { color: var(--ink-3); }
.table-wrap { overflow-x: auto; }

/* Repeater rows */
.rep { width: 100%; border-collapse: collapse; }
.rep td { padding: 4px 6px 4px 0; vertical-align: top; }
.rep th { text-align: left; font-size: .84rem; font-weight: 600; color: var(--ink-2); padding: 0 6px 4px 0; }
.rep td.x { width: 1%; }
.rep-add { margin-top: 6px; }

/* Status */
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--line-soft); color: var(--ink-2); }
.tag.ok, .tag.active, .tag.approved, .tag.qualified, .tag.sent, .tag.delivered, .tag.read, .tag.running, .tag.available, .tag.completed, .tag.verified { background: var(--ok-wash); color: var(--ok); }
.tag.warn, .tag.pending, .tag.pending_approval, .tag.draft, .tag.coming_soon, .tag.paused, .tag.unverified, .tag.created_paused { background: var(--warn-wash); color: var(--warn); }
.tag.bad, .tag.rejected, .tag.blocked, .tag.failed, .tag.disqualified, .tag.escalated, .tag.unavailable, .tag.opted_out, .tag.error, .tag.archived { background: var(--live-wash); color: var(--live); }
.tag.simulated, .tag.sandbox { background: var(--sim-wash); color: var(--sim); }
.tag.production, .tag.live { background: var(--live); color: #fff; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--ok-wash); border-color: #b9e0cb; color: var(--ok); }
.flash.bad { background: var(--live-wash); border-color: #f3b8c6; color: var(--live); }

.checks { list-style: none; padding: 0; margin: 0; }
.checks li { padding: 6px 0 6px 28px; position: relative; border-bottom: 1px solid var(--line-soft); }
.checks li:last-child { border-bottom: 0; }
.checks li::before { position: absolute; left: 4px; top: 6px; font-weight: 700; }
.checks li.pass::before { content: "✓"; color: var(--ok); }
.checks li.fail::before { content: "✕"; color: var(--live); }
.checks li.warn::before { content: "!"; color: var(--warn); left: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 14px; }
.stat b { display: block; font-size: 1.45rem; line-height: 1.2; }
.stat span { color: var(--ink-2); font-size: .87rem; }

/* Wizard */
.wizard { display: grid; grid-template-columns: 210px 1fr; gap: 22px; align-items: start; }
.steps { list-style: none; margin: 0; padding: 0; position: sticky; top: 16px; counter-reset: step; }
.steps li a {
  display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: var(--radius);
  text-decoration: none; color: var(--ink-2);
}
.steps li a::before {
  counter-increment: step; content: counter(step);
  width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); font-size: .8rem; font-weight: 700; background: #fff;
}
.steps li.done a::before { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }
.steps li.current a { background: var(--surface); color: var(--ink); font-weight: 700; border: 1px solid var(--line); }
.steps li.current a::before { background: var(--accent); color: #fff; border-color: var(--accent); }

.bubble { max-width: 70%; padding: 9px 12px; border-radius: 12px; margin: 6px 0; white-space: pre-wrap; }
.bubble.in { background: #fff; border: 1px solid var(--line); }
.bubble.out { background: var(--accent-wash); margin-left: auto; }
.bubble.sys { background: var(--warn-wash); margin: 6px auto; font-size: .87rem; }
.bubble small { display: block; color: var(--ink-3); font-size: .78rem; margin-top: 4px; }

.pre { white-space: pre-wrap; }
.mono-ish { font-feature-settings: "tnum" 1; letter-spacing: .01em; }
.muted { color: var(--ink-3); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters > div { min-width: 160px; }
.pagination { display: flex; gap: 6px; padding: 12px 20px; }
.empty { padding: 28px 20px; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

.login { max-width: 380px; margin: 12vh auto; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: flex; align-items: center; gap: 2px; overflow-x: auto; white-space: nowrap; padding: 8px 10px; }
  .sidebar .brand { padding: 0 10px 0 4px; }
  .sidebar .brand small, .sidebar .nav-group { display: none; }
  .sidebar a.nav, .sidebar form button.nav { display: inline-block !important; }
  .wizard { grid-template-columns: 1fr; }
  .steps { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 48px; }
  .mode-strip { padding: 8px 16px; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
