:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --surface-deep: #eaf0ed;
  --ink: #17332b;
  --ink-2: #2d4a42;
  --muted: #6f827c;
  --line: #dce5e1;
  --brand: #1d6e55;
  --brand-strong: #14513f;
  --brand-soft: #dceee8;
  --nav: #0f3027;
  --nav-2: #143b30;
  --gold: #bd8f3f;
  --gold-soft: #f4ead8;
  --blue: #557e9d;
  --blue-soft: #e3edf4;
  --red: #b55353;
  --red-soft: #f6e5e5;
  --amber: #c47e2d;
  --amber-soft: #f8ecd9;
  --shadow: 0 12px 34px rgba(18, 53, 43, .08);
  --shadow-sm: 0 5px 18px rgba(18, 53, 43, .07);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
.hidden { display: none !important; }

/* Shared */
.brand-lockup { display: inline-flex; align-items: center; gap: 12px; }
.brand-lockup > span:last-child, .sidebar-brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-lockup b, .sidebar-brand b { font-size: 20px; letter-spacing: -.02em; }
.brand-lockup small, .sidebar-brand small { margin-top: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .14em; opacity: .72; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: inline-grid; place-items: center;
  font-weight: 800; font-size: 21px; letter-spacing: -.05em; color: #fff;
  background: linear-gradient(145deg, #2b8a69, #165640);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 8px 20px rgba(0,0,0,.15);
}
.section-kicker, .topbar-kicker, .eyebrow {
  display: block; font-size: 10px; font-weight: 800; letter-spacing: .17em; color: var(--brand); text-transform: uppercase;
}
.btn {
  min-height: 42px; border: 0; border-radius: 11px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; font-weight: 750; transition: .18s ease; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .58; cursor: wait; transform: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 7px 18px rgba(29,110,85,.22); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--brand-soft); color: var(--brand-strong); }
.btn-secondary:hover { background: #cee5dd; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-block { width: 100%; }
.icon-button {
  width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 11px;
  display: inline-grid; place-items: center; padding: 0; transition: .18s ease;
}
.icon-button:hover { border-color: #b9c9c3; background: var(--surface-soft); }
svg.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aaba5; box-shadow: 0 0 0 4px rgba(154,171,165,.13); }
.status-dot.ok { background: #39a879; box-shadow: 0 0 0 4px rgba(57,168,121,.13); }
.status-dot.bad { background: #d15d5d; box-shadow: 0 0 0 4px rgba(209,93,93,.13); }
.status-dot.warn { background: #d79a47; box-shadow: 0 0 0 4px rgba(215,154,71,.13); }

/* Login */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(440px, .85fr); background: #eef3f0; }
.login-visual {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(circle at 72% 25%, rgba(194,161,89,.25), transparent 24%),
    radial-gradient(circle at 18% 70%, rgba(54,136,104,.28), transparent 28%),
    linear-gradient(145deg, #102f27 0%, #164534 55%, #285f46 100%);
}
.login-visual::before, .login-visual::after {
  content: ""; position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%;
}
.login-visual::before { width: 520px; height: 520px; right: -180px; top: -100px; }
.login-visual::after { width: 720px; height: 720px; left: -420px; bottom: -390px; }
.field-lines { position: absolute; inset: 0; opacity: .25; background-image: repeating-linear-gradient(110deg, transparent 0 46px, rgba(255,255,255,.08) 47px 48px, transparent 49px 92px); transform: skewY(-8deg) scale(1.35); }
.login-visual-inner { position: relative; z-index: 2; height: 100%; min-height: 650px; padding: 52px 6vw; display: flex; flex-direction: column; justify-content: space-between; }
.brand-lockup-light .brand-mark { background: rgba(255,255,255,.14); backdrop-filter: blur(8px); }
.brand-lockup-light small { color: rgba(255,255,255,.72); }
.login-hero-copy { max-width: 680px; margin-top: auto; margin-bottom: auto; }
.login-hero-copy .eyebrow { color: #e0bf7d; margin-bottom: 22px; }
.login-hero-copy h1 { margin: 0; font-size: clamp(44px, 5vw, 76px); line-height: .98; letter-spacing: -.055em; font-weight: 720; }
.login-hero-copy p { max-width: 560px; margin: 28px 0 0; font-size: 18px; line-height: 1.65; color: rgba(255,255,255,.74); }
.login-kicker { display: flex; align-items: center; gap: 14px; border-top: 1px solid rgba(255,255,255,.14); padding-top: 20px; color: rgba(255,255,255,.82); }
.login-kicker span { border: 1px solid rgba(255,255,255,.18); padding: 7px 10px; border-radius: 8px; text-transform: uppercase; letter-spacing: .15em; font-size: 10px; }
.login-kicker strong { font-size: 13px; letter-spacing: .03em; }
.login-panel-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 7vw 24px; }
.login-panel { width: min(430px, 100%); }
.brand-lockup-mobile { display: none; margin-bottom: 54px; }
.login-heading { margin-bottom: 30px; }
.login-heading h2 { font-size: 38px; letter-spacing: -.04em; margin: 8px 0 8px; }
.login-heading p { color: var(--muted); line-height: 1.6; margin: 0; }
.field-label { display: block; margin: 17px 0 8px; font-size: 12px; font-weight: 750; color: var(--ink-2); }
.input-shell { height: 48px; border: 1px solid #ccd9d4; background: #fff; border-radius: 12px; display: flex; align-items: center; padding: 0 13px; gap: 10px; transition: .15s ease; }
.input-shell:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,110,85,.1); }
.input-shell input { border: 0; outline: 0; flex: 1; min-width: 0; color: var(--ink); background: transparent; }
.input-icon { color: #83958f; display: inline-flex; }
.input-action { width: 32px; height: 32px; border: 0; background: transparent; }
#loginButton { margin-top: 24px; height: 48px; }
.form-error { margin-top: 12px; padding: 10px 12px; border-radius: 9px; background: var(--red-soft); color: #913c3c; font-size: 12px; line-height: 1.45; }
.login-system-status { margin-top: 24px; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 10px; }
.login-footer { margin-top: auto; padding-top: 40px; color: #8a9a95; font-size: 11px; }

/* App shell */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 250px; position: fixed; inset: 0 auto 0 0; z-index: 30; background: linear-gradient(180deg, var(--nav), #0d2b23);
  color: rgba(255,255,255,.86); display: flex; flex-direction: column; padding: 23px 16px; box-shadow: 8px 0 30px rgba(14,48,39,.08);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.sidebar-brand .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
.sidebar-brand small { color: rgba(255,255,255,.56); }
.sidebar-context { margin: 28px 8px 16px; padding: 16px 14px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.07); border-radius: 13px; }
.sidebar-context span { display: block; font-size: 9px; color: rgba(255,255,255,.46); letter-spacing: .13em; }
.sidebar-context strong { display: block; margin-top: 5px; font-size: 13px; font-weight: 650; }
.sidebar-nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item { width: 100%; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: rgba(255,255,255,.66); display: flex; align-items: center; gap: 11px; padding: 0 12px; text-align: left; font-size: 13px; font-weight: 600; transition: .17s ease; }
.nav-item:hover { background: rgba(255,255,255,.055); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 #d2aa5f; }
.nav-item svg { width: 17px; height: 17px; opacity: .95; }
.sidebar-bottom { margin-top: auto; }
.sidebar-health { display: flex; gap: 11px; align-items: center; padding: 14px 11px; margin-bottom: 6px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-health small { display: block; font-size: 9px; color: rgba(255,255,255,.44); letter-spacing: .12em; }
.sidebar-health strong { display: block; font-size: 11px; margin-top: 3px; color: rgba(255,255,255,.78); }
.nav-item-muted { color: rgba(255,255,255,.48); }
.workspace { margin-left: 250px; width: calc(100% - 250px); min-height: 100vh; }
.topbar { height: 74px; position: sticky; top: 0; z-index: 20; background: rgba(242,245,243,.92); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(215,226,221,.8); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-kicker { font-size: 8px; color: #879791; }
.topbar h1 { margin: 3px 0 0; font-size: 21px; letter-spacing: -.025em; }
.topbar-right { display: flex; align-items: center; gap: 8px; position: relative; }
.api-pill { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--muted); font-size: 11px; font-weight: 700; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.user-chip { height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 12px; display: flex; align-items: center; gap: 9px; padding: 0 10px 0 6px; }
.user-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); font-weight: 800; font-size: 12px; }
.user-chip-copy { display: flex; flex-direction: column; text-align: left; min-width: 90px; }
.user-chip-copy b { font-size: 11px; }
.user-chip-copy small { font-size: 8px; color: var(--muted); margin-top: 2px; letter-spacing: .08em; }
.user-menu { position: absolute; right: 0; top: 49px; width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); }
.user-menu button { width: 100%; min-height: 40px; border: 0; background: transparent; border-radius: 8px; display: flex; align-items: center; gap: 10px; padding: 0 10px; font-size: 12px; }
.user-menu button:hover { background: var(--surface-soft); }
.mobile-menu-button { display: none; }
.mobile-scrim { display: none; }

.main-content { padding: 24px 28px 42px; max-width: 1800px; margin: 0 auto; }

/* Filters */
.filter-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; margin-bottom: 20px; }
.filter-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.filter-card-head strong { display: block; margin-top: 4px; font-size: 14px; }
.quick-range { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; display: flex; gap: 2px; }
.quick-range button { border: 0; background: transparent; border-radius: 7px; min-height: 28px; padding: 0 10px; color: var(--muted); font-size: 10px; font-weight: 750; }
.quick-range button.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(18,53,43,.08); }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr 1.35fr 1.35fr 1.1fr auto; gap: 10px; align-items: end; }
.filter-grid label > span { display: block; font-size: 10px; color: var(--muted); font-weight: 700; margin: 0 0 6px 2px; }
.filter-grid input, .filter-grid select, .inline-select select { width: 100%; height: 39px; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 0 9px; color: var(--ink-2); outline: 0; font-size: 11px; }
.filter-grid input:focus, .filter-grid select:focus, .inline-select select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,110,85,.08); }
.filter-disabled { opacity: .45; }
.filter-disabled select { cursor: not-allowed; background: #f2f4f3; }
.filter-actions { display: flex; gap: 7px; }
.filter-actions .btn { min-height: 39px; font-size: 11px; }
.active-filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.filter-chip { padding: 5px 8px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-strong); font-size: 9px; font-weight: 700; }

/* Cards */
.view-panel { display: none; }
.view-panel.active { display: block; animation: fadeUp .22s ease; }
@keyframes fadeUp { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.kpi-card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 16px 15px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi-card::after { content: ""; position: absolute; width: 72px; height: 72px; border-radius: 50%; right: -26px; top: -28px; background: var(--kpi-soft, var(--brand-soft)); opacity: .7; }
.kpi-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; position: relative; z-index: 1; }
.kpi-label { font-size: 10px; color: var(--muted); font-weight: 750; letter-spacing: .02em; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--kpi-soft, var(--brand-soft)); color: var(--kpi-color, var(--brand)); }
.kpi-value { display: block; margin-top: 14px; font-size: clamp(19px, 1.6vw, 27px); font-weight: 770; letter-spacing: -.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { margin-top: 7px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.content-grid { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(340px,.85fr); gap: 14px; margin-bottom: 14px; }
.content-grid-wide { grid-template-columns: minmax(0,1.55fr) minmax(300px,.45fr); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.card-head h2 { margin: 5px 0 0; font-size: 16px; letter-spacing: -.02em; }
.card-note { font-size: 9px; color: var(--muted); text-align: right; }
.chart-card { min-height: 340px; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 9px; margin-top: 3px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.legend-in { background: var(--brand); }
.legend-out { background: var(--gold); }
.trend-chart { min-height: 250px; display: grid; align-items: center; }
.trend-chart svg { width: 100%; height: auto; overflow: visible; }
.chart-grid-line { stroke: #e7eeeb; stroke-width: 1; }
.chart-axis-text { fill: #82918c; font-size: 10px; }
.chart-line-in { stroke: var(--brand); stroke-width: 3; fill: none; }
.chart-line-out { stroke: var(--gold); stroke-width: 3; fill: none; }
.chart-point-in { fill: #fff; stroke: var(--brand); stroke-width: 2; }
.chart-point-out { fill: #fff; stroke: var(--gold); stroke-width: 2; }
.chart-area-in { fill: url(#areaIn); }
.chart-area-out { fill: url(#areaOut); }
.empty-state { min-height: 150px; display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 12px; }
.empty-state strong { color: var(--ink-2); display: block; margin-bottom: 4px; }

.quality-overview { display: flex; flex-direction: column; align-items: center; }
.quality-ring { --pct: 0; width: 154px; height: 154px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--brand) calc(var(--pct) * 1%), #e7eeeb 0); position: relative; margin: 8px auto 18px; }
.quality-ring::before { content: ""; width: 116px; height: 116px; border-radius: 50%; background: #fff; position: absolute; }
.quality-ring-copy { position: relative; text-align: center; }
.quality-ring-copy strong { display: block; font-size: 27px; letter-spacing: -.04em; }
.quality-ring-copy span { display: block; margin-top: 2px; font-size: 9px; color: var(--muted); }
.quality-mini-grid { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quality-mini { padding: 10px; border-radius: 10px; background: var(--surface-soft); }
.quality-mini span { display: block; color: var(--muted); font-size: 9px; }
.quality-mini strong { display: block; margin-top: 4px; font-size: 12px; }

.category-bars, .entity-ranking, .quality-sources, .quality-origins { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; align-items: center; gap: 10px; }
.bar-name { font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; border-radius: 99px; background: #edf2f0; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #3f9075); }
.bar-value { min-width: 72px; text-align: right; font-size: 9px; color: var(--muted); }
.entity-row { display: grid; grid-template-columns: 26px minmax(0,1fr) auto; gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid #edf1ef; }
.entity-row:last-child { border-bottom: 0; }
.rank-num { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-soft); color: var(--muted); font-size: 9px; font-weight: 800; }
.entity-row:nth-child(1) .rank-num { background: var(--gold-soft); color: #946a27; }
.entity-main { min-width: 0; }
.entity-main strong { display: block; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entity-main span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.entity-value { text-align: right; }
.entity-value strong { display: block; font-size: 10px; }
.entity-value span { display: block; margin-top: 3px; font-size: 8px; color: var(--muted); }

/* Tables */
.table-card { padding-bottom: 10px; }
.table-scroll { overflow: auto; max-width: 100%; border-radius: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.data-table th { position: sticky; top: 0; z-index: 2; background: #f7f9f8; color: #73847f; text-align: left; font-size: 8.5px; text-transform: uppercase; letter-spacing: .07em; padding: 10px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 10px 11px; border-bottom: 1px solid #edf1ef; color: var(--ink-2); vertical-align: middle; white-space: nowrap; }
.data-table tbody tr:hover td { background: #fafcfb; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { display: block; font-weight: 700; color: var(--ink); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 8.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 7px; border-radius: 7px; font-size: 8px; font-weight: 800; letter-spacing: .025em; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--brand-soft); color: var(--brand); }
.badge-warn { background: var(--amber-soft); color: #a26724; }
.badge-bad { background: var(--red-soft); color: var(--red); }
.badge-neutral { background: #edf1ef; color: #71817c; }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.historical-row td { background: #fcfaf6; }
.historical-row:hover td { background: #faf6ef !important; }

.module-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin: 7px 2px 14px; }
.module-head h2 { margin: 4px 0 4px; font-size: 24px; letter-spacing: -.035em; }
.module-head p { margin: 0; color: var(--muted); font-size: 11px; }
.table-toolbar { min-height: 50px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 0 12px; }
.table-toolbar-wrap { justify-content: flex-start; flex-wrap: wrap; }
.search-box { min-width: 280px; max-width: 520px; flex: 1; height: 38px; border: 1px solid var(--line); border-radius: 9px; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: #fff; color: var(--muted); }
.search-box input { border: 0; outline: 0; width: 100%; min-width: 0; font-size: 10px; color: var(--ink); }
.inline-select { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; font-weight: 700; white-space: nowrap; }
.inline-select select { min-width: 74px; width: auto; height: 36px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; padding: 10px 4px 0; color: var(--muted); font-size: 9px; }
.pager-buttons { display: flex; gap: 5px; }
.pager button { min-width: 32px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink-2); font-size: 9px; font-weight: 700; }
.pager button:disabled { opacity: .38; cursor: default; }
.pager button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.table-loading { min-height: 260px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }

/* Quality page */
.quality-kpis { grid-template-columns: repeat(4, minmax(0,1fr)); }
.source-row { display: grid; grid-template-columns: minmax(130px,1fr) 90px 1.2fr; gap: 10px; align-items: center; }
.source-row strong { font-size: 10px; }
.source-row .source-pct { text-align: right; font-size: 10px; font-weight: 800; }
.origin-row { display: grid; grid-template-columns: minmax(120px,1fr) auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid #edf1ef; }
.origin-row:last-child { border-bottom: 0; }
.origin-row strong { font-size: 10px; }
.origin-row > span, .origin-meta > span { color: var(--muted); font-size: 9px; }
.origin-meta { display: flex; align-items: center; gap: 7px; margin-top: 4px; }

/* Modal / toasts / loading */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(7,29,23,.52); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(460px, 100%); background: #fff; border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.22); padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 15px; }
.modal-head h2 { margin: 4px 0 0; font-size: 20px; }
.modal-help { color: var(--muted); font-size: 10px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.loading-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(242,245,243,.58); backdrop-filter: blur(2px); display: grid; place-items: center; }
.loading-card { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 14px 18px; font-size: 11px; }
.spinner { width: 20px; height: 20px; border: 2px solid #dce5e1; border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 150; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: 380px; background: #17332b; color: #fff; border-radius: 11px; box-shadow: 0 14px 38px rgba(0,0,0,.2); padding: 12px 14px; font-size: 10px; line-height: 1.45; animation: toastIn .18s ease; }
.toast.error { background: #7d3636; }
.toast.warn { background: #7b5726; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 1450px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .filter-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .filter-actions { justify-content: flex-end; }
}
@media (max-width: 1120px) {
  .sidebar { width: 220px; }
  .workspace { margin-left: 220px; width: calc(100% - 220px); }
  .content-grid, .content-grid-wide { grid-template-columns: 1fr; }
  .quality-card { min-height: auto; }
  .quality-overview { flex-direction: row; gap: 24px; justify-content: center; }
  .quality-mini-grid { max-width: 360px; }
}
@media (max-width: 880px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel-wrap { padding: 36px 24px 20px; }
  .brand-lockup-mobile { display: inline-flex; }
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; width: 250px; }
  .sidebar.open { transform: none; }
  .mobile-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(8,32,25,.42); opacity: 0; visibility: hidden; transition: .2s; }
  .mobile-scrim.open { opacity: 1; visibility: visible; }
  .workspace { margin-left: 0; width: 100%; }
  .mobile-menu-button { display: inline-grid; }
  .main-content { padding: 18px; }
  .topbar { padding: 0 18px; }
  .api-pill { display: none; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .quality-kpis { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 620px) {
  .topbar { height: 68px; }
  .topbar-kicker { display: none; }
  .topbar h1 { font-size: 17px; }
  .user-chip-copy, .user-chip > svg { display: none; }
  .user-chip { padding: 0 5px; }
  .main-content { padding: 14px 10px 30px; }
  .filter-card { padding: 14px 12px; border-radius: 14px; }
  .filter-card-head { align-items: flex-start; gap: 10px; }
  .quick-range button { padding: 0 7px; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .btn { flex: 1; }
  .kpi-grid, .quality-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .kpi-card { padding: 13px 11px; }
  .kpi-value { font-size: 19px; }
  .card { border-radius: 14px; padding: 14px 12px; }
  .content-grid { gap: 10px; margin-bottom: 10px; }
  .chart-legend { flex-direction: column; gap: 5px; }
  .quality-overview { flex-direction: column; }
  .module-head { align-items: flex-start; flex-direction: column; }
  .module-head .btn { width: 100%; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; width: 100%; }
  .inline-select { justify-content: space-between; }
  .inline-select select { min-width: 140px; }
  .pager { align-items: flex-start; flex-direction: column; }
  .source-row { grid-template-columns: 1fr auto; }
  .source-row .bar-track { grid-column: 1 / -1; }
}

/* Portal V2 - usuarios, roles y permisos */
.admin-summary-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-bottom:12px; }
.admin-stat { min-height:92px; display:flex; flex-direction:column; justify-content:center; }
.admin-stat > span { color:var(--muted); font-size:9px; font-weight:800; text-transform:uppercase; letter-spacing:.07em; }
.admin-stat > strong { margin-top:6px; font-size:23px; letter-spacing:-.03em; }
.admin-stat > small { margin-top:4px; color:var(--muted); font-size:9px; }
.admin-grid { grid-template-columns:minmax(0,1.65fr) minmax(330px,.75fr); align-items:start; }
.btn-small { min-height:32px; padding:0 10px; font-size:9px; }
.roles-list { display:flex; flex-direction:column; gap:8px; }
.role-card { border:1px solid var(--line); border-radius:11px; padding:11px; background:#fbfcfb; }
.role-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.role-card h3 { margin:0; font-size:11px; }
.role-card p { margin:4px 0 0; color:var(--muted); font-size:9px; line-height:1.4; }
.role-card-meta { display:flex; flex-wrap:wrap; gap:5px; margin-top:9px; }
.permission-chip { display:inline-flex; align-items:center; min-height:21px; padding:0 6px; border-radius:6px; background:#eef4f1; color:#356d5c; font-size:7.5px; font-weight:800; }
.table-actions { display:flex; align-items:center; justify-content:flex-end; gap:5px; }
.action-link { border:0; background:transparent; color:var(--brand); font:inherit; font-size:8.5px; font-weight:800; cursor:pointer; padding:4px 5px; }
.action-link.danger { color:var(--red); }
.scope-summary { display:flex; flex-direction:column; gap:2px; }
.scope-summary strong { font-size:9px; }
.scope-summary small { color:var(--muted); font-size:8px; }
.modal-card-wide { width:min(760px,100%); max-height:calc(100vh - 34px); overflow:auto; }
.form-grid-two { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.form-grid-two label, .field-block { display:flex; flex-direction:column; gap:6px; color:var(--muted); font-size:9px; font-weight:800; }
.form-grid-two input, .form-grid-two select, .field-block input { width:100%; height:38px; border:1px solid var(--line); border-radius:9px; background:#fff; padding:0 10px; color:var(--ink); outline:none; font-size:10px; }
.field-block { margin-top:12px; }
.check-line { display:flex !important; flex-direction:row !important; align-items:center; gap:8px !important; min-height:38px; color:var(--ink-2) !important; }
.check-line input { width:15px !important; height:15px !important; }
.scope-block, .permission-panel { margin-top:16px; padding:14px; border:1px solid var(--line); border-radius:12px; background:#f9fbfa; }
.scope-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin-top:9px; }
.scope-options label { display:flex; align-items:flex-start; gap:8px; padding:10px; border:1px solid var(--line); border-radius:9px; background:#fff; cursor:pointer; }
.scope-options label:has(input:checked) { border-color:#78a995; box-shadow:0 0 0 2px rgba(49,119,93,.08); }
.scope-options input { margin-top:2px; }
.scope-options b, .scope-options small { display:block; }
.scope-options b { font-size:9px; color:var(--ink); }
.scope-options small { margin-top:3px; font-size:8px; color:var(--muted); line-height:1.35; }
.scope-selector { margin-top:12px; }
.scope-selector > strong { display:block; margin-bottom:8px; font-size:9px; }
.scope-check-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; max-height:210px; overflow:auto; padding-right:4px; }
.scope-check-grid label { display:flex; align-items:center; gap:7px; min-height:31px; padding:5px 7px; border:1px solid #e5ebe8; border-radius:8px; background:#fff; font-size:8.5px; color:var(--ink-2); }
.permission-groups { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:10px; }
.permission-group { border:1px solid #e5ebe8; background:#fff; border-radius:10px; padding:10px; }
.permission-group > strong { display:block; margin-bottom:7px; font-size:9px; }
.permission-option { display:flex; align-items:flex-start; gap:7px; padding:5px 0; }
.permission-option span b { display:block; font-size:8.5px; }
.permission-option span small { display:block; margin-top:2px; color:var(--muted); font-size:7.5px; line-height:1.25; }
.admin-hidden { display:none !important; }

@media (max-width:1120px) { .admin-grid { grid-template-columns:1fr; } }
@media (max-width:760px) {
  .admin-summary-grid { grid-template-columns:1fr; }
  .form-grid-two, .scope-options, .scope-check-grid, .permission-groups { grid-template-columns:1fr; }
  .modal-card-wide { width:100%; }
}
