:root {
    --navy-950: #07111d;
    --navy-900: #0b1726;
    --navy-800: #12233a;
    --navy-700: #1d3552;
    --green-500: #27d17f;
    --green-600: #17b86b;
    --green-100: #dcf9e9;
    --cream: #f7f7f3;
    --surface: #ffffff;
    --slate-700: #3b4a5d;
    --slate-500: #68778a;
    --slate-300: #cdd5df;
    --slate-200: #e2e7ed;
    --slate-100: #edf1f4;
    --danger: #c94d59;
    --warning: #b87919;
    --shadow: 0 18px 50px rgba(8, 22, 38, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }

html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--navy-900); background: var(--cream); }
body { margin: 0; min-height: 100vh; background: var(--cream); }
a { color: inherit; }
button, input { font: inherit; }

.app-frame { min-height: 100vh; display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 30px 22px 24px; color: #fff; background: linear-gradient(155deg, var(--navy-950), var(--navy-900) 60%, #0d2631); overflow: hidden; }
.sidebar::after { content: ""; position: absolute; width: 230px; height: 230px; right: -130px; bottom: 70px; border: 1px solid rgba(39, 209, 127, .18); transform: rotate(45deg); }
.brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--green-500); color: var(--navy-950); font-size: 22px; font-weight: 900; box-shadow: 0 10px 25px rgba(39, 209, 127, .2); transform: skew(-7deg); }
.brand-mark span { transform: skew(7deg); }
.brand-mark.large { width: 54px; height: 54px; font-size: 28px; border-radius: 15px; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; }
.brand-copy strong { font-size: 18px; letter-spacing: -.02em; }
.brand-copy small { color: #91a0b1; font-size: 11px; letter-spacing: .03em; }
.side-nav { position: relative; z-index: 1; display: grid; gap: 8px; margin-top: 58px; }
.side-nav a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 15px; border-radius: 12px; color: #aab5c3; text-decoration: none; font-weight: 650; font-size: 14px; transition: .18s ease; }
.side-nav a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.side-nav a.active { color: #fff; background: rgba(39, 209, 127, .13); box-shadow: inset 3px 0 var(--green-500); }
.nav-icon { width: 22px; color: var(--green-500); font-size: 19px; text-align: center; }
.sidebar-footer { position: relative; z-index: 1; margin-top: auto; padding: 18px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; background: rgba(255, 255, 255, .035); }
.sidebar-footer strong { display: block; margin-top: 6px; font-size: 13px; line-height: 1.4; }
.eyebrow { color: var(--slate-500); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar .eyebrow { color: #75869a; }
.logout-button { margin-top: 15px; padding: 0; border: 0; background: transparent; color: #aab5c3; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.main-content { min-width: 0; }
.content-wrap { max-width: 1460px; margin: 0 auto; padding: 42px 44px 60px; }
.topbar { display: flex; justify-content: space-between; gap: 30px; align-items: flex-start; margin-bottom: 30px; }
.topbar h1 { margin: 6px 0 0; font-size: clamp(28px, 3vw, 42px); line-height: 1.08; letter-spacing: -.045em; }
.page-intro { max-width: 650px; margin: 10px 0 0; color: var(--slate-500); font-size: 15px; line-height: 1.55; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border: 1px solid var(--slate-200); border-radius: 30px; background: rgba(255, 255, 255, .75); }
.user-chip > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--navy-800); color: #fff; font-weight: 800; }
.user-chip div { display: grid; }
.user-chip small { color: var(--slate-500); font-size: 9px; }
.user-chip strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.mobile-header { display: none; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card, .panel { border: 1px solid rgba(205, 213, 223, .8); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card { position: relative; min-height: 154px; padding: 23px; overflow: hidden; }
.metric-card > span { color: var(--slate-500); font-size: 12px; font-weight: 700; }
.metric-card > strong { display: block; margin: 14px 0 7px; color: var(--navy-900); font-size: 36px; line-height: 1; letter-spacing: -.05em; }
.metric-card > small { color: var(--slate-500); font-size: 11px; }
.accent-card::after { content: "↗"; position: absolute; right: 18px; top: 16px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--green-100); color: var(--green-600); font-weight: 900; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 18px; margin-bottom: 18px; }
.panel { padding: 25px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.panel-heading h2, .panel h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.025em; }
.panel-heading a { color: var(--green-600); font-size: 12px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.recommendation-feature h3 { max-width: 700px; margin: 16px 0 8px; font-size: 22px; letter-spacing: -.025em; }
.recommendation-feature p { max-width: 780px; color: var(--slate-500); line-height: 1.6; }
.recommendation-feature small { color: var(--slate-500); }
.run-panel { display: flex; flex-direction: column; align-items: flex-start; background: var(--navy-900); color: #fff; }
.run-panel .eyebrow { color: var(--green-500); }
.run-panel h2 { font-size: 16px; }
.run-panel .run-date { margin-top: auto; padding-top: 34px; font-size: 24px; }
.run-panel > span:not(.eyebrow), .run-panel p { margin-top: 7px; color: #9cabbc; font-size: 12px; line-height: 1.5; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-heading { padding: 25px 25px 0; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 13px 18px; border-top: 1px solid var(--slate-200); border-bottom: 1px solid var(--slate-200); background: #f9fafb; color: var(--slate-500); font-size: 9px; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 17px 18px; border-bottom: 1px solid var(--slate-100); color: var(--slate-700); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td strong { color: var(--navy-900); font-size: 12px; }
.rank-value { color: var(--navy-900) !important; font-weight: 850; }
.rank-value.not-found { color: var(--slate-500) !important; font-size: 11px; }
.movement, .type-pill, .status { display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 20px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.movement-improved, .movement-newly_found { color: #087949; background: var(--green-100); }
.movement-declined { color: var(--danger); background: #fdebed; }
.movement-unchanged, .movement-no_data { color: var(--slate-500); background: var(--slate-100); }
.movement-not_found { color: var(--warning); background: #fff4dc; }
.type-pill { color: var(--navy-700); background: #eaf0f7; font-weight: 700; }
.status { color: var(--navy-700); background: var(--slate-100); text-transform: uppercase; letter-spacing: .06em; }
.status-new, .status-accepted, .status-completed { color: #087949; background: var(--green-100); }
.status-rejected, .status-superseded { color: var(--slate-500); background: var(--slate-100); }
.inline-empty { padding: 30px; color: var(--slate-500); text-align: center; }

.empty-state { display: grid; justify-items: center; padding: 58px 24px; text-align: center; }
.empty-state .empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 14px; background: var(--green-100); color: var(--green-600); font-size: 22px; font-weight: 900; }
.empty-state h2, .empty-state h3 { margin: 4px 0 6px; }
.empty-state p { max-width: 590px; margin: 0; color: var(--slate-500); line-height: 1.6; }
.compact-empty { justify-items: start; padding: 15px 0 5px; text-align: left; }
.compact-empty .empty-icon { width: 38px; height: 38px; font-size: 17px; }
.compact-empty h3 { font-size: 17px; }
.large-empty { min-height: 370px; align-content: center; }
.large-empty code { margin-top: 20px; padding: 10px 14px; border-radius: 8px; background: var(--navy-900); color: var(--green-500); }
.history-panel { margin-top: 18px; }
.history-controls, .trend-panel { margin-top: 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.filter-grid label { display: grid; gap: 7px; color: var(--slate-500); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.filter-grid input, .filter-grid select { width: 100%; padding: 11px 12px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--surface); color: var(--navy-900); font: inherit; text-transform: none; }
.filter-actions { display: flex; align-items: end; gap: 16px; }
.button-primary { padding: 12px 16px; border: 0; border-radius: 10px; background: var(--green-500); color: var(--navy-950); cursor: pointer; font-weight: 850; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; color: var(--slate-500); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; display: inline-block; border-radius: 50%; }
.legend-organic { background: var(--green-500); }
.legend-local { background: #4f77c8; }
.trend-wrap { overflow-x: auto; padding-bottom: 6px; }
.trend-chart { width: 100%; min-width: 680px; display: block; }
.chart-axis { stroke: #718096; stroke-width: 1.5; }
.chart-grid { stroke: #dce3e8; stroke-width: 1; }
.not-found-axis { stroke: #9aa8b3; stroke-dasharray: 5 5; }
.chart-label { fill: var(--slate-500); font-size: 12px; }
.trend-line { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.trend-organic { stroke: var(--green-500); }
.trend-local { stroke: #4f77c8; }
.trend-point { stroke: var(--surface); stroke-width: 2; }
.point-organic { fill: var(--green-500); }
.point-local { fill: #4f77c8; }
.not-found-point { font-size: 18px; font-weight: 900; text-anchor: middle; }
.organic-not-found { fill: var(--green-600); }
.local-not-found { fill: #4f77c8; }
.record-range { margin: 5px 0 0; color: var(--slate-500); font-size: 11px; }
.history-table { min-width: 1375px; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 16px 22px; border-top: 1px solid var(--slate-100); color: var(--slate-500); font-size: 12px; }
.pagination a { color: var(--green-600); font-weight: 750; text-decoration: none; }
.pagination a:last-child { text-align: right; }

.recommendation-list { display: grid; gap: 16px; }
.recommendation-card { padding: 28px; }
.recommendation-meta { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.recommendation-meta time { color: var(--slate-500); font-size: 11px; }
.recommendation-card h2 { margin-top: 18px; }
.recommendation-action { color: var(--slate-700); line-height: 1.65; }
.rationale { margin-top: 20px; padding: 18px; border-left: 3px solid var(--green-500); border-radius: 0 10px 10px 0; background: #f6faf8; }
.rationale strong { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.rationale p { margin: 7px 0 0; color: var(--slate-500); line-height: 1.6; }
.recommendation-card footer { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--slate-100); color: var(--slate-500); font-size: 11px; }

.login-page { background: var(--navy-950); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(460px, 1.1fr); }
.login-brand-panel { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(38px, 6vw, 86px); overflow: hidden; color: #fff; background: linear-gradient(145deg, #07111d 10%, #0c1d30 65%, #0b302c); }
.login-brand-panel::after { content: ""; position: absolute; width: 460px; height: 460px; right: -270px; bottom: -160px; border: 1px solid rgba(39, 209, 127, .2); border-radius: 80px; transform: rotate(45deg); }
.login-brand { position: relative; z-index: 2; }
.login-brand .brand-copy strong { font-size: 24px; }
.login-tagline { max-width: 540px; margin: 110px 0 14px; font-size: clamp(38px, 5vw, 68px); font-weight: 850; line-height: .98; letter-spacing: -.06em; }
.login-description { max-width: 430px; color: #9eadbd; font-size: 16px; line-height: 1.65; }
.growth-lines { position: absolute; right: 12%; bottom: 9%; display: flex; align-items: flex-end; gap: 10px; opacity: .34; transform: skew(-12deg); }
.growth-lines i { width: 14px; height: 40px; background: var(--green-500); border-radius: 3px; }
.growth-lines i:nth-child(2) { height: 70px; }.growth-lines i:nth-child(3) { height: 108px; }.growth-lines i:nth-child(4) { height: 155px; }
.login-form-panel { display: grid; place-items: center; padding: 35px; background: var(--cream); }
.login-card { width: min(430px, 100%); }
.login-card h1 { margin: 8px 0; font-size: 38px; letter-spacing: -.045em; }
.login-card > p { margin: 0 0 28px; color: var(--slate-500); }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 9px; color: var(--navy-800); font-size: 11px; font-weight: 800; }
.login-form input { width: 100%; height: 49px; padding: 0 14px; border: 1px solid var(--slate-300); border-radius: 10px; background: #fff; color: var(--navy-900); outline: none; }
.login-form input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(39, 209, 127, .14); }
.primary-button { height: 51px; display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding: 0 17px; border: 0; border-radius: 10px; background: var(--green-500); color: var(--navy-950); font-weight: 850; cursor: pointer; box-shadow: 0 12px 25px rgba(39, 209, 127, .2); }
.form-alert { margin-bottom: 18px; padding: 12px 14px; border-radius: 9px; background: #fdebed; color: #962e3a; font-size: 12px; line-height: 1.5; }
.security-note { display: block; margin-top: 18px; color: var(--slate-500); text-align: center; }

@media (max-width: 1080px) {
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .content-wrap { padding-inline: 28px; }
    .sidebar { width: 235px; }
    .app-frame { grid-template-columns: 235px minmax(0, 1fr); }
}

@media (max-width: 780px) {
    .app-frame { display: block; }
    .sidebar { display: none; }
    .mobile-header { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 10px 18px; background: var(--navy-950); color: #fff; }
    .brand.compact .brand-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
    .brand.compact .brand-copy strong { font-size: 15px; }
    .mobile-menu { position: relative; }
    .mobile-menu summary { padding: 9px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; cursor: pointer; font-size: 12px; list-style: none; }
    .mobile-menu-panel { position: absolute; right: 0; top: 46px; width: 210px; display: grid; padding: 8px; border: 1px solid var(--slate-200); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
    .mobile-menu-panel a, .mobile-menu-panel button { display: block; width: 100%; padding: 11px; border: 0; border-radius: 7px; background: transparent; color: var(--navy-900); font-size: 13px; text-align: left; text-decoration: none; }
    .mobile-menu-panel a:hover, .mobile-menu-panel button:hover { background: var(--slate-100); }
    .content-wrap { padding: 28px 17px 45px; }
    .topbar { align-items: center; }
    .user-chip div { display: none; }
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric-card { min-height: 138px; padding: 18px; }
    .metric-card > strong { font-size: 30px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .run-panel .run-date { margin-top: 18px; padding-top: 0; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand-panel { min-height: 280px; padding: 32px; }
    .login-tagline { margin-top: 65px; font-size: 44px; }
    .login-description { font-size: 14px; }
    .growth-lines { display: none; }
    .login-form-panel { padding: 44px 24px; }
    .filter-grid { grid-template-columns: 1fr; }
    .chart-legend { margin-top: 10px; }
}

@media (max-width: 620px) {
    .topbar { align-items: flex-start; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .metric-card { min-height: 126px; }
    .metric-card > small { display: none; }
    .panel { padding: 20px; }
    .table-panel { padding: 0; }
    .table-panel > .panel-heading { padding: 20px 20px 0; }
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { padding: 14px 18px; border-top: 1px solid var(--slate-200); }
    .data-table td { display: grid; grid-template-columns: 115px 1fr; gap: 12px; padding: 7px 0; border: 0; }
    .data-table td::before { content: attr(data-label); color: var(--slate-500); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
    .inline-empty { display: block !important; padding: 22px 0 !important; }
}
