/* ============================================================
   Yönetişim (NewGovernance) — applied styles for this app.
   Consumes tokens.css. Admin layout: a fixed left sidebar + a
   sticky topbar per the design system's app Shell/SidebarItem,
   with Button / Card / Input / Badge / Avatar looks ported from
   the component specs. Turkish UI lives in the templates.
   ============================================================ */

* { box-sizing: border-box; }

html { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--text-body);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.shell { display: flex; }

a { color: var(--text-brand); text-decoration: none; }
a:hover { color: var(--brand-active); text-decoration: underline; }

/* Inline-sprite icons inherit stroke from currentColor. */
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5) var(--space-3);
  background: var(--surface-card);
  border-right: var(--border-width) solid var(--border-subtle);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  padding: var(--space-1) var(--space-2) var(--space-5);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .brand-full { height: 24px; display: block; }
.sidebar-brand .brand-mark { height: 26px; display: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.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(--text-body);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-strong); text-decoration: none; }
.nav-item .icon { color: var(--text-muted); }
.nav-item span { flex: 1; }
.nav-item.active {
  background: var(--surface-brand-subtle);
  color: var(--green-800);
  font-weight: var(--weight-semibold);
}
.nav-item.active .icon { color: var(--green-700); }

/* Collapsible nav section (Raporlar). A <details> element rather than a scripted
   toggle: the enforced CSP forbids inline script, so JS would mean another static
   file for what the browser does natively. */
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group .chevron {
  flex: 0 0 auto; width: 16px; height: 16px;
  transition: transform var(--duration-fast) var(--ease-standard);
}
.nav-group[open] .chevron { transform: rotate(90deg); }
/* Children are indented to the parent's label, so the icon column lines up under
   the chevron rather than under the section icon. */
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 var(--space-1) var(--space-5); }
.nav-sub .nav-item { padding: 7px var(--space-3); font-size: var(--text-sm); }
.nav-sub .icon { width: 16px; height: 16px; }

/* Pinned to the bottom: user identity + sign out. */
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-logout { margin: 0; }
.nav-logout .nav-item { color: var(--text-muted); }
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  margin-bottom: var(--space-1);
  border-top: var(--border-width) solid var(--border-subtle);
}
.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-circle);
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  user-select: none;
}
.user-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: var(--text-xs); color: var(--text-muted); }

/* ============================================================
   Main column: sticky topbar + scrolling content
   ============================================================ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-8);
  background: color-mix(in srgb, var(--surface-card) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: var(--border-width) solid var(--border-subtle);
}
.topbar-heading { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.topbar-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-snug);
  line-height: var(--leading-tight);
  color: var(--text-strong);
  margin: 0;
}
.topbar-sub {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
}
a.topbar-sub:hover { color: var(--text-brand); text-decoration: none; }
.topbar-sub .icon { width: 15px; height: 15px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.content {
  flex: 1;
  padding: var(--space-7) var(--space-8) var(--space-9);
}

/* ============================================================
   Buttons (ported from Button.jsx: sizes sm/md, variants)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-snug);
  line-height: 1;
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  background: var(--brand);
  color: var(--brand-contrast);
  box-shadow: var(--shadow-xs);
  transition: background var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast),
              box-shadow var(--duration-fast);
}
.btn:hover { background: var(--brand-hover); color: var(--brand-contrast); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 18px; height: 18px; }

.btn.secondary {
  background: var(--surface-card);
  color: var(--text-strong);
  border-color: var(--border-default);
}
.btn.secondary:hover { background: var(--surface-hover); color: var(--text-strong); }

.btn.ghost { background: transparent; color: var(--text-body); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text-strong); }

.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-700); color: #fff; }

.btn.subtle { background: var(--surface-brand-subtle); color: var(--text-brand); box-shadow: none; }
.btn.subtle:hover { background: var(--green-100); color: var(--text-brand); }

.btn.sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn.sm .icon { width: 16px; height: 16px; }
.btn.block { width: 100%; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}
/* Flush variant for edge-to-edge tables: the table supplies its own padding. */
.table-card { padding: 0; overflow: hidden; }
.form-card { max-width: 620px; }
.empty-state { color: var(--text-muted); text-align: center; padding: var(--space-8) var(--space-6); }

/* Section heading between cards (e.g. a customer's contracts). */
h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-strong);
  margin: 0;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin: var(--space-7) 0 var(--space-4);
}
.card + .section-header { margin-top: var(--space-8); }

/* ============================================================
   Forms (ported from Input.jsx)
   ============================================================ */
form p { margin: 0 0 var(--space-4); }
label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
  margin-bottom: var(--space-1);
}
input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=tel],
input[type=url],
input[type=search],
input[type=date],
input:not([type]),
textarea,
select {
  width: 100%;
  padding: 0 var(--space-3);
  height: 40px;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text-strong);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
textarea { height: auto; min-height: 88px; padding: var(--space-3); line-height: var(--leading-normal); resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}
select { cursor: pointer; }
.helptext { display: block; color: var(--text-muted); font-size: var(--text-xs); margin-top: var(--space-1); }
.errorlist {
  list-style: none;
  padding: 0;
  margin: var(--space-1) 0;
  color: var(--danger-700);
  font-size: var(--text-sm);
}
/* Form-wide (non-field) errors render as a danger banner. */
.errorlist.nonfield {
  background: var(--danger-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-weight: var(--weight-medium);
}
.actions { display: flex; gap: var(--space-3); margin-top: var(--space-6); }

/* Two fields on one line (e.g. start/end dates, SMS/e-mail prices). */
.form-row { display: flex; gap: var(--space-4); margin: 0 0 var(--space-4); }
.form-row > .field { flex: 1; min-width: 0; margin-bottom: 0; }
@media (max-width: 520px) {
  .form-row { flex-direction: column; gap: 0; margin-bottom: 0; }
  .form-row > .field { margin-bottom: var(--space-4); }
}

/* ============================================================
   Tables
   ============================================================ */
table { width: 100%; border-collapse: collapse; background: var(--surface-card); font-size: var(--text-md); }
th, td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: var(--border-width) solid var(--border-subtle); }
th {
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-hover); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============================================================
   Messages / alerts
   ============================================================ */
.messages { list-style: none; padding: 0; margin: 0 0 var(--space-5); }
.messages li {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.messages li.success { background: var(--success-bg); color: var(--success-700); }
.messages li.error   { background: var(--danger-bg);  color: var(--danger-700); }
.messages li.warning { background: var(--warning-bg); color: var(--warning-700); }
.messages li.info,
.messages li.debug   { background: var(--info-bg);    color: var(--info-700); }

/* ============================================================
   Detail list
   ============================================================ */
dl { display: grid; grid-template-columns: 200px 1fr; gap: var(--space-3) var(--space-5); margin: 0; align-items: baseline; }
dt { font-weight: var(--weight-semibold); color: var(--text-muted); font-size: var(--text-sm); }
dd { margin: 0; color: var(--text-strong); }

/* ============================================================
   Status badges (ported from Badge.jsx, with a leading dot)
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-snug);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge.success { background: var(--success-bg); color: var(--success-700); }
.badge.warning { background: var(--warning-bg); color: var(--warning-700); }
.badge.danger  { background: var(--danger-bg);  color: var(--danger-700); }
.badge.info    { background: var(--info-bg);    color: var(--info-700); }
.badge.neutral { background: var(--surface-sunken); color: var(--text-muted); }

/* ============================================================
   List filter bar
   ============================================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.filters .field { display: flex; flex-direction: column; gap: var(--space-1); }
.filters label { margin-bottom: 0; }
.filters select { width: auto; min-width: 168px; }
/* Search box reads as a control, not a full-width bar (base inputs are 100%). */
.filters input[type="search"] { width: auto; min-width: 280px; }
/* Live "N kişi" count sitting beside the search box. */
.filter-count { align-self: center; color: var(--text-muted); font-size: var(--text-sm); }

/* Contact-list notes: one line, ellipsis; the full note is in the cell's title (hover)
   and in the row's data-search, so clipping never hides it from search. */
.notes-cell { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   Inline pricing-tier formset
   ============================================================ */
.tier-table { width: 100%; border-collapse: collapse; background: transparent; }
.tier-table th { background: none; padding: 0 var(--space-3) var(--space-2) 0; }
.tier-table td { padding: var(--space-2) var(--space-3) var(--space-2) 0; border: 0; vertical-align: top; }
.tier-table input { height: 38px; }
.tier-table .delete-cell { white-space: nowrap; color: var(--text-muted); font-size: var(--text-sm); vertical-align: middle; }
.tier-remove {
  background: none; border: 0; cursor: pointer; padding: 0;
  color: var(--danger-700); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold);
}
.tier-remove:hover { text-decoration: underline; }
.tier-add { margin-top: var(--space-3); }

/* ============================================================
   Auth screens (login / verify / lockout) — centered card
   ============================================================ */
body.auth-body .main { flex: 1; }
body.auth-body .content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}
.auth-card {
  width: 380px;
  max-width: 100%;
  padding: var(--space-7);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.auth-card .auth-logo { height: 30px; display: block; margin-bottom: var(--space-6); }
.auth-card h1 { font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--text-strong); margin: 0 0 var(--space-5); }

/* ============================================================
   Responsive: collapse the sidebar to an icon rail
   ============================================================ */
@media (max-width: 860px) {
  .sidebar { width: 68px; padding-left: var(--space-2); padding-right: var(--space-2); }
  .sidebar-brand { justify-content: center; padding: var(--space-1) 0 var(--space-5); }
  .sidebar-brand .brand-full { display: none; }
  .sidebar-brand .brand-mark { display: block; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item span { display: none; }
  /* On the icon rail a sub-item is just its icon, so the indent and the chevron
     (which would have nothing left to align to) go away. */
  .nav-group .chevron { display: none; }
  .nav-sub { margin-left: 0; }
  .user-chip { justify-content: center; }
  .user-meta { display: none; }
  .topbar, .content { padding-left: var(--space-5); padding-right: var(--space-5); }
}

/* ============================================================
   Dashboard (Ana Sayfa): KPI stat cards, panel grid, distribution bars
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5) var(--space-6);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-value {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  line-height: 1.1;
  color: var(--text-strong);
}
/* Revenue cards only: a grouped amount with a ₺ suffix overflows a quarter-width card at
   the 4xl count size, so money steps down a scale and is allowed to break. */
.stat-money { font-size: var(--text-2xl); overflow-wrap: anywhere; }
.stat-sub { font-size: var(--text-xs); color: var(--text-subtle); }

/* Two-column layout for the lower panels; collapses at the sidebar breakpoint. */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5) var(--space-6);
  align-items: start;
}
.dashboard-grid > section { min-width: 0; }
.dashboard-grid .section-header { margin-top: var(--space-7); }

.section-actions { display: flex; align-items: center; gap: var(--space-3); }
.see-all { font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; }

/* Status / billing distribution rows: label · bar · count. */
.breakdown { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.breakdown-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: var(--space-4); }
.breakdown-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-strong); }
.breakdown-count { font-size: var(--text-sm); color: var(--text-muted); text-align: right; min-width: 2ch; }
/* Native <progress> styled as a slim track — proportion comes from value/max
   attributes, so no inline styles are needed (CSP-safe). */
.breakdown-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}
.breakdown-bar::-webkit-progress-bar { background: var(--surface-sunken); border-radius: var(--radius-pill); }
.breakdown-bar::-webkit-progress-value { background: var(--brand); border-radius: var(--radius-pill); }
.breakdown-bar::-moz-progress-bar { background: var(--brand); border-radius: var(--radius-pill); }

@media (max-width: 1040px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .breakdown-row { grid-template-columns: 96px 1fr auto; gap: var(--space-3); }
}

/* Hidden inline icon sprite: pulled out of layout flow via a class (not an inline
   style attribute) so the enforced CSP's style-src can stay strict — no 'unsafe-inline'. */
.icon-sprite { position: absolute; }

/* ============================================================
   Customer history: section figures, signed change, row actions,
   segmented add/remove toggle, modals, pagination
   ============================================================ */
.section-head-left { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }

/* Current-total figure beside a section heading (and in the list-page topbar). */
.metric-pill {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 5px 13px; border-radius: var(--radius-pill);
  background: var(--surface-brand-subtle); color: var(--green-800);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.metric-pill b { font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: 1; }
.metric-pill span {
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  text-transform: uppercase; letter-spacing: var(--tracking-caps); opacity: .85;
}

/* Signed unit change in the mono column. */
.change-pos { color: var(--success-700); font-weight: var(--weight-semibold); }
.change-neg { color: var(--danger-700); font-weight: var(--weight-semibold); }

/* Right-align numeric table columns (counts, unit totals). */
th.num, td.num { text-align: right; }

/* Per-row action buttons use the generic .btn.sm variants; just lay them out. */
.row-actions { display: flex; gap: var(--space-2); justify-content: flex-end; white-space: nowrap; }

.see-all-row { margin: var(--space-3) 0 0; }

/* Segmented Ekle / Çıkar toggle (a radio group styled as a switch). */
.segmented {
  display: inline-flex; width: 100%;
  background: var(--surface-sunken); border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 3px; gap: 3px;
}
.segmented label { flex: 1; margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
  display: flex; align-items: center; justify-content: center; padding: 8px 0;
  border-radius: 7px; font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--text-muted);
  transition: background var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast);
}
.segmented input:checked + span { background: var(--surface-card); box-shadow: var(--shadow-xs); color: var(--text-strong); }
.segmented input[value="add"]:checked + span { color: var(--success-700); }
.segmented input[value="remove"]:checked + span { color: var(--danger-700); }
.segmented input:focus-visible + span { box-shadow: var(--ring); }

/* Modal dialog (native <dialog>) — matches the design mock: one clean surface,
   no internal dividers, a borderless action row. */
dialog.modal {
  border: none; padding: 0; margin: auto;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: min(440px, calc(100vw - 32px));
  background: var(--surface-card); color: var(--text-body);
}
dialog.modal::backdrop { background: rgba(19, 20, 23, .45); }
dialog.modal[open] { animation: modal-in var(--duration-base) var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: var(--space-6) var(--space-6) 0; }
.modal-head h3 { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--text-strong); letter-spacing: var(--tracking-snug); }
.modal-head p { margin: 6px 0 0; color: var(--text-muted); font-size: var(--text-sm); }
.modal-body { padding: var(--space-5) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.modal-body .form-row { margin: 0; }
.modal-foot { padding: var(--space-4) var(--space-6) var(--space-6); display: flex; justify-content: flex-end; gap: var(--space-3); }
.confirm-record {
  padding: 11px 15px; background: var(--surface-sunken);
  border: var(--border-width) solid var(--border-subtle); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--text-sm); color: var(--text-strong);
}
@media (prefers-reduced-motion: reduce) {
  dialog.modal[open] { animation: none; }
  .segmented span { transition: none; }
}

/* History full-list pagination. */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-4); margin-top: var(--space-5); }
.page-info { font-size: var(--text-sm); color: var(--text-muted); }

/* ============================================================
   Contact people (customer detail, right-hand panel)
   ============================================================ */
/* The two top-row columns each open with a section header, so their cards align. */
.detail-top .section-header { margin-top: 0; }
/* That zeroed top margin also kills the gap under the KPI row the page opens with —
   restore what the dashboard gets from its own section spacing. */
.stat-grid + .detail-top { margin-top: var(--space-7); }
/* The global 200px label column is too wide at half width. */
.detail-top dl { grid-template-columns: 140px 1fr; }

.contact-list { padding: 0; }
.contact-row { padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: 3px; }
.contact-row + .contact-row { border-top: var(--border-width) solid var(--border-subtle); }
.contact-row.passive { background: var(--surface-sunken); }
.contact-row.passive .contact-name { color: var(--text-muted); }

.contact-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.contact-name { font-weight: var(--weight-semibold); color: var(--text-strong); }
.contact-head .row-actions { margin-left: auto; }
.contact-role { font-size: var(--text-sm); color: var(--text-muted); }
.contact-reach { font-size: var(--text-sm); color: var(--text-body); }

/* Notes are clamped so one wordy record can't dominate the panel; a click
   (customer_history.js) adds .expanded to release the clamp. */
.contact-note {
  font-size: var(--text-sm); color: var(--text-muted); cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.contact-note.expanded { -webkit-line-clamp: unset; overflow: visible; }

/* Reveals the passive rows in place, without a round-trip. */
.contact-toggle {
  width: 100%; padding: 11px var(--space-5); border: 0;
  border-top: var(--border-width) solid var(--border-subtle);
  background: transparent; cursor: pointer; text-align: left;
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--text-muted);
}
.contact-toggle:hover { color: var(--text-strong); background: var(--surface-sunken); }

/* Consequence notices: an unset primary above the list, and the pre-save warnings
   inside the contact / delete-confirm dialogs. */
.panel-warning, .modal-warning {
  margin: 0 0 var(--space-3); padding: 9px 13px; border-radius: var(--radius-md);
  background: var(--warning-bg); color: var(--warning-700);
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
}
.modal-warning { margin: var(--space-2) 0 0; }
.is-hidden { display: none; }

/* Checkbox rows read as one line, unlike the stacked label+input default. */
label.check { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }

.segmented input[value="passive"]:checked + span { color: var(--text-muted); }

/* ============================================================
   Reports: the customer × month revenue matrix
   ============================================================ */
/* A column per month, so the grid outgrows the page on any range worth reporting.
   The card scrolls sideways with the customer column pinned — without it a row loses
   its name a few months in. Kept on the card (not the table) so the sticky cells have
   a scroll container to stick to. */
.report-table { overflow-x: auto; }
.report-table table { width: max-content; min-width: 100%; }
.report-table th:first-child, .report-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface-card);
  /* A drawn shadow rather than a border: under border-collapse a sticky cell's own
     border is not guaranteed to travel with it, so the divider could vanish on scroll. */
  box-shadow: 1px 0 0 var(--border-subtle);
}
/* The pinned cell carries its own background, so it would otherwise sit out the
   row-hover tint and the header/footer shading that the rest of the row gets. */
.report-table thead th:first-child { background: var(--surface-sunken); }
.report-table tbody tr:hover td:first-child { background: var(--surface-hover); }
.report-table tfoot td {
  background: var(--surface-sunken);
  border-top: var(--border-width) solid var(--border-subtle);
  border-bottom: 0;
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
}
.report-table tfoot td:first-child { background: var(--surface-sunken); }
/* Figures are long (12 columns of "125.480,50 ₺"); keep each on one line. */
.report-table td.num, .report-table th.num { white-space: nowrap; }
