/* CROC theme, ported from the C'ROC frontend (Croc-Frontend: analyst, admin, customer apps).
   Three themes on <html data-theme>: dark (default), light, warm. The choice is kept in
   localStorage under "croc-theme", the same key the C'ROC frontend uses. */

@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/montserrat.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono.ttf") format("truetype");
  font-weight: 100 800;
  font-display: swap;
}

/* ---- Light theme ---- */
:root {
  color-scheme: light;
  --bg-page: #f4f5f7;
  --bg-surface: #ffffff;
  --bg-surface-2: #f1f2f5;
  --bg-surface-3: #e9eaee;
  --border-default: #e3e5e9;
  --border-subtle: #ececf0;
  --text-primary: #12151c;
  --text-secondary: #5b6472;
  --text-muted: #98a1b0;

  --accent: #f9cf2d;
  --accent-12: rgba(249, 207, 45, 0.12);
  --accent-ink: #04121e;
  --danger: #e0324a;
  --danger-13: rgba(224, 50, 74, 0.1);
  --warning: #d5860a;
  --warning-13: rgba(213, 134, 10, 0.12);
  --warning-2: #e0692b;
  --warning-2-14: rgba(224, 105, 43, 0.14);
  --info: #2f6fe0;
  --info-13: rgba(47, 111, 224, 0.12);
  --success: #1f9d6c;
  --success-13: rgba(31, 157, 108, 0.13);

  --font-sans: "Montserrat", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

/* ---- Dark theme (default) ---- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #0a0a0a;
  --bg-surface: #121212;
  --bg-surface-2: #1a1a1a;
  --bg-surface-3: #202020;
  --border-default: #262626;
  --border-subtle: #171717;
  --text-primary: #e8eef6;
  --text-secondary: #93a1b3;
  --text-muted: #5d6b7d;

  --danger: #fb5a6b;
  --danger-13: rgba(251, 90, 107, 0.13);
  --warning: #f9a63a;
  --warning-13: rgba(249, 166, 58, 0.13);
  --warning-2: #fb923c;
  --warning-2-14: rgba(251, 146, 60, 0.14);
  --info: #5b9dff;
  --info-13: rgba(91, 157, 255, 0.13);
  --success: #34d399;
  --success-13: rgba(52, 211, 153, 0.13);
}

/* ---- Warm theme ---- */
[data-theme="warm"] {
  --bg-page: #fff6da;
  --bg-surface: #ffffff;
  --bg-surface-2: #fdf0c8;
  --bg-surface-3: #f9e6ab;
  --border-default: #eddca0;
  --border-subtle: #f5ecc9;
  --text-primary: #2b2010;
  --text-secondary: #6b5a30;
  --text-muted: #9c8b5c;

  --accent-12: rgba(249, 207, 45, 0.16);
  --danger: #c9273f;
  --danger-13: rgba(201, 39, 63, 0.1);
  --warning: #b06a06;
  --warning-13: rgba(176, 106, 6, 0.13);
  --warning-2: #c1571d;
  --warning-2-14: rgba(193, 87, 29, 0.14);
  --info: #1d5bc4;
  --info-13: rgba(29, 91, 196, 0.12);
  --success: #187a52;
  --success-13: rgba(24, 122, 82, 0.13);
}

/* ---- Base ---- */
* { box-sizing: border-box; border-color: var(--border-default); }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
}
a { color: inherit; }
::selection { background: var(--accent-12); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
* { scrollbar-width: thin; scrollbar-color: var(--border-default) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 8px; }
code, pre, .mono { font-family: var(--font-mono); }
code { font-size: 12px; color: var(--text-secondary); }
h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--text-primary); }
p { margin: 0 0 8px; }
.icon { flex-shrink: 0; display: block; }

/* ---- App shell: sidebar + header ---- */
.shell { display: flex; min-height: 100vh; width: 100%; }
.shell-main { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.content { min-width: 0; flex: 1; padding: 26px; }
.content > * + * { margin-top: 18px; }

.sidebar {
  position: sticky; top: 0;
  display: flex; flex-direction: column;
  width: 230px; height: 100vh; flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
}
.sidebar-logo {
  display: flex; align-items: center; justify-content: center;
  height: 80px; flex-shrink: 0; padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo img { height: 52px; width: 65px; object-fit: contain; }
.sidebar-nav { display: flex; flex: 1; flex-direction: column; gap: 3px; overflow-y: auto; padding: 14px 12px; }
.nav-section {
  margin: 0; padding: 6px 12px 4px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.8px; color: var(--text-muted);
}
.nav-section:not(:first-child) { margin-top: 10px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; color: var(--text-secondary); text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.nav-link.active { background: var(--accent-12); color: var(--text-primary); font-weight: 500; }
.nav-link span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-user { flex-shrink: 0; padding: 12px; border-top: 1px solid var(--border-subtle); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; background: var(--bg-surface-2);
}
.user-card.compact { padding: 6px 10px 6px 6px; border: 1px solid var(--border-default); }
.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px;
  background-image: linear-gradient(135deg, var(--accent) 0%, var(--info) 100%);
  color: var(--accent-ink); font-size: 13px; font-weight: 600; text-transform: uppercase;
}
.user-card.compact .avatar { width: 26px; height: 26px; border-radius: 7px; font-size: 11px; }
.user-meta { min-width: 0; flex: 1; }
.user-name { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.user-role { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--text-muted); }
.signout { flex-shrink: 0; color: var(--text-muted); transition: color 0.15s; }
.signout:hover { color: var(--text-primary); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 62px; flex-shrink: 0; padding: 0 26px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 {
  margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 16px; font-weight: 600; letter-spacing: -0.16px;
}
.topbar-title p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-muted); }
.topbar-brand { display: flex; flex-shrink: 0; align-items: center; gap: 10px; text-decoration: none; }
.topbar-brand img { height: 30px; width: 38px; object-fit: contain; }
.topbar-brand span { font-size: 14px; font-weight: 600; letter-spacing: -0.14px; }
.topbar-divider { width: 1px; height: 18px; flex-shrink: 0; background: var(--border-default); }

.theme-toggle {
  display: flex; flex-shrink: 0; align-items: center; gap: 2px;
  padding: 3px; border-radius: 9px;
  border: 1px solid var(--border-default); background: var(--bg-surface-2);
}
.theme-toggle button {
  display: flex; align-items: center; gap: 6px;
  padding: 4.8px 8.8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 12px; cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.theme-toggle button:hover { color: var(--text-primary); }
.theme-toggle button[aria-checked="true"] {
  background: var(--bg-surface); color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* ---- Page furniture ---- */
.page-intro { max-width: 820px; font-size: 12.5px; color: var(--text-secondary); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.count { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 19.8px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; }
.card > .card-header:last-child { padding-bottom: 0; }
.card-flush > .card-header {padding: 16px 20px 12px; border-bottom: 1px solid var(--border-default); }
.card-header h2 { margin: 0; }
.card-header p, .card-sub { margin: 2px 0 0; font-size: 11.5px; color: var(--text-muted); }
.card-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-top: 1px solid var(--border-default);
  font-size: 11.5px; color: var(--text-muted);
}
.card .card { background: var(--bg-surface-2); border-color: var(--border-subtle); margin: 12px 0; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 9px; padding: 17.8px; }
.kpi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12px; font-weight: 500; line-height: 15px; color: var(--text-secondary); }
.kpi-icon { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; }
.kpi-value { padding-top: 5px; font-size: 30px; font-weight: 600; line-height: 30px; letter-spacing: -0.6px; }
.kpi-hint { font-size: 11.5px; color: var(--text-muted); }

.hint { font-size: 11.5px; color: var(--text-muted); }
.hint-warn { color: var(--warning); }
.muted { color: var(--text-muted); }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 18px; border-radius: 12px; border: 1px solid;
  font-size: 12.5px;
}
.notice > div > :last-child { margin-bottom: 0; }
.notice .icon { margin-top: 1px; }
.notice-success { background: var(--success-13); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.notice-success .icon { color: var(--success); }
.notice-warning { background: var(--warning-13); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.notice-warning .icon { color: var(--warning); }

.stat-line { display: flex; flex-wrap: wrap; gap: 28px; }
.stat-line div { display: flex; flex-direction: column; gap: 2px; }
.stat-line strong { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; }
.stat-line span { font-size: 11.5px; color: var(--text-secondary); }

/* ---- Tables ---- */
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12.5px; }
.data-table th {
  padding: 13px 16px; border-bottom: 1px solid var(--border-default);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.525px; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
}
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); vertical-align: middle; }
.data-table td.primary, .data-table td.primary a { color: var(--text-primary); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--bg-surface-2); }
.data-table td.empty { padding: 40px 20px; text-align: center; font-size: 13px; color: var(--text-muted); }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .actions form { display: inline; }
.data-table .actions form + form { margin-left: 6px; }
.data-table tr.trace-row td { padding-top: 0; }
.data-table tr.trace-row:hover, .data-table tr.has-trace:hover { background: transparent; }
.data-table tr.has-trace td { border-bottom: 0; }
.row-inactive td { opacity: 0.5; }
.link { color: var(--text-primary); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); text-underline-offset: 4px; }
.link:hover { text-decoration-color: var(--accent); }
.link-accent { font-family: var(--font-mono); color: var(--accent); text-decoration: none; }
.link-accent:hover { text-decoration: underline; }

/* ---- Badges ---- */
.pill, .badge {
  display: inline-flex; flex-shrink: 0; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 6px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  background: var(--bg-surface-2); color: var(--text-secondary);
}
.badge-mono { font-family: var(--font-mono); }
.badge-danger, .sev-critical, .sev-high { background: var(--danger-13); color: var(--danger); }
.badge-warning, .sev-medium, .status-investigating { background: var(--warning-13); color: var(--warning); }
.badge-warning2, .pill-security { background: var(--warning-2-14); color: var(--warning-2); }
.badge-info, .sev-low, .pill-aml { background: var(--info-13); color: var(--info); }
.badge-accent { background: var(--accent-12); color: var(--accent); }
.badge-success, .status-closed, .status-active { background: var(--success-13); color: var(--success); }
.status-suspended { background: var(--danger-13); color: var(--danger); }
.sev-critical { font-weight: 600; }
/* Chains: neutral pill with a coloured dot. */
.pill-ethereum::before, .pill-bitcoin::before, .pill-optimism::before, .pill-base::before, .pill-bnb::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted);
}
.pill-ethereum::before { background: #7b8cf0; }
.pill-bitcoin::before { background: #f7931a; }
.pill-optimism::before { background: #ff0420; }
.pill-base::before { background: #0052ff; }
.pill-bnb::before { background: #f0b90b; }
.pill-ethereum, .pill-bitcoin, .pill-optimism, .pill-base, .pill-bnb { text-transform: capitalize; }

/* ---- Buttons ---- */
.btn, .btn-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-default); background: var(--bg-surface-2); color: var(--text-primary);
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s, background-color 0.15s, filter 0.15s;
}
.btn { border-color: var(--accent); background: var(--accent); color: #171300; }
.btn:hover { filter: brightness(1.08); }
.btn-sm { min-height: 30px; padding: 5px 11px; font-size: 11.5px; }
.btn-sm:hover { border-color: var(--text-muted); }
.btn-danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-13); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn:disabled, .btn-sm:disabled, fieldset:disabled .btn, fieldset:disabled .btn-sm { cursor: not-allowed; opacity: 0.45; filter: none; }

.pager { display: flex; align-items: center; gap: 8px; }

/* ---- Forms ---- */
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
label {
  display: block; margin: 0 0 14px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--text-muted);
}
label br { display: none; }
input[type=text], input[type=email], input[type=number], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border-default); background: var(--bg-surface-2); color: var(--text-primary);
  font: inherit; font-size: 12.5px; font-weight: 400; letter-spacing: normal; text-transform: none;
  transition: border-color 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { font-family: var(--font-mono); font-size: 12px; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%2398a1b0' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > label { flex: 1; min-width: 160px; }
.row > .checkbox { flex: 0 0 auto; align-self: flex-end; min-width: 0; padding-bottom: 10px; }
.checkbox {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 500; letter-spacing: normal; text-transform: none; color: var(--text-primary);
}
.checkbox input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filter-bar label { margin: 0; min-width: 180px; }
.filter-bar label.grow { flex: 1; min-width: 240px; }
.filter-bar .count { padding-bottom: 10px; }
.cond-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.cond-row input, .cond-row select { margin-top: 0; }
.cond-row input { flex: 2; }
.cond-row select { flex: 1; }

details { margin: 14px 0; }
summary { cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text-secondary); }
summary:hover { color: var(--text-primary); }
details[open] > summary { margin-bottom: 8px; }
.trace { margin: 0; }
.trace summary { font-size: 11.5px; color: var(--text-muted); }

.test-result {
  margin: 10px 0 0; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border-default); background: var(--bg-page); color: var(--text-secondary);
  font-size: 11.5px; line-height: 1.6; overflow-x: auto;
}
.test-result:empty { display: none; }

/* ---- Public homepage (signed out): C'ROC login layout ---- */
.home { display: grid; grid-template-columns: 1.05fr 0.95fr; min-height: 100vh; }
/* The brand column stays on the dark hero treatment in every theme, as in C'ROC. */
.home-hero {
  display: flex; flex-direction: column; justify-content: space-between; gap: 64px;
  padding: 48px 56px; overflow: hidden;
  background-image: linear-gradient(165.6deg, rgb(10, 22, 34) 0%, rgb(10, 15, 24) 60%);
  border-right: 1px solid rgba(0, 0, 0, 0.4);
  color: #f2f7fc;
}
.home-hero-logo { width: 90px; height: 72px; object-fit: contain; }
.home-hero-copy { display: flex; max-width: 460px; flex-direction: column; gap: 16px; }
.home-pill {
  display: inline-flex; width: fit-content; align-items: center; gap: 8px;
  padding: 4.8px 10.8px; border-radius: 20px;
  border: 1px solid rgba(52, 211, 153, 0.25); background: rgba(52, 211, 153, 0.12);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.44px; text-transform: uppercase; color: #34d399;
}
.home-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; }
.home-hero h1 { margin: 0; font-size: 38px; font-weight: 600; line-height: 1.12; letter-spacing: -0.76px; color: #f2f7fc; }
.home-hero p { margin: 0; font-size: 15px; line-height: 24px; color: #93a4b8; }
.home-chains { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.home-chains .pill { background: rgba(255, 255, 255, 0.06); color: #c4cfdc; }
.home-facts { display: flex; flex-wrap: wrap; gap: 34px; }
.home-facts div { display: flex; flex-direction: column; gap: 2px; }
.home-facts strong { font-size: 22px; font-weight: 600; color: #eef4fb; }
.home-facts span { font-size: 12px; color: #6c7d92; }

.home-signin { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--bg-page); }
.home-signin-inner { width: 100%; max-width: 360px; }
.home-signin-logo { display: none; width: 55px; height: 44px; margin-bottom: 24px; object-fit: contain; }
.home-signin h2 { margin: 0; font-size: 26px; line-height: 1; letter-spacing: -0.26px; }
.home-sub { margin: 11px 0 0; font-size: 14px; color: var(--text-secondary); }
.home-btn { display: flex; width: 100%; margin-top: 28px; padding: 13px; border-radius: 10px; font-size: 14.5px; letter-spacing: 0.145px; }
.home-note { margin: 14px 0 0; font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.home-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted);
}

@media (max-width: 1000px) {
  .home { grid-template-columns: 1fr; }
  .home-hero { display: none; }
  .home-signin { padding: 32px 16px; }
  .home-signin-logo { display: block; }
}

/* ---- Small screens: sidebar becomes a top strip ---- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--border-default); }
  .sidebar-logo { height: 60px; padding: 10px; }
  .sidebar-logo img { height: 40px; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .nav-section { display: none; }
  .nav-link { padding: 7px 10px; font-size: 12.5px; }
  .topbar { position: static; padding: 0 16px; }
  .content { padding: 16px; }
  .theme-toggle .label-text { display: none; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .theme-toggle .label-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
