/* =========================================================================
   CM1 — BM2 dark theme tokens (shared by admin and client UIs)
   ========================================================================= */

:root {
  --bg:            #0b0f14;
  --surface:       #141b22;
  --surface-2:     #1c2530;
  --surface-3:     #232f3d;
  --border:        #1f2a36;
  --border-strong: #2c3a4a;

  --text:       #e6edf3;
  --text-muted: #8b949e;
  --text-dim:   #6b7785;

  --primary:        #58a6ff;
  --primary-hover:  #79b8ff;
  --primary-fg:     #0b0f14;

  --accent:  #a78bfa;
  --success: #3fb950;
  --warning: #d29922;
  --danger:  #f85149;
  --info:    #58a6ff;

  --radius:    8px;
  --radius-sm: 4px;
  --shadow:    0 6px 20px rgba(0,0,0,0.35);

  --nav-w: 232px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* =========================================================================
   Base
   ========================================================================= */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover { color: var(--primary-hover); text-decoration: underline; }

code, pre, .mono { font-family: var(--font-mono); }

h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* =========================================================================
   Shell — topbar + sidebar + main
   ========================================================================= */

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "brand topbar"
    "nav   main";
  min-height: 100vh;
}

.shell-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 15px;
}
.shell-brand .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 8px;
  box-shadow: 0 0 12px var(--primary);
}

.shell-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.shell-topbar .crumbs { color: var(--text-muted); font-size: 13px; }
.shell-topbar .user {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-muted); font-size: 13px;
}
.shell-topbar .user .badge { background: var(--surface-3); padding: 2px 8px; border-radius: 12px; font-size: 11px; }

.shell-nav {
  grid-area: nav;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 8px;
}
.shell-nav .nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 12px 12px 6px;
}
.shell-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
}
.shell-nav a:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.shell-nav a.active {
  background: var(--surface-3);
  color: var(--primary);
  font-weight: 600;
}
.shell-nav a .ico {
  width: 16px; height: 16px;
  display: inline-block;
  text-align: center;
  opacity: 0.7;
}

.shell-main {
  grid-area: main;
  padding: 24px 32px 64px;
  max-width: 1400px;
}

/* =========================================================================
   Cards / panels
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card .card-h {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card .card-h h2 { margin: 0; }

.grid {
  display: grid;
  gap: 16px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.stat .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-family: var(--font-mono); }
.stat .delta { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* =========================================================================
   Tables
   ========================================================================= */

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.table th, table.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-2);
  position: sticky; top: 0;
}
table.table tr:hover td { background: rgba(255,255,255,0.02); }
table.table td.num, table.table th.num { text-align: right; font-family: var(--font-mono); }
table.table td.actions { white-space: nowrap; text-align: right; }
table.table td .sub { color: var(--text-dim); font-size: 12px; display: block; }

/* =========================================================================
   Pills / status
   ========================================================================= */

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-muted);
}
.pill.success { background: rgba(63,185,80,0.15); color: var(--success); }
.pill.warning { background: rgba(210,153,34,0.15); color: var(--warning); }
.pill.danger  { background: rgba(248,81,73,0.15); color: var(--danger); }
.pill.info    { background: rgba(88,166,255,0.15); color: var(--info); }
.pill.accent  { background: rgba(167,139,250,0.15); color: var(--accent); }

/* =========================================================================
   Forms / buttons
   ========================================================================= */

label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=search], textarea, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.18);
}
textarea { resize: vertical; min-height: 80px; font-family: var(--font-mono); font-size: 12.5px; }

.field { margin-bottom: 14px; }
.field .hint { color: var(--text-dim); font-size: 11.5px; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(248,81,73,0.3); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* =========================================================================
   Alert / banner
   ========================================================================= */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  background: var(--surface-2);
  border-left: 3px solid var(--info);
  color: var(--text);
  font-size: 13px;
}
.alert.danger  { border-left-color: var(--danger); background: rgba(248,81,73,0.08); }
.alert.success { border-left-color: var(--success); background: rgba(63,185,80,0.08); }
.alert.warning { border-left-color: var(--warning); background: rgba(210,153,34,0.08); }

/* =========================================================================
   Auth shell — login / reset pages
   ========================================================================= */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-card .brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; letter-spacing: 0.06em;
  margin-bottom: 24px;
}
.auth-card .brand .dot { width: 10px; height: 10px; background: var(--primary); border-radius: 50%; box-shadow: 0 0 12px var(--primary); }
.auth-card .foot { color: var(--text-dim); font-size: 12px; margin-top: 20px; text-align: center; }

/* =========================================================================
   Misc
   ========================================================================= */

.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap-16 { gap: 16px; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.run-progress {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.run-progress .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0;
  transition: width 300ms ease;
}
.run-progress.indeterminate .bar {
  width: 30%;
  animation: cm1-indeterminate 1.6s ease-in-out infinite;
}
@keyframes cm1-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(380%); }
}
