/* Sheliak Ops Console. One stylesheet, no scripts (the CSP allows neither inline styles nor scripts). */
:root {
  --bg: #f4f5f8;
  --card: #fff;
  --text: #14161b;
  --muted: #5d6676;
  --faint: #8a93a3;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --head: #f8f9fb;
  --primary: #3a3fd1;
  --primary-hover: #2f33b4;
  --primary-soft: #eceefe;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --warning: #96650a;
  --warning-soft: #fff3d6;
  --ok: #1b7f3b;
  --ok-soft: #e5f4ea;
  --neutral-soft: #eef0f3;
  --side: #10142b;
  --side-text: #c4c9e0;
  --side-muted: #7d84a6;
  --side-active: #262c57;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 20, 43, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shell: sidebar, top bar, content ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { flex: 0 0 240px; background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; text-decoration: none; }
.sidebar .brand { flex-direction: column; align-items: flex-start; gap: 6px; }
.sidebar .brand img { height: 22px; width: auto; filter: brightness(0) invert(1); }
.sidebar .brand .product { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); white-space: nowrap; }
.sidebar nav { display: flex; flex-direction: column; gap: 18px; }
.sidebar .group { display: flex; flex-direction: column; gap: 2px; }
.sidebar .group-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--side-muted); padding: 0 10px 4px; }
.sidebar nav a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--side-text); font-weight: 500; text-decoration: none; }
.sidebar nav a:hover { background: #1b2044; color: #fff; }
.sidebar nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #7b80ff; }
.nav-toggle, .nav-toggle-label { display: none; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.prefs { display: inline-flex; gap: 6px; margin: 0; }
.user { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-name { font-weight: 600; }
.user-roles { font-size: 12px; color: var(--muted); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-badge { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--warning); background: var(--warning-soft); border: 1px solid #f1dca6; border-radius: 999px; padding: 2px 9px; }
.content { padding: 28px; width: 100%; max-width: 1360px; }
.pause-banner { background: var(--danger); color: #fff; padding: 10px 28px; font-weight: 600; }
.pause-banner a { color: #fff; text-decoration: underline; }

/* ---------- sign-in pages ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(1200px 500px at 50% -10%, #e4e6ff 0%, var(--bg) 60%); }
.auth-top { display: flex; justify-content: flex-end; padding: 16px 24px; }
.auth-box { width: 100%; max-width: 420px; margin: 6vh auto 40px; padding: 0 16px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; }
.auth-brand img { height: 30px; width: auto; }
.auth-brand .product { font-weight: 600; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line-strong); }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(16, 20, 43, .08); }
.auth-card h1 { font-size: 20px; margin: 0 0 18px; }
.auth-card .card { border: 0; padding: 0; box-shadow: none; max-width: none; }
.auth-card button:not(.link) { width: 100%; height: 40px; }
.auth-who { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 16px; font-size: 13px; }

/* ---------- type ---------- */
h1 { font-size: 22px; line-height: 1.3; font-weight: 650; margin: 0 0 20px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; margin: 28px 0 10px; }
h3 { font-size: 14px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
code { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--neutral-soft); border-radius: 4px; padding: 1px 4px; }
.wrap { word-break: break-all; white-space: pre-wrap; }
.secret { font-size: 15px; letter-spacing: 1px; }
.error { color: var(--danger); font-weight: 600; background: var(--danger-soft); border: 1px solid #f5c6c2; border-radius: 8px; padding: 10px 14px; }
.notice, .warning { color: var(--warning); }
.ok { color: var(--ok); } .bad { color: var(--danger); font-weight: 700; }

/* ---------- cards and tiles ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.narrow { max-width: 460px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 8px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; box-shadow: var(--shadow); overflow: hidden; }
.tile:hover { border-color: var(--line-strong); text-decoration: none; box-shadow: 0 4px 12px rgba(16, 20, 43, .07); }
.tile > span:first-child { font-size: 12px; font-weight: 600; color: var(--muted); }
.tile strong { font-size: 28px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.tile.warn::before { background: #e3a008; } .tile.crit::before { background: var(--danger); }
.tile.warn, .tile.crit { border-color: var(--line); }

/* ---------- the home page's order states ---------- */
.state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.state-grid a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
.state-grid a:hover { border-color: var(--line-strong); text-decoration: none; }
.state-grid strong { font-variant-numeric: tabular-nums; }
.heartbeats { margin-top: 10px; }

/* ---------- detail panels (an order's fields in sections) ---------- */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.panel { padding: 0; gap: 0; overflow: hidden; }
.panel h3 { margin: 0; padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--line); background: var(--head); }
.panel table { border: 0; border-radius: 0; box-shadow: none; }
.panel table.fields th { width: 42%; background: none; }
h1 code { font-size: 14px; vertical-align: middle; }
h1 .state { vertical-align: middle; }

/* ---------- tables ---------- */
table { border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.list, table.fields { width: 100%; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child > td, tr:last-child > th { border-bottom: 0; }
thead th, table.list tr:first-child > th { background: var(--head); font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
table.list tbody tr:hover > td, table.list tr:hover > td { background: #fafbff; }
table.fields th { width: 220px; color: var(--muted); font-weight: 500; background: var(--head); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
td a { font-weight: 500; }

/* ---------- forms and buttons ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; height: 36px; }
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(58, 63, 209, .15); }
input[type=checkbox], input[type=radio] { height: auto; padding: 0; accent-color: var(--primary); }
button { font: inherit; font-weight: 600; height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; white-space: nowrap; }
button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(58, 63, 209, .35); outline-offset: 2px; }
button.secondary { background: #fff; color: var(--text); border-color: var(--line-strong); }
button.secondary:hover { background: var(--head); }
button.small { height: 30px; padding: 0 12px; font-size: 13px; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #a91f1f; border-color: #a91f1f; }
button.link { background: none; border: none; color: var(--primary); padding: 0; height: auto; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button.chip { height: 28px; padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; }
button.chip:hover { color: var(--text); background: var(--head); }
form.inline { display: inline-flex; gap: 10px; margin: 0; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 18px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters .wide { flex: 1 1 100%; }
.reveal { flex-direction: row; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
fieldset.roles { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px 12px; margin: 0; }
fieldset.roles legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
label.check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 14px; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.actions .card { min-width: 280px; flex: 1 1 280px; }
.danger-zone { border-color: #f1b8b3; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- status pills ---------- */
.state, .level { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em; line-height: 18px; padding: 0 8px; border-radius: 999px; background: var(--neutral-soft); color: var(--muted); white-space: nowrap; }
.state.REVIEW, .state.EXPIRED { background: var(--danger-soft); color: var(--danger); }
.state.PAID { background: var(--ok-soft); color: var(--ok); }
.state.PAYING, .state.FUNDING, .state.FUNDED { background: var(--warning-soft); color: var(--warning); }
.state.QUOTED { background: var(--primary-soft); color: var(--primary); }
.state.pending { background: var(--warning-soft); color: var(--warning); } .state.executed, .state.approved { background: var(--ok-soft); color: var(--ok); }
.state.rejected, .state.failed, .state.cancelled, .state.expired, .state.REFUNDED, .state.CLOSED { background: var(--neutral-soft); color: var(--muted); }
.level.critical { background: var(--danger-soft); color: var(--danger); } .level.warning { background: var(--warning-soft); color: var(--warning); } .level.info { background: var(--primary-soft); color: var(--primary); }

/* ---------- charts ---------- */
svg.spark { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); max-width: 100%; height: auto; }
svg.spark .line { fill: none; stroke: var(--primary); stroke-width: 2; }
svg.spark .reload { stroke: var(--warning); stroke-dasharray: 4 4; }

/* ---------- narrow screens: the sidebar becomes a top bar with a menu ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; height: auto; flex: none; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; }
  .sidebar .brand { padding: 4px 0; }
  .nav-toggle-label { display: inline-flex; margin-left: auto; padding: 6px 12px; border: 1px solid #2c3258; border-radius: 8px; color: #fff; font-weight: 600; cursor: pointer; }
  .sidebar nav { display: none; flex-basis: 100%; padding: 12px 0 6px; }
  .nav-toggle:checked ~ nav { display: flex; }
  .topbar { padding: 0 16px; position: static; }
  .user-text { display: none; }
  .user { padding-left: 0; border-left: 0; }
  .content { padding: 18px 16px; }
  table.list { display: block; overflow-x: auto; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile strong { font-size: 24px; }
  .panels { grid-template-columns: 1fr; }
  table.fields th { width: auto; }
}
