:root {
  /* Huly.ai brand */
  --huly-blue: #046bd2;
  --huly-blue-dark: #045cb4;
  --huly-cyan: #4db6e8;
  --huly-purple: #9d4edd;
  --huly-magenta: #ff007a;
  --huly-coral: #ff7e5f;
  --huly-gradient: linear-gradient(135deg, #4db6e8 0%, #9d4edd 45%, #ff007a 78%, #ff7e5f 100%);

  --ink: #111827;
  --ink-soft: #334155;
  --mute: #64748b;
  --line: #e5e7eb;
  --paper: #ffffff;
  --paper-muted: #f8fafc;
  --panel: #ffffff;
  --teal: var(--huly-blue);
  --teal-deep: var(--huly-blue-dark);
  --forest: #059669;
  --ember: #e11d48;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --radius: 14px;
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  --font-display: var(--font-sans);
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: #ffffff;
}

a { color: var(--huly-blue); text-decoration: none; }
a:hover { color: var(--huly-blue-dark); }

/* Shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  background: #ffffff;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: #ffffff;
  color: var(--ink);
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  color: inherit;
  padding: 0.35rem 0.5rem 0.75rem;
}

.sidebar-brand:hover { color: inherit; }

.sidebar-brand img {
  display: block;
  height: 42px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.brand-product {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--huly-blue);
  padding-left: 0.15rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.sidebar-nav a {
  color: var(--ink-soft);
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-weight: 550;
  transition: background 160ms ease, color 160ms ease;
}

.sidebar-nav a:hover {
  color: var(--huly-blue-dark);
  background: #f0f5fa;
}

.sidebar-nav a.active {
  color: var(--huly-blue-dark);
  background: #e8f2fc;
  box-shadow: inset 3px 0 0 var(--huly-blue);
}

.nav-group {
  display: grid;
  gap: 0.15rem;
  margin-top: 0.35rem;
}

.nav-group-label {
  padding: 0.55rem 0.9rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}

.nav-group-children {
  display: grid;
  gap: 0.15rem;
}

.sidebar-nav a.nav-child {
  padding-left: 1.35rem;
  font-size: 0.92rem;
}

.nav-group.is-active > .nav-group-label {
  color: var(--huly-blue);
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.user-chip strong { display: block; font-size: 0.92rem; color: var(--ink); }
.user-chip span { color: var(--mute); font-size: 0.8rem; }

.btn-logout {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-weight: 500;
}

.btn-logout:hover {
  background: #f0f5fa;
  border-color: #cfe0f5;
  color: var(--huly-blue-dark);
}

.main-wrap {
  min-width: 0;
  background: #ffffff;
}

.main-content {
  padding: 2rem 2.25rem 3rem;
  max-width: 1280px;
  background: #ffffff;
}

/* Page */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: rise 480ms ease both;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 2.2vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
  color: var(--ink);
}

.page-sub, .muted { color: var(--mute); margin: 0; }
.eyebrow { margin: 0 0 0.35rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mute); }
.small { font-size: 0.88rem; }

.period-picker, .inline-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.period-picker label { font-size: 0.85rem; color: var(--mute); }

.period-picker input,
.period-picker select,
.inline-actions input[type="month"] {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  color: var(--ink);
}

/* KPI / panels */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.kpi, .panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi {
  padding: 1.15rem 1.2rem 1.25rem;
  animation: rise 560ms ease both;
}

.kpi:nth-child(2) { animation-delay: 60ms; }
.kpi:nth-child(3) { animation-delay: 120ms; }
.kpi:nth-child(4) { animation-delay: 180ms; }
.kpi:nth-child(5) { animation-delay: 240ms; }

.kpi-label {
  display: block;
  color: var(--mute);
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 0.45rem;
}

.kpi-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}

.kpi-value-sm { font-size: 1.25rem; }

.kpi-meta { display: block; margin-top: 0.45rem; font-size: 0.82rem; color: var(--mute); }
.kpi-meta.up { color: var(--forest); }
.kpi-meta.down { color: var(--ember); }

.panel-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel {
  padding: 1.15rem 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
  animation: rise 620ms ease both;
}

.panel-wide { grid-column: span 1; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--ink);
}

.panel-head span, .panel-head a { color: var(--mute); font-size: 0.85rem; }

.module-legend {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  font-size: 0.9rem;
}

.module-legend .dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.45rem;
}

.dot.calls { background: var(--huly-blue); }
.dot.surveys { background: var(--huly-purple); }
.dot.audio { background: var(--huly-magenta); }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--mute);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .strong { font-weight: 650; }
.data-table tfoot td {
  font-weight: 600;
  border-bottom: 0;
  background: #f0f5fa;
}

.cell-stack { display: grid; gap: 0.15rem; }

.status {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--ink-soft);
}

.status-draft { background: #e8f2fc; color: var(--huly-blue-dark); }
.status-sent { background: #ede9fe; color: #6d28d9; }
.status-paid { background: #d1fae5; color: #047857; }
.status-overdue { background: #ffe4e6; color: #be123c; }

.csat-green { background: #d1fae5; color: #047857; }
.csat-yellow { background: #fef3c7; color: #b45309; }
.csat-red { background: #ffe4e6; color: #be123c; }
.csat-unset { background: #f1f5f9; color: var(--ink-soft); }

.project-overview-grid {
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.2fr);
  margin-bottom: 1rem;
}

.csat-chart-wrap {
  max-width: 260px;
  margin: 0 auto;
}

.csat-legend {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
}

.csat-legend .dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.csat-dot-green { background: #047857; }
.csat-dot-yellow { background: #eab308; }
.csat-dot-red { background: #be123c; }

.assignment-cell {
  min-width: 11rem;
  vertical-align: top;
}

.assignment-form {
  margin: 0;
}

.lead-picker {
  position: relative;
  display: flex;
  gap: 0.25rem;
  align-items: flex-start;
}

.lead-picker .lead-search {
  min-width: 10rem;
}

.lead-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 12rem;
  overflow: auto;
}

.lead-suggestion {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.lead-suggestion:hover {
  background: #f8fafc;
}

.csat-select.csat-select-csat-green { border-color: #047857; }
.csat-select.csat-select-csat-yellow { border-color: #eab308; }
.csat-select.csat-select-csat-red { border-color: #be123c; }

.btn, .btn-accent, .btn-ghost {
  border: 0;
  border-radius: 10px;
  font-weight: 600;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

.btn-accent {
  background: var(--huly-blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(4, 107, 210, 0.25);
}

.btn-accent:hover {
  background: var(--huly-blue-dark);
  color: #fff;
}

.btn-ghost {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  border-color: #cfe0f5;
  color: var(--huly-blue-dark);
  background: #f0f5fa;
}

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

.btn:focus-visible,
.btn-accent:focus-visible,
.btn-ghost:focus-visible,
.btn-logout:focus-visible {
  outline: 2px solid var(--huly-blue);
  outline-offset: 2px;
}

.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--mute);
}

.empty-state p { margin: 0; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pagination-meta { margin: 0; }

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-page {
  font-size: 0.88rem;
  color: var(--ink-soft);
  padding: 0 0.35rem;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-size label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pagination-size select {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  color: var(--ink);
}

.inline-actions {
  flex-wrap: wrap;
}

.period-picker,
.list-toolbar {
  width: 100%;
}

@media (min-width: 861px) {
  .period-picker,
  .list-toolbar {
    width: auto;
  }
}

.flash {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 500;
}

.flash-ok { background: #d1fae5; color: #047857; }
.flash-error { background: #ffe4e6; color: #be123c; }

.db-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  color: var(--ink-soft);
  background: #f0f5fa;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
}

a.db-name-link {
  text-decoration: none;
}

a.db-name-link:hover .db-name {
  color: var(--huly-blue-dark);
  background: #e8f2fc;
  text-decoration: underline;
}

.size-bar {
  display: flex;
  width: 7.5rem;
  height: 0.55rem;
  border-radius: 999px;
  overflow: hidden;
  background: #e8eef5;
}

.size-seg { display: block; height: 100%; min-width: 0; }
.size-heap { background: #046bd2; }
.size-toast { background: #c2410c; }
.size-index { background: #7c3aed; }

.size-legend {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.75rem 0 0;
}

.size-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  margin-right: 0.25rem;
  vertical-align: -1px;
}

.rec-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.rec-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: #f8fafc;
}

.rec-item strong { display: block; margin-bottom: 0.25rem; }
.rec-item p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; line-height: 1.45; }
.rec-info { border-left: 3px solid var(--huly-blue); }
.rec-warn { border-left: 3px solid #c2410c; background: #fff7ed; }
.rec-high { border-left: 3px solid #be123c; background: #fff1f2; }
.text-warn { color: #c2410c; font-weight: 600; }

.sort-link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.sort-link:hover,
.sort-link.active {
  color: var(--huly-blue);
}

.pricing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.pricing-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.pricing-list li:last-child { border-bottom: 0; }

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: #ffffff;
}

.auth-stage { width: min(420px, 100%); animation: rise 520ms ease both; }

.auth-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.5rem;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: block;
  height: 48px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 0.35rem;
}

.auth-brand {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--huly-blue);
  margin-bottom: 0.65rem;
}

.auth-lede {
  color: var(--mute);
  margin-bottom: 1.5rem;
}

.auth-hint {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--mute);
}

.auth-form .form-control {
  border-radius: 12px;
  border-color: var(--line);
  background: #fff;
}

.auth-form .form-control:focus {
  border-color: var(--huly-blue);
  box-shadow: 0 0 0 3px rgba(4, 107, 210, 0.15);
}

.auth-form .form-label { font-weight: 500; color: var(--ink-soft); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.15rem 0;
  color: var(--mute);
  font-size: 0.82rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.btn-sso {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  font-weight: 600;
}

.btn-sso:hover {
  background: #f7f9fc;
  border-color: #c5d0de;
  color: var(--ink);
}

.sso-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.flash-warn {
  background: #fff8e8;
  border: 1px solid #f0d48a;
  color: #7a5a10;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font-size: 0.92rem;
}

/* Client forms */
.form-grid {
  display: grid;
  gap: 1.25rem;
}

.form-section {
  padding: 1rem 0 0.25rem;
  border-top: 1px solid var(--line);
}

.form-section:first-child { border-top: 0; padding-top: 0; }

.form-section h3 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 650;
}

.form-row-2, .form-row-3 {
  display: grid;
  gap: 0.85rem;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.pricing-periods-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.pricing-periods-head h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.table-wrap-wide {
  overflow-x: auto;
}

.table-wrap-wide .data-table {
  min-width: 1100px;
}

.client-form .form-control {
  border-radius: 11px;
  border-color: var(--line);
  background: #fff;
}

.client-form .form-control:focus {
  border-color: var(--huly-blue);
  box-shadow: 0 0 0 3px rgba(4, 107, 210, 0.15);
}

.client-form .form-label {
  font-weight: 500;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.input-prefix {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: stretch;
}

.input-prefix span {
  display: grid;
  place-items: center;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 11px 0 0 11px;
  background: #f0f5fa;
  color: var(--mute);
}

.input-prefix .form-control { border-radius: 0 11px 11px 0; }

.stage-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.stage-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-weight: 500;
}

.stage-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--huly-blue); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.btn-danger {
  background: var(--ember);
  color: #fff;
  border: 0;
  border-radius: 11px;
  font-weight: 600;
  padding: 0.55rem 1rem;
}

.row-actions {
  white-space: nowrap;
  text-align: right;
  vertical-align: top;
}

.row-actions > a + a,
.row-actions > a + .inline-form,
.row-actions > .inline-form + a,
.row-actions > .inline-form + .inline-form {
  margin-left: 0.75rem;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  margin: 0;
  vertical-align: baseline;
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--huly-blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover { color: var(--ink); }

.form-grid-split {
  align-items: start;
}

@media (min-width: 900px) {
  .form-grid-split {
    grid-template-columns: minmax(16rem, 1fr) minmax(18rem, 1.25fr);
    gap: 2rem;
  }
}

.perm-group { margin: 0 0 1rem; }

.perm-group-title {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mute);
}

.perm-checks {
  display: grid;
  gap: 0.55rem;
}

.perm-checks-nested {
  margin-left: 0.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--line);
}

.danger-link { color: var(--ember) !important; }

.detail-list {
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.detail-list > div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.75rem;
}

.detail-list dt {
  margin: 0;
  color: var(--mute);
  font-size: 0.85rem;
}

.detail-list dd { margin: 0; font-weight: 500; }

.stage-track {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.stage-step {
  padding: 0.85rem 0.75rem;
  border-radius: 12px;
  border: 1px dashed var(--line);
  color: var(--mute);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
  background: #ffffff;
}

.stage-step.done {
  border-style: solid;
  border-color: #bfdbfe;
  background: #e8f2fc;
  color: var(--huly-blue-dark);
}

.doc-current { margin: 0.5rem 0; font-size: 0.9rem; }

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.list-toolbar .search-field {
  flex: 1 1 220px;
  min-width: 180px;
}

.list-toolbar .form-control {
  border-radius: 10px;
  border: 1px solid var(--line);
}

.toolbar-select {
  display: grid;
  gap: 0.25rem;
}

.toolbar-select label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toolbar-select select {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  color: var(--ink);
  min-width: 140px;
}

.toolbar-meta { margin: 0 0 0.85rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.brand-bar {
  height: 4px;
  width: 100%;
  background: var(--huly-gradient);
  border-radius: 999px;
  margin-bottom: 1rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.is-hidden { display: none !important; }

.refresh-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: rgba(15, 35, 60, 0.28);
  backdrop-filter: blur(2px);
}

.refresh-card {
  width: min(360px, calc(100vw - 2rem));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem 1.35rem 1.25rem;
  box-shadow: 0 18px 40px rgba(15, 35, 60, 0.18);
  text-align: center;
}

.refresh-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 3px solid #d9e8f8;
  border-top-color: var(--huly-blue);
  animation: refresh-spin 0.75s linear infinite;
}

.refresh-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
  color: var(--ink);
}

.refresh-status {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  min-height: 1.35em;
}

.refresh-bar {
  height: 6px;
  border-radius: 999px;
  background: #e8f0f8;
  overflow: hidden;
}

.refresh-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--huly-blue);
  transition: width 180ms ease;
}

.refresh-count { margin: 0.65rem 0 0; }

body.refresh-active { cursor: progress; }

.row-refreshing { opacity: 0.72; }

.row-updated {
  animation: row-flash 850ms ease;
}

.cell-pending {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 1.2em;
}

.cell-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #d9e8f8;
  border-top-color: var(--huly-blue);
  animation: refresh-spin 0.7s linear infinite;
}

@keyframes refresh-spin {
  to { transform: rotate(360deg); }
}

@keyframes row-flash {
  from { background: #e8f3fc; }
  to { background: transparent; }
}

.row-renewal-upcoming {
  background: #fff7ed;
}

.row-renewal-upcoming:hover {
  background: #ffedd5;
}

.row-renewal-overdue {
  background: #fff1f2;
}

.row-renewal-overdue:hover {
  background: #ffe4e6;
}

.renewal-action {
  display: grid;
  gap: 0.35rem;
  justify-items: end;
  min-width: 10rem;
}

.renewal-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--mute);
  font-weight: 500;
}

.actions-cell {
  text-align: right;
  white-space: nowrap;
}

.inline-chart-picker select {
  min-width: 12rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  background: #fff;
}

.empty-hint {
  padding: 1.25rem 0.25rem 0.5rem;
}

@media (max-width: 1100px) {
  .kpi-grid, .kpi-grid-3, .kpi-grid-5, .panel-grid { grid-template-columns: 1fr 1fr; }
  .form-row-3, .stage-track { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .sidebar-foot { width: 100%; grid-template-columns: 1fr auto; align-items: center; }
  .main-content { padding: 1.25rem; }
  .page-head { flex-direction: column; align-items: start; }
  .kpi-grid, .kpi-grid-3, .kpi-grid-5, .panel-grid, .form-row-2, .form-row-3, .stage-checks, .stage-track { grid-template-columns: 1fr; }
  .detail-list > div { grid-template-columns: 1fr; gap: 0.2rem; }
}
