:root {
  --ink: #102c39;
  --muted: #617581;
  --line: #dce7ea;
  --soft: #f3f7f7;
  --panel: #ffffff;
  --teal: #237f7a;
  --teal-dark: #17645f;
  --teal-soft: #e5f3f1;
  --blue: #155c92;
  --green: #11865f;
  --red: #b34242;
  --amber: #9a6b18;
  --shadow: 0 12px 38px rgba(16, 44, 57, 0.08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--soft); }
body { margin: 0; min-height: 100vh; background: var(--soft); color: var(--ink); }
button, input, select { font: inherit; }
a { color: var(--teal-dark); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(1.55rem, 2.6vw, 2.15rem); line-height: 1.12; letter-spacing: -0.035em; }
h2 { margin-bottom: 0; font-size: 1.15rem; letter-spacing: -0.015em; }
code { border-radius: 5px; background: #eaf0f1; padding: 2px 6px; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; background: #123946; color: #fff; display: flex; flex-direction: column; z-index: 30; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; color: #fff; text-decoration: none; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand strong { letter-spacing: .07em; }
.sidebar-brand small { color: #a9c6cc; margin-top: 2px; }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; color: #fff; background: linear-gradient(145deg, #27a49a, #176b67); box-shadow: 0 8px 24px rgba(35,127,122,.28); font-size: 1.5rem; font-weight: 800; }
.brand-mark-small { width: 40px; height: 40px; flex: 0 0 40px; font-size: 1.05rem; }
.sidebar nav { display: grid; gap: 6px; }
.nav-link { display: flex; gap: 11px; align-items: center; padding: 11px 13px; border-radius: 11px; color: #c4d8dc; text-decoration: none; font-weight: 650; font-size: .93rem; }
.nav-link span { display: inline-grid; width: 20px; place-items: center; font-size: 1.1rem; }
.nav-link:hover, .nav-link:focus-visible { color: #fff; background: rgba(255,255,255,.08); outline: none; }
.nav-link.active { color: #fff; background: #237f7a; box-shadow: inset 3px 0 #61d0c5; }
.sidebar-foot { margin-top: auto; padding: 16px 10px 4px; color: #d5e4e7; font-size: .86rem; }
.sidebar-foot small { display: block; margin: 8px 0 0 18px; color: #8fadb4; overflow-wrap: anywhere; }
.status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #41c890; box-shadow: 0 0 0 4px rgba(65,200,144,.13); }

.main-area { min-width: 0; }
.topbar { min-height: 122px; padding: 27px clamp(22px, 4vw, 52px); display: flex; gap: 20px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); }
.topbar p { margin-bottom: 0; color: var(--muted); }
.topbar-actions { display: flex; gap: 9px; align-items: center; }
.topbar-actions form { margin: 0; }
.eyebrow { margin-bottom: 7px; color: var(--teal-dark); text-transform: uppercase; font-size: .72rem; font-weight: 800; letter-spacing: .105em; }
.menu-toggle { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-size: 1.2rem; }
.page-content { display: grid; gap: 20px; padding: clamp(20px, 3.6vw, 42px) clamp(18px, 4vw, 52px) 56px; max-width: 1600px; margin: 0 auto; }

.button { display: inline-flex; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-weight: 750; font-size: .87rem; cursor: pointer; transition: transform .15s ease, background-color .15s ease, border-color .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--teal); color: #fff; box-shadow: 0 7px 18px rgba(35,127,122,.2); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { border-color: #bad0d3; background: #fff; color: var(--ink); }
.button-secondary:hover { border-color: var(--teal); }
.button-quiet { background: transparent; color: var(--muted); }
.button-wide { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.metric-card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.metric-card { min-height: 144px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.metric-card span { color: var(--muted); font-size: .84rem; font-weight: 700; }
.metric-card strong { margin: 7px 0 2px; font-size: 2rem; letter-spacing: -.04em; }
.metric-card small { color: var(--muted); }
.accent-card { color: #fff; border-color: transparent; background: linear-gradient(135deg, #17645f, #278b84); }
.accent-card::after { content: ""; position: absolute; right: -45px; top: -50px; width: 150px; height: 150px; border-radius: 50%; background: rgba(255,255,255,.08); }
.accent-card span, .accent-card small { color: #d6f0ed; }
.panel { padding: 23px; }
.panel-head { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.panel-head p { margin-bottom: 6px; }
.panel-head > a { font-size: .87rem; font-weight: 750; white-space: nowrap; }
.split-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(300px,.65fr); gap: 20px; }
.split-grid-wide { grid-template-columns: minmax(0,1.1fr) minmax(0,.9fr); }
.detail-grid { display: grid; grid-template-columns: minmax(0,1fr) 290px; gap: 20px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.muted { color: var(--muted); font-size: .9rem; line-height: 1.55; }
.pill { display: inline-flex; border-radius: 99px; padding: 5px 9px; background: #edf2f3; color: #5a6c74; align-items: center; justify-content: center; font-size: .73rem; font-weight: 800; white-space: nowrap; }
.pill-green { color: #086444; background: #def4e9; }
.quota-track { height: 13px; overflow: hidden; border-radius: 99px; background: #e6eeef; }
.quota-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #237f7a, #55baa9); transition: width .45s ease; }
.quota-labels { display: grid; grid-template-columns: 35px 1fr 35px; gap: 8px; margin: 10px 0 18px; color: var(--muted); align-items: center; font-size: .76rem; }
.quota-labels strong { color: var(--ink); text-align: center; }
.quota-labels span:last-child { text-align: right; }
.job-status { font-weight: 800; text-transform: capitalize; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-head { padding: 23px 23px 0; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { padding: 12px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); background: #f8fafa; text-align: left; text-transform: uppercase; letter-spacing: .055em; font-size: .68rem; white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid #e8eff0; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfd; }
.selected-row { background: var(--teal-soft); }
.target-result { background: #e8f6f1; box-shadow: inset 4px 0 var(--green); }
.keyword-link, .result-title { color: var(--ink); font-weight: 750; text-decoration: none; }
.keyword-link:hover, .result-title:hover { color: var(--teal-dark); text-decoration: underline; }
.category-tag { color: var(--muted); white-space: nowrap; }
.position-cell { font-size: .96rem; font-weight: 850; }
.change { color: var(--muted); white-space: nowrap; }
.change.positive { color: var(--green); font-weight: 800; }
.change.negative { color: var(--red); font-weight: 800; }
.result-title + p { max-width: 750px; margin: 5px 0 0; color: var(--muted); line-height: 1.45; }
.message-cell { max-width: 360px; white-space: pre-line; color: var(--muted); }
.truncate-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-cell { padding: 35px; color: var(--muted); text-align: center; }

.inline-form { display: flex; gap: 8px; align-items: center; }
input, select { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #becdd1; border-radius: 9px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgba(35,127,122,.14); border-color: var(--teal); }
.inline-form select { width: auto; min-width: 170px; }
.stack-form { display: grid; gap: 15px; }
.stack-form label { display: grid; gap: 7px; color: #3c535e; font-size: .83rem; font-weight: 750; }
.device-tabs { display: inline-flex; margin-bottom: 20px; padding: 4px; border-radius: 10px; background: #edf3f3; }
.device-tabs a { min-width: 110px; padding: 8px 13px; border-radius: 8px; color: var(--muted); text-decoration: none; text-align: center; font-size: .83rem; font-weight: 750; }
.device-tabs a.active { color: var(--teal-dark); background: #fff; box-shadow: 0 2px 8px rgba(16,44,57,.08); }
.chart-wrap { position: relative; min-height: 250px; padding-left: 42px; }
.chart-wrap svg { display: block; width: 100%; height: 230px; overflow: visible; }
.chart-wrap line { stroke: #e0e9eb; stroke-width: 1; }
.chart-wrap polyline { fill: none; stroke: var(--teal); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.chart-wrap circle { fill: #fff; stroke: var(--teal); stroke-width: 3; }
.chart-axis { position: absolute; inset: 13px auto 24px 0; display: flex; flex-direction: column; justify-content: space-between; color: var(--muted); font-size: .72rem; }
.detail-kpis { display: grid; grid-template-columns: .7fr 1fr 2fr; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.detail-kpis span { min-width: 0; }
.detail-kpis small, .detail-kpis strong { display: block; }
.detail-kpis small { margin-bottom: 5px; color: var(--muted); }
.detail-kpis strong { font-size: .9rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.definition-list { margin: 20px 0; }
.definition-list div { display: flex; gap: 12px; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; max-width: 62%; overflow-wrap: anywhere; font-weight: 750; text-align: right; }
.empty-state { min-height: 210px; display: grid; place-content: center; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 1.05rem; }
.empty-state p, .empty-compact p { margin: 7px 0 0; }
.empty-compact { padding: 18px 0; color: var(--muted); }
.info-panel { display: flex; gap: 16px; align-items: flex-start; }
.info-panel p { margin: 7px 0 0; color: var(--muted); line-height: 1.55; }

.alert { padding: 13px 16px; border: 1px solid; border-radius: 11px; line-height: 1.45; font-size: .88rem; }
.alert-success { color: #0a6748; border-color: #a9ddc9; background: #e8f7f1; }
.alert-error { color: #8b3030; border-color: #e4baba; background: #fff0f0; }
.alert-warning { color: #805712; border-color: #e7ce9e; background: #fff8e8; }

.dialog-card { width: min(520px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 25px 80px rgba(16,44,57,.25); }
.dialog-card::backdrop { background: rgba(8,30,38,.55); backdrop-filter: blur(2px); }
.dialog-card form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #edf3f3; color: var(--ink); cursor: pointer; font-size: 1.35rem; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 22px; background: radial-gradient(circle at 15% 15%, #dff1ef 0, transparent 34%), radial-gradient(circle at 85% 85%, #dbeaf1 0, transparent 38%), #f4f8f8; }
.login-shell { width: min(100%, 470px); }
.login-card { padding: clamp(28px, 6vw, 45px); border: 1px solid rgba(190,211,214,.9); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 24px 80px rgba(16,44,57,.12); }
.login-card .brand-mark { margin-bottom: 26px; }
.login-card h1 { font-size: 2rem; }
.login-intro { margin-bottom: 25px; color: var(--muted); line-height: 1.55; }
.security-note { margin: 20px 0 0; color: #7b8d94; font-size: .77rem; line-height: 1.45; text-align: center; }
.scrim { display: none; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 30px; }
  .detail-side .definition-list { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 265px; transition: transform .22s ease; box-shadow: 15px 0 50px rgba(4,30,39,.22); }
  .menu-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: inline-grid; flex: 0 0 42px; place-items: center; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(7,31,39,.45); }
  .menu-open .scrim { display: block; }
  .topbar { align-items: flex-start; padding: 20px; }
  .topbar-actions .button-secondary { display: none; }
  .split-grid, .split-grid-wide { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 125px; }
  .page-content { padding: 18px 13px 42px; }
  .topbar { min-height: 104px; gap: 13px; }
  .topbar > div:nth-child(2) { min-width: 0; }
  .topbar p:not(.eyebrow) { display: none; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .button-quiet { padding-inline: 7px; }
  .panel { padding: 18px; border-radius: 14px; }
  .table-panel { padding: 0; }
  .table-panel .panel-head { padding: 18px 18px 0; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form select { width: 100%; }
  .detail-kpis { grid-template-columns: 1fr 1fr; }
  .detail-kpis span:last-child { grid-column: 1 / -1; }
  .detail-side { display: block; }
  td, th { padding-inline: 12px; }
}

