/* =====================================================================
   CronRunner v2 - design system
   Same shape as the Magnus Carrier Registry UI: no framework, no build
   step, one stylesheet. Tokens are shared with the registry so the two
   staff tools look like one family.
   ===================================================================== */

:root {
    --navy-900: #071324;
    --navy-800: #0b1c33;
    --navy-700: #12294a;
    --navy-600: #1b3a63;
    --brand-green: #386a52;      /* the Magnus mark, as shipped (decision 8) */
    --brand-green-2: #4f9c78;

    --blue-600: #1d4ed8;
    --blue-500: #2563eb;
    --blue-50:  #eff6ff;

    --ink-900: #101828;
    --ink-700: #344054;
    --ink-600: #475467;
    --ink-500: #595959;
    --line:    #e4e7ec;
    --line-2:  #f2f4f7;
    --surface: #ffffff;
    --canvas:  #f6f8fb;

    --ok-600:   #067647;
    --ok-50:    #ecfdf3;
    --warn-700: #b54708;
    --warn-50:  #fffaeb;
    --err-700:  #b42318;
    --err-50:   #fef3f2;
    --info-700: #175cd3;
    --info-50:  #eff8ff;
    --muted-50: #f2f4f7;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
    --shadow-lg: 0 12px 16px -4px rgba(16,24,40,.12), 0 4px 6px -2px rgba(16,24,40,.05);

    --fs-base: 14px;
    --sidebar-w: 232px;
    --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--canvas); color: var(--ink-900);
    font: var(--fs-base)/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--ink-600); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--navy-900); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar__mark { width: 34px; height: 32px; color: #fff; flex: none; }
.sidebar__brandText { line-height: 1.15; }
.sidebar__brandText b { display: block; font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.sidebar__brandText span { font-size: 11px; color: #94a3b8; letter-spacing: .6px; text-transform: uppercase; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav__item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; color: #cbd5e1;
    padding: 9px 10px; border-radius: 7px; font: inherit; font-size: 13.5px; cursor: pointer; }
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav__item.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav__item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav__sep { font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase; color: #64748b; padding: 12px 10px 4px; }
.nav__tag { margin-left: auto; font-size: 10px; background: rgba(255,255,255,.14); padding: 1px 6px; border-radius: 10px; }
.sidebar__foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #94a3b8; }
.sidebar__foot b { color: #e2e8f0; display: block; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 20px; position: sticky; top: 0; z-index: 5; }
.topbar__search { flex: 1; max-width: 520px; position: relative; }
.topbar__search input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--canvas); }
.topbar__search svg { position: absolute; left: 11px; top: 10px; width: 15px; height: 15px; color: var(--ink-600); }
.topbar__spacer { flex: 1; }
.mode { font-size: 11.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; padding: 3px 9px; border-radius: 12px; }
.mode--live { background: var(--ok-50); color: var(--ok-600); }
.mode--shadow { background: var(--info-50); color: var(--info-700); }
.mode--inert { background: var(--warn-50); color: var(--warn-700); }
.user { display: flex; align-items: center; gap: 10px; }
.user__avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-700); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.user__name { font-weight: 600; line-height: 1.1; font-size: 13px; }
.user__role { font-size: 11.5px; color: var(--ink-600); text-transform: capitalize; }

.page { padding: 20px 24px 40px; }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page__head h1 { margin: 0; font-size: 20px; font-weight: 700; }
.page__head p { margin: 2px 0 0; color: var(--ink-600); font-size: 13px; }
.page__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ cards, grid */
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1400px) { .grid--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid--4, .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card__head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card__head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card__body { padding: 14px 16px; }
.card__body--flush { padding: 0; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__label { font-size: 12px; color: var(--ink-600); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat__value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat__foot { font-size: 12px; color: var(--ink-600); }
.stat--err .stat__value { color: var(--err-700); }
.stat--warn .stat__value { color: var(--warn-700); }
.stat--ok .stat__value { color: var(--ok-600); }

/* ------------------------------------------------------------ tables */
.tablewrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-600); font-weight: 600;
    padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f8fafc; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .sub { display: block; font-size: 12px; color: var(--ink-600); }
.tbl input[type=checkbox] { margin: 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-600); }
.empty h4 { margin: 0 0 6px; color: var(--ink-900); font-size: 14px; }

/* ------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 12px; white-space: nowrap; }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { background: var(--ok-50); color: var(--ok-600); }
.badge--warn { background: var(--warn-50); color: var(--warn-700); }
.badge--err { background: var(--err-50); color: var(--err-700); }
.badge--info { background: var(--info-50); color: var(--info-700); }
.badge--muted { background: var(--muted-50); color: var(--ink-600); }
.badge--critical { background: var(--err-700); color: #fff; }

/* ------------------------------------------------------------ timestamps (decision 3d) */
.dt { display: inline-flex; gap: 8px; align-items: baseline; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dt__utc { font-weight: 500; }
.dt__local { color: var(--ink-600); font-size: 12px; }

/* ------------------------------------------------------------ buttons, forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-900);
    padding: 7px 12px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; line-height: 1.2; }
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn--primary:hover { background: var(--blue-500); }
.btn--danger { color: var(--err-700); border-color: #fecdca; }
.btn--danger:hover { background: var(--err-50); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--sm { padding: 4px 9px; font-size: 12px; }
.btn--block { width: 100%; justify-content: center; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-700); }
.field input, .field select, .field textarea { font: inherit; font-size: 13.5px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
.field textarea { min-height: 96px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.field .help { font-size: 12px; color: var(--ink-600); }
.field .err { font-size: 12px; color: var(--err-700); }
.field--inline { flex-direction: row; align-items: center; gap: 8px; }
.field--inline input[type=checkbox] { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span2 { grid-column: span 2; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin: 0; min-width: 150px; }
.filters .field input, .filters .field select { padding: 6px 9px; font-size: 13px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-600); cursor: pointer; }
.tab.active { color: var(--blue-600); border-bottom-color: var(--blue-600); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-600); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-600); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
pre.box { background: #0b1c33; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; max-height: 380px; font-size: 12px; margin: 0; white-space: pre-wrap; word-break: break-word; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; border: 1px solid transparent; }
.alert--err { background: var(--err-50); color: var(--err-700); border-color: #fecdca; }
.alert--warn { background: var(--warn-50); color: var(--warn-700); border-color: #fedf89; }
.alert--info { background: var(--info-50); color: var(--info-700); border-color: #b2ddff; }
.menu { position: relative; display: inline-block; }
.menu__list { position: absolute; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); min-width: 170px; padding: 4px; display: none; }
.menu.open .menu__list { display: block; }
.menu__item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer; }
.menu__item:hover { background: #f2f4f7; }
.menu__item--danger { color: var(--err-700); }

/* ------------------------------------------------------------ drawer, modal, toast */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 92vw); background: #fff; box-shadow: var(--shadow-lg); z-index: 40;
    transform: translateX(100%); transition: transform .18s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer__head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer__body { padding: 16px 18px; overflow: auto; flex: 1; }
.scrim { position: fixed; inset: 0; background: rgba(16,24,40,.35); z-index: 30; display: none; }
.scrim.open { display: block; }
.modal { position: fixed; inset: 0; display: none; place-items: center; z-index: 50; }
.modal.open { display: grid; }
.modal__box { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: min(520px, 92vw); padding: 18px; }
.modal__box h3 { margin: 0 0 8px; font-size: 15px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--navy-800); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); max-width: 420px; }
.toast--err { background: var(--err-700); }
.toast--ok { background: var(--ok-600); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.12); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ charts */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.bars__ok { background: var(--brand-green-2); border-radius: 2px 2px 0 0; }
.bars__err { background: var(--err-700); }
.bars__axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-600); margin-top: 4px; }
.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.health__chip { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.health__name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .form-grid { grid-template-columns: 1fr; }
}
