/* Highlands Dashboard portal. Palette: Charcoal #3B3939, Slate #5A5858,
   Deep Forest #395E33, paper #FAFAF8. Carries the app shell plus the ops card
   styles, so the server-injected /ops fragment renders inside the shell. */

:root {
  --charcoal: #3B3939;
  --slate: #5A5858;
  --forest: #395E33;
  --paper: #FAFAF8;
  --line: #ECEAE6;
  --warn: #9B2D2D;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, 'Helvetica Neue', Arial, sans-serif;
  color: var(--charcoal);
  background: var(--paper);
  line-height: 1.4;
}

a { color: var(--forest); }

/* ---- App shell ---------------------------------------------------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--charcoal);
  color: #EDEDEB;
  padding: 22px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  font-size: 20px; font-weight: 700; letter-spacing: .4px;
  padding: 0 22px 18px; color: #fff;
}
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a {
  color: #C9C9C7; text-decoration: none; font-size: 14px;
  padding: 11px 22px; border-left: 3px solid transparent;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar nav a.active {
  color: #fff; background: rgba(57,94,51,.35); border-left-color: var(--forest);
  font-weight: 600;
}
.sidebar nav a .soon {
  font-size: 9px; text-transform: uppercase; letter-spacing: .5px;
  color: #8C8C8A; border: 1px solid #565452; border-radius: 4px;
  padding: 1px 4px; margin-left: 6px; vertical-align: middle;
}
.sidebar .navsep { height: 1px; background: #565452; margin: 12px 22px; }
.sidebar nav a.signout { margin-top: 6px; color: #9C9C9A; }

.content { flex: 1 1 auto; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 16px 32px;
}
.topbar .pagetitle { font-size: 16px; font-weight: 600; color: var(--charcoal); }
.topbar .who { font-size: 13px; color: var(--slate); text-align: right; }
.topbar .who .email { display: block; font-size: 11px; color: #9C9C9A; }

main { max-width: 1120px; margin: 0 auto; padding: 24px 32px 48px; }

/* ---- Panels, KPI cards, charts (ops fragment) --------------------------- */

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 18px 20px; margin-bottom: 20px;
}
.panel.narrow { max-width: 560px; }
.panel h2 {
  margin: 0 0 14px; font-size: 16px; font-weight: 600; color: var(--forest);
  border-bottom: 2px solid var(--forest); padding-bottom: 8px;
}

.ops-asof { color: var(--slate); font-size: 13px; margin: 0 0 16px; }
.ops-source { color: var(--slate); font-size: 11px; margin-top: 20px; }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panels .panel { margin-bottom: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.card {
  background: var(--paper); border: 1px solid #EEECE8; border-radius: 8px;
  padding: 12px 14px;
}
.card .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--slate); }
.card .val { font-size: 24px; font-weight: 600; margin-top: 3px; }
.card .sub { font-size: 12px; color: var(--slate); margin-top: 2px; }
.card .dual { display: flex; gap: 20px; margin-top: 4px; }
.card .dv { font-size: 23px; font-weight: 600; color: var(--charcoal); }
.card .dl { font-size: 10px; color: var(--slate); text-transform: uppercase; margin-left: 4px; }

.ops-section {
  margin: 34px 0 0; padding-bottom: 8px; font-size: 16px; font-weight: 600;
  color: var(--forest); border-bottom: 2px solid var(--forest);
}
.charts { margin-top: 24px; display: grid; gap: 20px; }
.chart { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.chart img { width: 100%; height: auto; display: block; }

/* ---- Forms, buttons, tables --------------------------------------------- */

.form label, .kv td { font-size: 14px; }
.form label {
  display: block; color: var(--slate); margin: 0 0 14px; font-size: 12px;
  text-transform: uppercase; letter-spacing: .3px;
}
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input:not([type]), .form input[name=code] {
  display: block; width: 100%; margin-top: 5px;
  font-size: 15px; font-family: inherit; color: var(--charcoal);
  padding: 9px 11px; border: 1px solid #D9D7D3; border-radius: 6px; background: #fff;
  text-transform: none; letter-spacing: normal;
}
.form input:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 2px rgba(57,94,51,.15); }
.form label.checkbox { text-transform: none; letter-spacing: normal; font-size: 13px; color: var(--charcoal); }
.form label.checkbox input { margin-right: 6px; }

.btn {
  display: inline-block; background: var(--forest); color: #fff; border: none;
  font-size: 14px; font-family: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 18px; border-radius: 6px; text-decoration: none; margin-top: 4px;
}
.btn:hover { background: #2F4E2A; }
.link {
  background: none; border: none; color: var(--forest); cursor: pointer;
  font-size: 13px; font-family: inherit; padding: 0; text-decoration: underline;
}
.resend { margin-top: 14px; }

.kv { border-collapse: collapse; width: 100%; margin-bottom: 14px; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv td:first-child { color: var(--slate); width: 130px; }

.users { border-collapse: collapse; width: 100%; font-size: 14px; }
.users th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
  color: var(--slate); padding: 8px 10px; border-bottom: 2px solid var(--line);
}
.users td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.users tr.disabled-row td { color: #A6A6A4; }
.users .actions { text-align: right; }
.inline { display: inline; }

.muted { color: var(--slate); font-size: 13px; }
.key-status { display: block; font-size: 12px; margin-top: 6px; text-transform: none; letter-spacing: normal; }
.key-status.set { color: var(--forest); font-weight: 600; }
.key-status.unset { color: var(--slate); }
.soon-badge {
  display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--slate); border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px;
}

/* ---- Flash messages ----------------------------------------------------- */

.flash { padding: 11px 14px; border-radius: 7px; font-size: 14px; margin-bottom: 18px; }
.flash.ok { background: #EAF0E8; color: #2F4E2A; border: 1px solid #C9DBC4; }
.flash.warn { background: #FBF3E7; color: #8A5A1A; border: 1px solid #EAD7B8; }
.flash.err { background: #F7EAEA; color: var(--warn); border: 1px solid #E4C4C4; }

/* ---- Login page --------------------------------------------------------- */

.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--charcoal);
}
.login-card {
  background: #fff; border-radius: 12px; padding: 34px 32px;
  width: 360px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-card .brand-big { font-size: 26px; font-weight: 700; color: var(--charcoal); letter-spacing: .4px; }
.login-card .login-sub { margin: 2px 0 18px; color: var(--slate); font-size: 13px; }
.login-card .form input[name=code] { font-size: 22px; letter-spacing: 6px; text-align: center; }

/* ---- Rent + Funnel views (mirrors) ------------------------------------- */

.rent-head { margin-bottom: 6px; }
.rent-head .back { font-size: 13px; text-decoration: none; }
.rent-head h2 { margin: 8px 0 2px; font-size: 20px; color: var(--charcoal); }
.rsec { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--slate); margin: 18px 0 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 8px; }
.tile {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; text-decoration: none; color: var(--charcoal); transition: border-color .12s;
}
.tile:hover { border-color: var(--forest); }
.tile-missing { opacity: .6; cursor: default; }
.tile-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--slate); }
.tile-name { font-size: 16px; font-weight: 600; margin-top: 3px; }
.tile-sub { font-size: 12px; margin-top: 2px; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.tile-num { font-size: 11px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 2px solid var(--line); margin: 8px 0 18px; }
.tabs a {
  font-size: 14px; color: var(--slate); text-decoration: none; padding: 9px 14px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs a:hover { color: var(--charcoal); }
.tabs a.active { color: var(--forest); border-bottom-color: var(--forest); font-weight: 600; }

.rtable { border-collapse: collapse; width: 100%; font-size: 13px; }
.rtable th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
  color: var(--slate); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.rtable td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rtable td.r, .rtable th.r { text-align: right; font-variant-numeric: tabular-nums; }
.rtable td.strong { font-weight: 600; }
.rtable td.center { text-align: center; }
.rtable .specials { display: block; font-size: 11px; color: #8A5A1A; margin-top: 2px; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.grade { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.st-active { background: #EAF0E8; color: #2F4E2A; }
.st-bad { background: #F7EAEA; color: var(--warn); }
.st-pending { background: #FBF3E7; color: #8A5A1A; }
.st-none { background: #EEECE8; color: var(--slate); }
.g-higher { background: #DCEFE0; color: #1E7D32; }
.g-shigher { background: #E9F6EC; color: #186A3B; }
.g-similar { background: #E7F0FB; color: #1B4F8A; }
.g-slower { background: #FBF1DC; color: #8A6D1E; }
.g-lower { background: #F7E3E2; color: #B3261E; }
.g-none { background: #EEECE8; color: var(--slate); }

.range { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font-size: 12px; color: var(--slate); text-decoration: none; border: 1px solid var(--line); border-radius: 14px; padding: 3px 11px; }
.chip:hover { border-color: var(--forest); color: var(--charcoal); }
.chip.active { background: var(--forest); color: #fff; border-color: var(--forest); }

.rlegend {
  display: flex; flex-wrap: wrap; gap: 9px 16px; margin-bottom: 14px;
  padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
.rlegend .lg { font-size: 12px; color: var(--charcoal); display: flex; align-items: center; gap: 6px; }
.rlegend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.chart-title { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--charcoal); }
.canvas-wrap { position: relative; height: 340px; }

.notice { border: 1px solid #EAD7B8; background: #FBF7EE; border-radius: 8px; padding: 14px 16px; }
.notice strong { color: var(--charcoal); }
.notice code { background: #F0EEE9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- Funnel (PrimeStage mirror) ---------------------------------------- */

.fwin { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.fwin-range { margin-left: 8px; font-size: 12px; }

.fcard { }
.fcard-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.fcard-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--charcoal); }

.funnel-stages { display: flex; flex-direction: column; gap: 9px; }
.fstage-top { display: flex; justify-content: space-between; font-size: 13px; }
.fstage-label { color: var(--charcoal); }
.fstage-count { font-variant-numeric: tabular-nums; font-weight: 600; }
.fbar { background: #F1F0ED; border-radius: 4px; height: 18px; overflow: hidden; display: flex; }
.fbar-fill { background: var(--forest); height: 100%; min-width: 2px; }
.fbar-seg { height: 100%; }
.fsegs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; padding-left: 2px; }
.fseg { font-size: 11px; color: var(--slate); }
.seg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: middle; }
.chan-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; flex: 0 0 auto; }
.fsub { margin: 10px 0 0; font-size: 12px; }
.fconv { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 14px 0 4px; font-size: 13px; color: var(--slate); }
.fconv b { color: var(--charcoal); font-size: 15px; font-variant-numeric: tabular-nums; margin-right: 4px; }

.ftable { margin-top: 14px; }
.ftable .barcol { width: 38%; }
.ftable .barcell { vertical-align: middle; }
.ftable .barcell .fbar { height: 12px; }
.fsubhead { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--slate); margin: 18px 0 8px; }
.stalled-row td { background: #FBF3E7; }

.o-active { background: #eef3ff; color: #1b4f8a; }
.o-moved { background: #395e33; color: #fff; }
.o-lost { background: #f0e0e0; color: #8a2b2b; }
.o-none { background: #EEECE8; color: var(--slate); }

.adcell { display: flex; align-items: center; gap: 9px; max-width: 320px; }
.adthumb { width: 38px; height: 38px; object-fit: cover; border-radius: 5px; flex: 0 0 auto; border: 1px solid var(--line); }
.adtext { display: flex; flex-direction: column; min-width: 0; }
.adhl { font-size: 11px; margin-top: 1px; }

.chan-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.chan-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.chan-name { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--slate); }
.chan-spend { font-size: 19px; font-weight: 600; margin: 2px 0; font-variant-numeric: tabular-nums; }
.chan-sub { font-size: 11px; }
.chan-row td { font-weight: 600; }
.chan-src { font-size: 10px; text-transform: uppercase; letter-spacing: .3px; margin-left: 6px; font-weight: 400; }
.camp-row td { font-weight: 400; color: var(--slate); font-size: 12px; }
.camp-name { padding-left: 26px !important; }

.seo-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.seo-stat { background: var(--paper); border: 1px solid #EEECE8; border-radius: 8px; padding: 10px 12px; }
.seo-stat .sv { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.seo-stat .sl { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--slate); margin-top: 2px; }
.trend { font-size: 11px; font-weight: 600; }
.trend.good { color: #395e33; }
.trend.bad { color: #b3261e; }
.trend.flat { color: #9a9a9a; }
.seo-branded { margin: 8px 0 14px; display: flex; align-items: center; gap: 8px; }
.b-branded { background: #eef7e9; color: #3d6b1e; }
.b-nonbranded { background: #eee; color: #555; }

/* Funnel legends + glossaries (mirror PrimeStage's explanatory UX) */
.bar-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 16px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.bar-legend .bl-title { font-size: 12px; font-weight: 600; color: var(--charcoal); }
.bar-legend .bl-item { font-size: 12px; color: var(--slate); display: flex; align-items: center; gap: 5px; }
.bar-legend .bl-swatch { width: 11px; height: 11px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.glossary { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.glossary-h { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--charcoal); }
.glossary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px 28px; }
.glossary-col h5 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--charcoal); }
.glossary-col h5 .gsub { font-size: 11px; font-weight: 400; color: #8A8A8A; margin-left: 4px; }
.glossary dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; margin: 0; align-items: start; }
.glossary dt { white-space: nowrap; }
.glossary dd { margin: 0; font-size: 12px; color: var(--slate); }
.seo-legend { margin-top: 6px; font-size: 12px; color: var(--slate); line-height: 1.5; }
.seo-nonbrand-dot { color: #8A6D1E; font-weight: 700; }
.seo-buckets { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.sb-top { display: flex; justify-content: space-between; font-size: 12px; }
.seo-psi { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.psi-head { font-size: 12px; font-weight: 600; color: var(--charcoal); }
.psi { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.psi-good { background: #eef6ed; color: #1e7d32; }
.psi-mid { background: #fbf4e6; color: #8a6d1e; }
.psi-bad { background: #fbeceb; color: #b3261e; }
.psi-cwv { font-size: 11px; }
.seo-mini { max-width: 360px; }
.nb { color: #8A6D1E; }
.pgcell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

/* ---- Responsive --------------------------------------------------------- */

@media (max-width: 880px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-basis: auto; height: auto; position: static; padding: 14px 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { border-left: none; padding: 8px 16px; }
  .sidebar nav a.active { border-left: none; border-radius: 5px; }
  .sidebar .navsep { display: none; }
  .panels { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .seo-stats { grid-template-columns: repeat(2, 1fr); }
  main { overflow-x: auto; }
}
