/* Review insights — layout and components on top of Lumen tokens.
   Every value comes from lumen_tokens.css. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
button, input, select { font-family: inherit; font-size: var(--text-base); }

.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: var(--space-6) var(--space-8) var(--space-12); display: flex; flex-direction: column; gap: var(--space-4); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0; height: 100vh; position: sticky; top: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar__logo { height: var(--topbar-height); display: flex; align-items: center; padding: 0 var(--space-5); border-bottom: 1px solid var(--border); }
.sidebar__logo img { height: 24px; width: auto; }
.sidebar__nav { flex: 1; padding: var(--space-3); display: flex; flex-direction: column; gap: 2px; }
.sidebar__section { padding: var(--space-3) var(--space-3) var(--space-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%;
  padding: 9px var(--space-3); border: none; border-radius: var(--radius-md);
  background: transparent; color: var(--fg-secondary); font-weight: var(--weight-medium);
  cursor: pointer; text-align: left; transition: background var(--dur-med) var(--ease-out);
}
.nav-item:hover { background: var(--bg-alt); }
.nav-item--active { background: var(--primary-soft); color: var(--info-text); font-weight: var(--weight-semibold); }
.nav-item:focus-visible, .seg button:focus-visible, .btn:focus-visible, .select:focus-visible,
.input:focus-visible, .link-btn:focus-visible, th button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.sidebar__footer { padding: var(--space-3); border-top: 1px solid var(--border); }
.user { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); }
.user__avatar {
  width: 28px; height: 28px; border-radius: var(--radius-pill); background: var(--bg-alt); color: var(--fg-secondary);
  display: inline-flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.user__name { font-size: var(--text-sm); font-weight: var(--weight-semibold); }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-height); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 var(--space-8); gap: var(--space-5);
  position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.topbar__subtitle { font-size: var(--text-sm); color: var(--fg-tertiary); margin-top: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-6); }
.card--flush { padding: 0; }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-4); }
.card--flush .card__head { padding: var(--space-5) var(--space-6) 0; }
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.card__subtitle { font-size: var(--text-sm); color: var(--fg-tertiary); margin-top: 2px; }
.grid-kpi { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 1280px) { .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-2 { grid-template-columns: 1fr; } }

.kpi__value { font-size: var(--text-3xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; line-height: 1; margin: var(--space-3) 0 var(--space-2); font-variant-numeric: tabular-nums; }
.kpi__foot { font-size: var(--text-sm); color: var(--fg-tertiary); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Toolbar, filters ---------- */
.filters__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); min-height: 24px; }
.filters__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4) var(--space-4); }
.filters__chips { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.select.select--block { width: 100%; max-width: none; min-width: 0; }
.picker { position: relative; }
.picker__button { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); cursor: pointer; text-align: left; }
.picker__button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker__menu {
  position: absolute; top: calc(100% + var(--space-1)); left: 0; min-width: max(100%, 240px); z-index: 20; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: var(--space-2);
  animation: fade var(--dur-fast) var(--ease-out);
}
.picker__option { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border-radius: var(--radius-sm); cursor: pointer; }
.picker__option:hover { background: var(--bg); }
.picker__option input { accent-color: var(--primary); width: 16px; height: 16px; }
.picker__actions { display: flex; flex-wrap: wrap; gap: var(--space-1); border-top: 1px solid var(--border); margin-top: var(--space-1); padding-top: var(--space-2); }
@media (max-width: 1100px) { .filters__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar__logo img, .nav-item span, .sidebar__section, .user__name { display: none; }
  .content { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
  .topbar__subtitle, .topbar .caption { display: none; }
  .filters__grid { grid-template-columns: 1fr; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 140px; }
.field__label { font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-tertiary); }
.select, .input {
  height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg-primary); outline: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.select:focus, .input:focus { border-color: var(--border-focus); box-shadow: var(--shadow-focus); }
.select { min-width: 160px; max-width: 240px; }
.input--search { min-width: 220px; }
.spacer { flex: 1; }

.seg { display: inline-flex; background: var(--bg-alt); border-radius: var(--radius-md); padding: 2px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--fg-secondary); padding: 7px var(--space-3);
  border-radius: var(--radius-sm); cursor: pointer; font-weight: var(--weight-medium);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.seg button:hover { color: var(--fg-primary); }
.seg .seg--on { background: var(--surface); color: var(--fg-primary); box-shadow: var(--shadow-xs); font-weight: var(--weight-semibold); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 var(--space-4);
  border-radius: var(--radius-md); border: none; cursor: pointer; font-weight: var(--weight-medium);
  background: var(--secondary); color: var(--fg-primary); transition: background var(--dur-med) var(--ease-out);
}
.btn:hover { background: var(--secondary-hover); }
a.btn { text-decoration: none; }
.btn--ghost { background: transparent; color: var(--fg-secondary); }
.btn--ghost:hover { background: var(--bg-alt); color: var(--fg-primary); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.link-btn { border: none; background: transparent; color: var(--fg-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: var(--radius-xs); }
.link-btn:hover { color: var(--fg-primary); background: var(--bg-alt); }

.check { display: inline-flex; align-items: center; gap: var(--space-2); height: 36px; cursor: pointer; color: var(--fg-secondary); }
.check input { accent-color: var(--primary); width: 16px; height: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--info-text); font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.chip button { border: none; background: transparent; color: inherit; cursor: pointer; display: inline-flex; padding: 2px; border-radius: var(--radius-pill); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; }
.badge--neutral { background: var(--bg-alt); color: var(--fg-secondary); }
.badge--ok { background: var(--success-soft); color: var(--success-text); }
.badge--err { background: var(--error-soft); color: var(--error-text); }
.badge--warn { background: var(--warning-soft); color: var(--warning-text); }
.badge--info { background: var(--info-soft); color: var(--info-text); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.delta--up { color: var(--success-text); }
.delta--down { color: var(--error-text); }
.delta--flat { color: var(--fg-tertiary); }
.muted { color: var(--fg-tertiary); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
/* Long tables scroll inside their card; the header (and the matrix total) stay in view. */
.table-wrap--scroll { max-height: 708px; overflow-y: auto; } /* header 41 + 10 rows of 65 + 16 of scrollbar */
.table-wrap--matrix { max-height: 552px; } /* header 41 + 10 rows of 45 + total row 45 + 16 of scrollbar */
.table-wrap--scroll thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border); }
.table-wrap--scroll tfoot td { position: sticky; bottom: 0; z-index: 1; }
.table th {
  text-align: left; padding: var(--space-3) var(--space-4); background: var(--bg); white-space: nowrap;
  font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-tertiary);
}
.table th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: var(--radius-xs); }
.table th.num, .table td.num { text-align: right; }
.table td { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--bg); }
.cell-main { font-weight: var(--weight-semibold); }
.cell-sub { font-size: var(--text-xs); color: var(--fg-tertiary); margin-top: 2px; }
.matrix td, .matrix th { white-space: nowrap; }
.matrix tfoot td { border-top: 2px solid var(--border-strong); background: var(--bg); }
.cell-up { background: var(--success-soft); color: var(--success-text); }
.cell-down { background: var(--error-soft); color: var(--error-text); }
.cell-low { background: var(--warning-soft); color: var(--warning-text); font-weight: var(--weight-semibold); }
.table-foot { padding: var(--space-3) var(--space-6); font-size: var(--text-sm); color: var(--fg-tertiary); border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart-note { margin: 0 0 var(--space-3); }
.legend { margin-bottom: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--text-xs); color: var(--fg-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 0; border-top-width: 2px; border-top-style: solid; }
.legend i.box { width: 10px; height: 10px; border: none; border-radius: 2px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--fg-primary); color: var(--fg-inverse);
  border-radius: var(--radius-md); box-shadow: var(--shadow-tooltip); padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm); min-width: 180px; z-index: 5; transition: opacity var(--dur-fast) var(--ease-out);
}
.tooltip__title { font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.tooltip__row { display: flex; justify-content: space-between; gap: var(--space-4); font-variant-numeric: tabular-nums; }
.tooltip__row span:first-child { color: var(--fg-disabled); }

.hbar { display: grid; grid-template-columns: 140px 1fr 120px; gap: var(--space-3); align-items: center; padding: var(--space-2) 0; }
.hbar__track { position: relative; height: 8px; background: var(--bg-alt); border-radius: var(--radius-pill); }
.hbar__fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--fg-secondary); border-radius: var(--radius-pill); }
.hbar__mark { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--fg-primary); border-radius: 1px; }
.hbar__value { text-align: right; font-variant-numeric: tabular-nums; font-size: var(--text-sm); }

/* ---------- Review cards ---------- */
.review { padding: var(--space-5) var(--space-6); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--space-3); }
.review:first-child { border-top: none; }
.review__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.review__rating { display: inline-flex; align-items: center; gap: 4px; font-weight: var(--weight-bold); font-size: var(--text-md); font-variant-numeric: tabular-nums; }
.review__unit { font-weight: var(--weight-semibold); }
.review__text { white-space: pre-wrap; line-height: var(--leading-relaxed); max-width: 920px; }
.review__text--clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.review .link-btn { align-self: flex-start; }
.review__private { background: var(--bg-alt); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); max-width: 920px; }
.review__private .overline { display: block; margin-bottom: var(--space-1); }
.review__foot { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ---------- States ---------- */
.state { padding: var(--space-10); text-align: center; color: var(--fg-tertiary); }
.skeleton { background: var(--bg-alt); border-radius: var(--radius-md); min-height: 120px; animation: pulse 1.2s var(--ease-in-out) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.fade-in { animation: fade var(--dur-med) var(--ease-out); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.login__card { width: 360px; background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); padding: var(--space-8); display: flex; flex-direction: column; gap: var(--space-4); }
.login__card img { height: 26px; width: auto; align-self: flex-start; }
.login__card .input { width: 100%; }
.btn--primary { background: var(--primary); color: var(--fg-on-primary); justify-content: center; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--primary:active { background: var(--primary-active); }
.form-error { background: var(--error-soft); color: var(--error-text); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }
