@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;1,600&display=swap');

:root {
    color-scheme: light;
    --ink: #172a24;
    --pine: #183a32;
    --pine-soft: #31574b;
    --paper: #f3f6f1;
    --surface: #ffffff;
    --line: #dce5dc;
    --muted: #718078;
    --lime: #d3f26c;
    --red: #c94843;
    --red-soft: #f9e9e7;
    --orange: #d17a32;
    --orange-soft: #fff0e2;
    --green: #29834d;
    --green-soft: #e5f3e8;
    --sans: 'DM Sans', 'Avenir Next', 'Segoe UI', sans-serif;
    --mono: 'DM Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
    margin: 0;
    color: var(--ink);
    background-color: var(--paper);
    background-image: linear-gradient(rgba(24, 58, 50, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(24, 58, 50, .035) 1px, transparent 1px);
    background-size: 32px 32px;
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
}
button, input, select { font: inherit; }
button, select { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #80a94c; outline-offset: 2px; }

/* Shared marks and labels */
.brand-mark {
    position: relative;
    display: inline-block;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    background: var(--lime);
}
.brand-mark::after {
    position: absolute;
    top: 3px;
    left: 8px;
    width: 3px;
    height: 12px;
    background: var(--pine);
    content: '';
    transform: skew(-25deg);
}
.eyebrow {
    margin: 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    line-height: 1.4;
    text-transform: uppercase;
}
.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-radius: 4px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { color: var(--pine); background: var(--lime); }
.button-primary:hover { background: #e0fa8e; }

/* Login */
.login-page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr);
    background: var(--surface);
}
.login-intro {
    position: relative;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 34px 5.2vw 30px;
    color: #fff;
    background-color: var(--pine);
    background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
    background-size: 44px 44px;
}
.login-brand, .brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    font-family: var(--mono);
    font-size: 11px;
    text-decoration: none;
}
.login-brand b, .brand b { color: var(--lime); font-weight: 500; }
.login-title-wrap { position: relative; z-index: 1; padding: 0 0 4vh; }
.login-title-wrap .eyebrow { color: #a7c7b5; }
.login-title-wrap h1 {
    max-width: 700px;
    margin: 18px 0 28px;
    font-size: 64px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: .99;
}
.login-title-wrap h1 span { color: var(--lime); }
.intro-rule { display: flex; width: 158px; height: 6px; gap: 5px; }
.intro-rule i { display: block; flex: 1; background: var(--lime); }
.intro-rule i:nth-child(2) { opacity: .58; }
.intro-rule i:nth-child(3) { opacity: .28; }
.intro-foot { margin: 0; color: #a7c7b5; font-family: var(--mono); font-size: 10px; }
.intro-foot span { padding: 0 8px; color: var(--lime); }
.login-panel { display: grid; align-items: center; justify-items: center; padding: 36px; }
.login-panel-inner { width: min(100%, 380px); animation: rise-in .45s ease both; }
.login-panel h2 { margin: 8px 0 34px; font-size: 32px; font-weight: 600; }
.login-form { display: grid; gap: 10px; }
.login-form label { margin-top: 2px; font-size: 12px; font-weight: 700; }
.login-form input[type=password] {
    width: 100%;
    height: 50px;
    border: 1px solid #cbd6cc;
    border-radius: 4px;
    padding: 0 14px;
    background: #fbfcfa;
}
.login-form input[type=password]:focus { border-color: var(--pine-soft); outline: 3px solid rgba(41,131,77,.14); }
.login-submit { width: 100%; margin-top: 10px; }
.login-submit span { font-size: 18px; }
.form-error { margin: 0; color: var(--red); font-size: 12px; font-weight: 600; }
.login-note { margin: 20px 0 0; color: var(--muted); font-size: 12px; }

/* Dashboard shell */
.site-header { color: #fff; background: var(--pine); border-bottom: 4px solid var(--lime); }
.header-inner {
    display: flex;
    max-width: 1560px;
    min-height: 62px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 auto;
    padding: 0 38px;
}
.brand { font-size: 11px; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 24px; }
.header-edition { color: #b7c8bf; font-family: var(--mono); font-size: 10px; }
.header-right form { margin: 0; }
.import-button {
    min-height: 36px;
    border: 1px solid rgba(255,255,255,.36);
    border-radius: 4px;
    padding: 0 12px;
    color: #fff;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.import-button:hover:not(:disabled) { border-color: var(--lime); color: var(--lime); }
.import-button:disabled { cursor: progress; opacity: .7; }
.logout-button {
    min-height: 36px;
    border: 1px solid rgba(255,255,255,.36);
    border-radius: 4px;
    padding: 0 12px;
    color: #fff;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
}
.logout-button:hover { border-color: var(--lime); color: var(--lime); }
.import-feedback { margin: 0 0 18px; border-left: 3px solid; padding: 11px 14px; font-size: 12px; font-weight: 600; }
.import-feedback-success { border-color: var(--green); color: #216c3e; background: var(--green-soft); }
.import-feedback-error { border-color: var(--red); color: #8d302c; background: var(--red-soft); }
.main-shell { max-width: 1560px; margin: 0 auto; padding: 32px 38px 28px; animation: rise-in .45s ease both; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; padding: 3px 0 25px; border-bottom: 1px solid #ccd8ce; }
.hero-copy .eyebrow { color: #62776a; }
.hero-copy h1 { margin: 7px 0 9px; font-size: 36px; font-weight: 600; letter-spacing: 0; line-height: 1.15; }
.hero-copy h1 em { color: var(--green); font-family: 'Playfair Display', Georgia, serif; font-weight: 600; }
.hero-subtitle { display: flex; align-items: center; gap: 8px; margin: 0; color: #5a6b61; font-size: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.snapshot-control { display: grid; min-width: 220px; gap: 6px; }
.snapshot-control label { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.snapshot-control select, .filter-control select, .page-size-control select {
    min-width: 0;
    height: 42px;
    border: 1px solid #cbd6cc;
    border-radius: 4px;
    padding: 0 32px 0 11px;
    background-color: var(--surface);
}
.snapshot-control select { font-weight: 600; }

/* Hierarchical filters */
.filters-section { padding: 20px 0 18px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 16px; font-weight: 700; }
.scope-count { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.filter-control { display: grid; min-width: 0; gap: 6px; }
.filter-control label { display: flex; align-items: center; gap: 7px; color: #5e7065; font-size: 11px; font-weight: 600; }
.filter-control label::first-letter { color: var(--green); }
.filter-control label span { color: var(--ink); font-size: 12px; }
.filter-control select { width: 100%; height: 42px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-control select:disabled { color: #7d8a82; background-color: #edf1ed; }

/* Color distribution */
.status-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 8px 0 28px;
    border-top: 1px solid #d5dfd6;
    border-bottom: 1px solid #d5dfd6;
    background: rgba(255,255,255,.78);
}
.status-stat, .status-total { display: flex; min-height: 84px; align-items: center; gap: 13px; padding: 14px 20px; border-right: 1px solid #dce5dc; }
.status-stat::before { width: 4px; height: 39px; flex: 0 0 4px; background: currentColor; content: ''; }
.stat-red { color: var(--red); }
.stat-orange { color: var(--orange); }
.stat-green { color: var(--green); }
.status-total { border-right: 0; color: var(--ink); }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 500; line-height: 1; }
.stat-label { display: flex; flex-direction: column; gap: 5px; color: #596960; font-size: 11px; }
.stat-label i { color: inherit; font-family: var(--mono); font-size: 9px; font-style: normal; }
.stat-red .stat-label i { color: var(--red); }
.stat-orange .stat-label i { color: var(--orange); }
.stat-green .stat-label i { color: var(--green); }

/* Results and controls */
.results-section { padding-top: 2px; }
.results-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.results-heading .eyebrow { color: #62776a; }
.results-heading h2 { margin: 4px 0 0; font-size: 23px; font-weight: 600; }
.results-tools { display: flex; align-items: flex-end; gap: 10px; }
.search-control { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.search-control input { width: 218px; height: 42px; border: 1px solid #cbd6cc; border-radius: 4px; padding: 0 11px; background: var(--surface); color: var(--ink); font-size: 12px; }
.search-control input::placeholder { color: #89978e; }
.button-export { min-height: 42px; color: #fff; background: var(--pine); font-size: 12px; }
.button-export:hover:not(:disabled) { background: #275246; }
.button-export b { min-width: 18px; border-radius: 2px; padding: 2px 5px; color: var(--pine); background: var(--lime); font-family: var(--mono); font-size: 10px; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 9px; }
.status-segment { display: inline-flex; gap: 3px; border: 1px solid #d4dfd5; border-radius: 5px; padding: 3px; background: rgba(255,255,255,.8); }
.status-segment button {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    gap: 7px;
    border: 0;
    border-radius: 3px;
    padding: 0 11px;
    color: #52635a;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}
.status-segment button:hover { background: #edf2eb; }
.status-segment button[aria-pressed=true] { color: #fff; background: var(--pine); }
.swatch { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.swatch-red { color: var(--red); }
.swatch-orange { color: var(--orange); }
.swatch-green { color: #56b975; }
.status-segment button[aria-pressed=true] .swatch-red { color: #ff9a94; }
.status-segment button[aria-pressed=true] .swatch-orange { color: #ffc184; }
.status-segment button[aria-pressed=true] .swatch-green { color: #9de7aa; }
.page-size-control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.page-size-control select { width: 74px; height: 36px; padding-left: 9px; }
.table-frame { overflow: hidden; border: 1px solid #d7e0d8; background: var(--surface); }
.table-scroll { overflow: auto; max-height: min(62vh, 760px); }
table { width: 100%; min-width: 1170px; border-collapse: separate; border-spacing: 0; font-size: 11px; }
thead { position: sticky; z-index: 2; top: 0; }
th { height: 43px; border-bottom: 1px solid #cfdbd0; padding: 0 12px; color: #52635a; background: #f1f5f0; font-size: 10px; font-weight: 700; text-align: left; white-space: nowrap; }
th.numeric, td.numeric { text-align: right; }
td { max-width: 270px; height: 41px; border-bottom: 1px solid #edf1ed; padding: 7px 12px; overflow: hidden; color: #3a4b41; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:hover { background: #f7faf6; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.row-red td:first-child { box-shadow: inset 3px 0 var(--red); }
tbody tr.row-orange td:first-child { box-shadow: inset 3px 0 var(--orange); }
tbody tr.row-green td:first-child { box-shadow: inset 3px 0 var(--green); }
tbody tr.row-neutral td:first-child { box-shadow: inset 3px 0 #87958a; }
.sort-button { display: inline-flex; align-items: center; gap: 7px; border: 0; padding: 5px 0 5px 5px; color: inherit; background: transparent; cursor: pointer; font-size: inherit; font-weight: inherit; }
.sort-button:hover { color: var(--green); }
.sort-button span { color: var(--green); font-size: 14px; }
.rate-pill { display: inline-flex; min-width: 72px; justify-content: center; border-radius: 3px; padding: 4px 8px; font-family: var(--mono); font-size: 10px; font-weight: 500; }
.rate-red { color: #a93330; background: var(--red-soft); }
.rate-orange { color: #a9581e; background: var(--orange-soft); }
.rate-green { color: #216c3e; background: var(--green-soft); }
.rate-neutral { color: #57645b; background: #edf1ed; }
.empty-state, .loading-state { padding: 42px 18px; color: var(--muted); text-align: center; }
.empty-mark { display: block; color: #a5b1a7; font-family: var(--mono); font-size: 25px; }
.empty-state p { margin: 8px 0 0; font-size: 12px; }
.loading-state { display: none; }
.loading-state.is-visible { display: block; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.page-buttons { display: flex; gap: 5px; }
.page-buttons button { width: 34px; height: 32px; border: 1px solid #cbd6cc; border-radius: 3px; color: var(--pine); background: var(--surface); cursor: pointer; font-size: 16px; }
.page-buttons button:hover:not(:disabled) { border-color: var(--pine); background: #edf3ee; }
.page-buttons button:disabled { color: #aab4ac; cursor: not-allowed; }
.app-error { margin: 12px 0; border-left: 3px solid var(--red); padding: 10px 12px; color: #8d302c; background: var(--red-soft); font-size: 12px; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 12px 0 0; color: #7e8d83; font-family: var(--mono); font-size: 9px; }

@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1050px) {
    .main-shell { padding-right: 26px; padding-left: 26px; }
    .header-inner { padding-right: 26px; padding-left: 26px; }
    .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .status-stat, .status-total { padding-right: 12px; padding-left: 12px; }
    .stat-value { font-size: 23px; }
    .results-heading { align-items: flex-start; }
}
@media (max-width: 700px) {
    .login-page { grid-template-columns: 1fr; }
    .login-intro { min-height: 40vh; padding: 24px; }
    .login-title-wrap { padding: 48px 0 18px; }
    .login-title-wrap h1 { margin: 12px 0 18px; font-size: 46px; }
    .login-panel { min-height: 48vh; align-items: start; padding: 35px 24px 46px; }
    .login-panel h2 { margin-bottom: 24px; }
    .header-inner { min-height: 58px; flex-wrap: wrap; row-gap: 9px; padding: 10px 16px; }
    .header-edition { display: none; }
    .header-right { width: 100%; justify-content: flex-end; gap: 8px; }
    .import-button, .logout-button { padding-right: 9px; padding-left: 9px; font-size: 11px; }
    .main-shell { padding: 24px 16px 20px; }
    .hero-row { align-items: flex-start; flex-direction: column; gap: 17px; padding-bottom: 18px; }
    .hero-copy h1 { font-size: 30px; }
    .snapshot-control { width: 100%; }
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 9px; }
    .filter-control:last-child { grid-column: span 2; }
    .status-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 10px 0 23px; }
    .status-stat, .status-total { min-height: 71px; padding: 10px; }
    .status-stat:nth-child(2) { border-right: 0; }
    .status-stat:nth-child(1), .status-stat:nth-child(2) { border-bottom: 1px solid #dce5dc; }
    .stat-value { font-size: 21px; }
    .stat-label { font-size: 10px; }
    .results-heading { flex-direction: column; gap: 13px; }
    .results-tools { width: 100%; align-items: flex-end; }
    .search-control { flex: 1; min-width: 0; }
    .search-control input { width: 100%; }
    .button-export { flex: 0 0 auto; padding: 0 10px; }
    .table-toolbar { align-items: flex-start; flex-direction: column; gap: 9px; }
    .status-segment { width: 100%; justify-content: space-between; }
    .status-segment button { gap: 5px; padding: 0 7px; font-size: 10px; }
    .page-footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
