/* ============================================================
   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; }

/* A grid rather than flex: equal side tracks put the middle one (the customer search)
   on the bar's true center on every page, whatever the title and actions weigh. */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  min-height: var(--topbar-height);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  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);
  /* Lets the open search box cap itself at the bar's width (100cqw) on narrow windows. */
  container-type: inline-size;
}
.topbar-heading { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* Long customer names wrap once, then clip with "…"; topbar.js puts the full title in a
   tooltip when that happens. Snug leading, not tight: at 1.15 the dots of an İ/Ö/Ü on
   the hidden third line rise out of their line box and poke up under the clamp. */
.topbar-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-snug);
  line-height: var(--leading-snug);
  color: var(--text-strong);
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.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 { justify-self: end; display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }

/* ============================================================
   Top-bar customer search (topbar.js)
   ============================================================ */
/* The grid track only ever reserves the collapsed pill. The box is absolutely centered
   on it, so opening it overlays the title and actions instead of reflowing them. */
.topbar-search { position: relative; width: 76px; height: 40px; }
.ts-box {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 1;
  width: 76px;
  height: 40px;
  transform: translateX(-50%);
  transition: width var(--duration-base) var(--ease-out);
}
.topbar-search.is-open .ts-box { z-index: var(--z-dropdown); width: min(640px, 100cqw); }
/* The input is the whole box, so a click anywhere on the pill focuses it; the icon and
   the key hint sit on top and let clicks through. */
.topbar-search input[type=search] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0 var(--space-3) 0 40px;
  cursor: pointer;
}
.topbar-search input[type=search]:hover { border-color: var(--border-strong); }
.topbar-search.is-open input[type=search] { cursor: text; border-color: var(--border-focus); box-shadow: var(--ring); }
.topbar-search input::placeholder { color: transparent; }
.topbar-search.is-open input::placeholder { color: var(--text-subtle); }
.ts-icon { position: absolute; top: 11px; left: 12px; width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
.ts-kbd { position: absolute; top: 10px; right: 10px; pointer-events: none; }
/* Inside the open box "s" types a letter, so the hint would be wrong there. */
.topbar-search.is-open .ts-kbd { display: none; }
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-xs);
}

.ts-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  padding: var(--space-1);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.ts-list { list-style: none; margin: 0; padding: 0; }
.ts-option a {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
}
.ts-option a:hover { color: var(--text-strong); text-decoration: none; }
/* The row Enter will open wears the active-nav tint. */
.ts-option.is-active a { background: var(--surface-brand-subtle); color: var(--green-800); }
.ts-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ts-name strong, .ts-tax strong { font-weight: var(--weight-bold); }
.ts-tax {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.ts-option.is-active .ts-tax { color: var(--green-700); }
.ts-foot { margin: 0; padding: 8px var(--space-3) 6px; font-size: var(--text-xs); color: var(--text-muted); }
.ts-foot:empty { display: none; }
.ts-list:not(:empty) + .ts-foot { margin-top: var(--space-1); border-top: var(--border-width) solid var(--border-subtle); }

.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[type=datetime-local],
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); }

/* ============================================================
   Four-part detail card (customer info) and its form twin

   One card cut into an upper band, two middle columns and a lower band, divided by
   hairlines rather than gaps so it still reads as a single panel. Free-text values
   (address, notes) take the full width in the bands; the short paired values sit in
   the middle columns. The card supplies no padding of its own — each part does, so
   the dividers run edge to edge.
   ============================================================ */
.info-card,
.form-grid { display: grid; grid-template-columns: 1fr 1fr; }
.info-card { padding: 0; }
.info-card > div,
.form-grid > div { padding: var(--space-5) var(--space-6); min-width: 0; }
.info-upper, .info-lower,
.fs-upper, .fs-lower { grid-column: 1 / -1; }
.info-upper, .info-mid-left, .info-mid-right,
.fs-upper, .fs-mid-left, .fs-mid-right {
  border-bottom: var(--border-width) solid var(--border-subtle);
}
.info-mid-left,
.fs-mid-left { border-right: var(--border-width) solid var(--border-subtle); }
/* Narrower than the global 200px, since the card is itself a column of the top row.
   The two full-width bands share a value so their labels line up down the card; the
   middle pair goes narrower again to buy back width in half the space. */
.info-upper dl,
.info-lower dl { grid-template-columns: 175px 1fr; }
.info-mid-left dl,
.info-mid-right dl { grid-template-columns: 145px 1fr; }

/* The parts own the padding, so the last control in each must not add trailing space. */
.form-grid > div > p:last-child,
.form-grid > div > .form-row:last-child { margin-bottom: 0; }
/* .actions sits outside .form-grid and so needs the padding the parts give themselves. */
.form-card-wide { padding: 0; max-width: none; }
.form-card-wide .actions { margin-top: 0; padding: var(--space-5) var(--space-6); }
/* Form-wide errors sit outside .form-grid too, above it. */
.form-card-wide > form > .errorlist { margin: var(--space-5) var(--space-6) 0; }

/* ============================================================
   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,
  .info-card,
  .form-grid { grid-template-columns: 1fr; }
  /* Stacked, the vertical rule would cut across the card instead of between columns. */
  .info-mid-left,
  .fs-mid-left { border-right: 0; }
}
@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; }
  .ts-box { 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); }
/* Weighted 60/40 rather than the even .dashboard-grid split: the info card carries two
   inner columns and needs the extra width, while the contact list stays one column
   whatever it is given. */
.detail-top { grid-template-columns: 3fr 2fr; }
/* Must follow the rule above, not join the shared 860px block earlier in this file:
   both selectors are one class, so source order decides and the ratio would otherwise
   win at every width. */
@media (max-width: 860px) {
  .detail-top { grid-template-columns: 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; }

/* ============================================================
   Billing: the invoice line editor, invoice totals, status bar,
   master-detail invoice rows and the uncovered-period warning
   ============================================================ */

/* Visually hidden but read aloud — the icon-only row toggles and delete checkboxes
   have no visible text of their own. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Invoice form: header bands ------------------------------------------- */
.invoice-head, .invoice-fields, .invoice-lines {
  padding: var(--space-5) var(--space-6);
  border-bottom: var(--border-width) solid var(--border-subtle);
}
.invoice-head-facts { grid-template-columns: 145px 1fr; }
.field-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 var(--space-4); }
.field-grid > .field { margin: 0 0 var(--space-4); min-width: 0; }
.field-wide { grid-column: 1 / -1; }
/* The section heading opens a band that already supplies its own top padding. */
.section-header-flush { margin-top: 0; }
.line-hint { margin: var(--space-3) 0 0; max-width: 82ch; }

/* --- Invoice form: the line table ----------------------------------------- */
/* One row per line rather than a stack of cards: column headers name each field once
   instead of once per row, which is what keeps a five-line invoice on one screen.
   Same borderless-table-of-inputs idiom as .tier-table above. */
.line-scroll { overflow-x: auto; padding-bottom: var(--space-1); }
.line-table { width: 100%; min-width: 1010px; border-collapse: collapse; background: transparent; }
.line-table th {
  background: none; text-align: left; white-space: nowrap;
  padding: 0 var(--space-2) var(--space-2) 0;
  border-bottom: var(--border-width) solid var(--border-subtle);
  font-size: var(--text-2xs);
}
.line-table th.num { text-align: right; }
.line-table td { padding: 6px var(--space-2) 6px 0; border: 0; vertical-align: middle; }
.line-table tbody tr:hover { background: transparent; }
.line-table input, .line-table select {
  height: 36px; font-size: var(--text-sm); padding: 0 var(--space-2); box-shadow: none;
}
.line-table .errorlist { font-size: var(--text-xs); }
.line-table td.amount {
  text-align: right; white-space: nowrap; color: var(--text-strong);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold); font-size: var(--text-sm);
}
/* Column widths: everything fixed except Açıklama, which absorbs the remainder. */
.col-type { width: 118px; } .col-pid { width: 80px; } .col-date { width: 132px; }
.col-qty { width: 82px; } .col-price { width: 108px; } .col-vat { width: 62px; }
.col-amount { width: 112px; } .col-x { width: 38px; }
/* A manual row bills a thing, not a stretch of time: invoice_lines.js hides the two
   date inputs and the dash below takes their place, so the columns still line up. */
.line-table td.period-cell.no-period { text-align: center; color: var(--text-subtle); font-size: var(--text-sm); }
.line-table td.period-cell.no-period::after { content: "—"; }
/* Type stripe on the leading cell — reads the line's kind without a colour legend. */
.line-table td.tip-cell { border-left: 3px solid var(--neutral-300); padding-left: var(--space-2); }
.line-row.t-service td.tip-cell { border-left-color: var(--green-500); }
.line-row.t-sms     td.tip-cell { border-left-color: var(--info-500); }
.line-row.t-email   td.tip-cell { border-left-color: var(--warning-500); }
.line-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-xs);
  background: none; color: var(--danger-700); cursor: pointer;
}
.line-remove:hover { background: var(--danger-bg); }
.line-remove .icon { width: 15px; height: 15px; }
/* A saved row is retired through the formset's DELETE flag, not removed from the DOM. */
.delete-check { display: inline-flex; margin: 0; cursor: pointer; }
.delete-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--danger-500); }
.line-row.pending-delete { opacity: 0.45; }
.line-add { margin-top: var(--space-3); }

/* --- Invoice totals ------------------------------------------------------- */
.totals { display: flex; justify-content: flex-end; margin-top: var(--space-5); }
.totals-inner { width: 340px; max-width: 100%; display: flex; flex-direction: column; }
.tot-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-5);
  padding: 9px 0; border-bottom: var(--border-width) solid var(--border-subtle);
  font-size: var(--text-sm); color: var(--text-muted);
}
.tot-row b {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--text-md); color: var(--text-strong); font-weight: var(--weight-semibold);
}
.tot-row.grand {
  border-bottom: 0; border-top: 2px solid var(--neutral-300); margin-top: 2px;
  padding-top: var(--space-3); color: var(--text-strong); font-weight: var(--weight-semibold);
}
.tot-row.grand b { font-size: var(--text-2xl); font-weight: var(--weight-bold); }

/* Invoice detail: totals in the table foot, each under the column it sums. Miktar,
   Birim Fiyat and KDV % are left without a foot on purpose — adding up mixed units,
   unit prices or tax rates would print a number that means nothing. */
tfoot td {
  background: var(--surface-sunken); color: var(--text-strong);
  font-weight: var(--weight-semibold); border-bottom: 0;
  border-top: var(--border-width) solid var(--border-default);
}
tfoot td.tf-label {
  color: var(--text-muted); font-size: var(--text-xs);
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
}
tfoot td.tf-grand { font-size: var(--text-lg); font-weight: var(--weight-bold); }

/* --- Invoice detail: status bar ------------------------------------------- */
/* Every transition is legal, so this is a button per status the invoice is not in.
   Each is its own POST form, hence the flex row of forms rather than of buttons. */
.status-bar {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5);
  background: var(--surface-card); border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.status-bar .sb-label {
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted);
}
.status-bar .sb-actions { margin-left: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.status-bar form { margin: 0; }

/* --- Master-detail invoice rows (customer detail) -------------------------- */
/* The lines ship with the page and hide behind .is-hidden, so expanding costs no
   round trip; customer_history.js does the class toggle. */
th.toggle-cell, td.toggle-cell { width: 44px; padding-right: 0; }
.row-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.row-toggle:hover { background: var(--surface-active); color: var(--text-strong); }
.row-toggle .chev { transition: transform var(--duration-fast) var(--ease-standard); }
.row-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.row-toggle[aria-expanded="true"] { color: var(--green-700); }
/* The panel row carries its own ground and must sit out the row-hover tint, or the
   nested table would flash as the pointer crosses it. */
tr.lines-row > td { padding: 0; background: var(--surface-sunken); }
tr.lines-row:hover > td { background: var(--surface-sunken); }
.lines-panel { padding: var(--space-4) var(--space-5) var(--space-5); }
.lines-panel h4 {
  margin: 0 0 var(--space-3); font-size: var(--text-xs); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted);
}
.lines-table {
  background: var(--surface-card); border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md); overflow: hidden; overflow-x: auto;
}
.lines-table table { font-size: var(--text-sm); }
.lines-table th, .lines-table td { padding: var(--space-2) var(--space-3); }
.lines-table th { font-size: var(--text-2xs); }

/* Which of the two sources set a billing anchor — the customer's own seed, or the
   invoice that carried it further. Sits inline after the figure, in the body font so
   it reads as a note rather than part of the mono value. */
.anchor-source {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: var(--space-1);
  white-space: nowrap;
}

/* --- Uncovered-period warning --------------------------------------------- */
/* Same warning surface as .panel-warning, but each skipped period gets its own row so
   the ranges line up in a column when there are several. */
.gap-warning {
  background: var(--warning-bg); color: var(--warning-700);
  border-radius: var(--radius-md); padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}
.gap-head {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); font-weight: var(--weight-bold); margin-bottom: var(--space-3);
}
.gap-head .icon { width: 17px; height: 17px; }
.gap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.gap-list li { display: grid; grid-template-columns: 96px 1fr; align-items: baseline; gap: var(--space-4); font-size: var(--text-sm); }
.gap-stream { font-weight: var(--weight-semibold); }
.gap-range {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold); color: var(--neutral-900);
}

@media (max-width: 1180px) {
  .field-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .gap-list li { grid-template-columns: 1fr; gap: 2px; }
}

/* ============================================================
   Invoicing planner (Fatura Planı) and what it touches: the
   prepared invoice's notice and calculation basis, the customer
   card's usage status and planner row, the contract fee hint
   ============================================================ */

/* Generic: a disabled button reads as disabled (the planner greys out Hazırla while an import is pending, the invoice page greys out Kes). */
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn:disabled:hover { background: var(--brand); }
.btn.secondary:disabled:hover { background: var(--surface-card); }
.table-scroll { overflow-x: auto; }
.badge.plain::before { display: none; }

/* Section heading count + one-line lede under it. */
.h-count {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-md);
  font-weight: var(--weight-semibold); color: var(--text-muted);
}
.section-lede { margin: calc(-1 * var(--space-2)) 0 var(--space-4); max-width: 92ch; font-size: var(--text-sm); color: var(--text-muted); }

/* --- Fatura Planı: import banner ------------------------------------------ */
.plan-banner {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5); margin-bottom: var(--space-5);
  background: var(--warning-bg); color: var(--warning-700); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
}
.plan-banner > .icon { width: 18px; height: 18px; }
/* Nothing is waiting on the import: the same line, as information rather than a warning. */
.plan-banner.quiet { background: var(--surface-sunken); color: var(--text-muted); }
.plan-banner .banner-text { flex: 1; min-width: 220px; }
.plan-banner .fig { color: var(--neutral-900); }
.plan-banner .btn { background: var(--surface-card); color: var(--text-strong); border-color: color-mix(in srgb, var(--warning-500) 35%, transparent); }

/* --- Fatura Planı: jump strip (summary before detail) ----------------------- */
.plan-jump { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.plan-jump a {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 34px; padding: 0 var(--space-3) 0 6px;
  border: var(--border-width) solid var(--border-subtle); border-radius: var(--radius-pill);
  background: var(--surface-card); box-shadow: var(--shadow-xs);
  color: var(--text-body); font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap;
}
.plan-jump a:hover { text-decoration: none; color: var(--text-strong); border-color: var(--border-default); }
.plan-jump .count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--text-strong);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.plan-jump .j-due .count { background: var(--brand); color: var(--brand-contrast); }
.plan-jump .j-attention .count { background: var(--warning-bg); color: var(--warning-700); }
.plan-jump .j-kolaybi .count { background: var(--info-bg); color: var(--info-700); }

/* --- Fatura Planı: table cells ---------------------------------------------- */
.plan-table td { vertical-align: top; }
.plan-table td.act { text-align: right; white-space: nowrap; vertical-align: middle; width: 1%; }
/* A confirm dialog is declared inside its row's cell but shown in the top layer, so it must
   not inherit the cell's right-aligned, non-wrapping text. */
.plan-table dialog.modal { text-align: left; white-space: normal; }
.cust { font-weight: var(--weight-semibold); color: var(--text-strong); }
a.cust:hover { color: var(--text-brand); }
.cell-sub { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--weight-regular); }
.fig { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.period-stack { display: flex; flex-direction: column; gap: 3px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-sm); white-space: nowrap; }
.lt-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.lt {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 6px;
  border-radius: var(--radius-xs); background: var(--surface-sunken);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-body); white-space: nowrap;
}
/* Same type colours as the invoice line editor's stripe (.line-row.t-*). */
.lt::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--neutral-300); }
.lt.t-service::before { background: var(--green-500); }
.lt.t-sms::before { background: var(--info-500); }
.lt.t-email::before { background: var(--warning-500); }
.lt .x { font-family: var(--font-mono); color: var(--text-muted); }
.amount-cell { text-align: right; white-space: nowrap; }
.amount-cell .fig { font-size: var(--text-md); color: var(--text-strong); }
.wait-note { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--warning-700); white-space: nowrap; }
.wait-note .icon { width: 14px; height: 14px; }
tr.is-waiting .cust { color: var(--text-body); }
.row-flag { display: inline-flex; margin-top: 4px; }

/* --- Planlayıcıdaki Müşteriler ----------------------------------------------- */
/* The Fatura Planı header's customer count links here. */
.topbar-sub a { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.topbar-sub a:hover { color: var(--text-brand); text-decoration-style: solid; }
/* Seventeen columns outgrow any screen, so the card scrolls sideways with the customer
   pinned, as .report-table does. Pinned by a .pin class, not :first-child: under the
   two-row grouped header the second row's first cell is "Cari ID". */
.roster-table { overflow-x: auto; }
.roster-table table { width: max-content; min-width: 100%; font-size: var(--text-sm); }
.roster-table th, .roster-table td { padding: var(--space-2) var(--space-3); white-space: nowrap; }
.roster-table td { vertical-align: top; }
.roster-table th.grp, .roster-table td.grp { border-left: var(--border-width) solid var(--border-subtle); }
.roster-table thead tr:first-child th[colspan] { color: var(--text-strong); border-bottom-color: var(--border-default); }
.roster-table .pin {
  position: sticky; left: 0; z-index: 1; min-width: 250px; max-width: 320px; white-space: normal;
  background: var(--surface-card);
  /* A drawn divider, as on .report-table: a sticky cell's own border may not travel with it. */
  box-shadow: 1px 0 0 var(--border-subtle);
}
.roster-table thead .pin { z-index: 2; background: var(--surface-sunken); }
.roster-table tbody tr:hover .pin { background: var(--surface-hover); }
.roster-table .missing { color: var(--warning-700); font-weight: var(--weight-semibold); }
.roster-table .dim { color: var(--text-muted); }
.roster-table .unbilled { color: var(--warning-700); font-weight: var(--weight-semibold); }
.roster-table td.unbilled-cell { white-space: normal; min-width: 11rem; max-width: 22rem; }
.roster-table .cell-sub a { color: var(--text-muted); }
.roster-table .cell-sub a:hover { color: var(--text-brand); }

/* --- Fatura Planı: flags ------------------------------------------------------ */
.flag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.flag-list li { display: grid; grid-template-columns: 16px 1fr; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-body); max-width: 78ch; }
.flag-list .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--warning-500); }
.flag-kind { display: block; font-weight: var(--weight-bold); color: var(--text-strong); }
.flag-list .fig { color: var(--neutral-900); }

/* Numbers still missing on a Draft. */
.num-pair { display: grid; grid-template-columns: auto auto; gap: 2px var(--space-3); font-size: var(--text-xs); }
.num-pair dt { font-size: var(--text-xs); }
.num-pair dd { font-family: var(--font-mono); font-size: var(--text-xs); }
.num-pair dd.missing { color: var(--warning-700); font-family: var(--font-sans); font-weight: var(--weight-semibold); }
.num-pair { margin: 0; }

.info-hint {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; padding: 3px 8px;
  border-radius: var(--radius-xs); background: var(--info-bg); color: var(--info-700);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.info-hint .icon { width: 13px; height: 13px; }
.info-hint a { color: inherit; text-decoration: underline; }

/* --- Fatura Planı: not-on-planner groups -------------------------------------- */
.plan-groups { display: flex; flex-direction: column; gap: var(--space-3); }
.plan-group > summary {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-4) var(--space-5); cursor: pointer; list-style: none;
}
.plan-group > summary::-webkit-details-marker { display: none; }
.plan-group > summary:hover { background: var(--surface-hover); }
.plan-group > summary:focus-visible { outline: none; box-shadow: inset var(--ring); }
.plan-group[open] > summary { border-bottom: var(--border-width) solid var(--border-subtle); }
.plan-group .chevron { width: 16px; height: 16px; color: var(--text-muted); transition: transform var(--duration-fast) var(--ease-standard); }
.plan-group[open] .chevron { transform: rotate(90deg); }
.group-title { font-weight: var(--weight-bold); color: var(--text-strong); }
.group-desc { flex-basis: 100%; margin-left: 28px; font-size: var(--text-xs); color: var(--text-muted); }
@media (min-width: 900px) { .group-desc { flex-basis: auto; margin-left: auto; } }
.more-row td { color: var(--text-muted); font-size: var(--text-sm); text-align: center; }

/* --- Prepared invoice ----------------------------------------------------------- */
.prep-notice {
  display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-5);
  padding: var(--space-4) var(--space-5); border-radius: var(--radius-md);
  background: var(--surface-brand-subtle); color: var(--green-800); font-size: var(--text-sm);
}
.prep-notice > .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--green-700); }
.prep-notice b { color: var(--green-900); }
.basis { padding: var(--space-5) var(--space-6); border-bottom: var(--border-width) solid var(--border-subtle); background: var(--neutral-50); }
.basis > summary { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; list-style: none; }
.basis > summary::-webkit-details-marker { display: none; }
.basis > summary h2 { font-size: var(--text-md); }
.basis > summary .chevron { width: 16px; height: 16px; color: var(--text-muted); transition: transform var(--duration-fast) var(--ease-standard); }
.basis[open] > summary .chevron { transform: rotate(90deg); }
.basis-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: grid; grid-template-columns: max-content max-content 1fr; gap: var(--space-2) var(--space-4); align-items: baseline; font-size: var(--text-sm); }
.basis-list li { display: contents; }
.basis-list .per { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-strong); white-space: nowrap; }
.basis-list .why.none { color: var(--text-subtle); }
.basis-foot { margin: var(--space-4) 0 0; font-size: var(--text-xs); color: var(--text-muted); }
@media (max-width: 640px) {
  .basis-list { grid-template-columns: 1fr; gap: 2px; }
  .basis-list .why { margin-bottom: var(--space-2); }
}
.status-bar .sb-hint { flex-basis: 100%; font-size: var(--text-xs); color: var(--text-muted); text-align: right; }

/* --- Customer detail: usage status + planner state ------------------------------ */
.usage-status { display: block; margin-top: 3px; font-family: var(--font-sans); font-size: var(--text-xs); color: var(--text-muted); }
.usage-status.unbilled { color: var(--warning-700); font-weight: var(--weight-semibold); }
.usage-status .fig { font-weight: var(--weight-semibold); }
.planner-state { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-family: var(--font-sans); }
.planner-state .since { font-size: var(--text-xs); color: var(--text-muted); }
.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--danger-700);
}
.link-btn:hover { text-decoration: underline; }
.gap-list li.with-count { grid-template-columns: 96px max-content 1fr; }
/* The planner's warnings on the customer card: the gap box's surface, the planner's
   flag list inside. */
.planner-warning {
  background: var(--warning-bg); border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5); margin-bottom: var(--space-4);
}
.planner-warning .gap-head { color: var(--warning-700); }
.planner-warning .flag-list li { max-width: none; }
.gap-count { font-weight: var(--weight-semibold); }
@media (max-width: 640px) { .gap-list li.with-count { grid-template-columns: 1fr; } }

/* --- Contract form: fee ---------------------------------------------------------- */
.fee-net { display: block; margin-top: var(--space-1); font-size: var(--text-xs); color: var(--text-muted); }
.fee-net b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-strong); font-weight: var(--weight-semibold); }

@media (prefers-reduced-motion: reduce) {
  .plan-group .chevron, .basis > summary .chevron { transition: none; }
}

/* Sticky topbar would cover a jumped-to section heading. */
[id^="sec-"] { scroll-margin-top: 90px; }

/* The "Görüldü" button sits at the end of its flag's text rather than in the action column,
   since one customer can carry several changed counts. */
.review-btn { margin-left: var(--space-2); vertical-align: middle; }

/* ============================================================
   WhatsApp inbox (whatsapp app)
   ============================================================ */
/* Sidebar unread count. Not a span: every span in a nav item stretches (flex: 1) and is
   hidden on the icon rail, while the count keeps its size there and turns into a dot. */
.nav-item.has-count { position: relative; }
.nav-item .nav-count {
  flex: 0 0 auto; min-width: 22px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--brand); color: var(--brand-contrast);
  font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: var(--weight-bold); line-height: 1;
}
@media (max-width: 860px) {
  .nav-item .nav-count {
    display: block; position: absolute; top: 7px; right: 12px;
    min-width: 0; width: 10px; height: 10px; padding: 0; font-size: 0;
    border: 2px solid var(--surface-card);
  }
}
.topbar-actions form { margin: 0; }

/* Two panes in one card, each scrolling on its own so the list header and the compose box
   stay put. Height = viewport minus the topbar and the content's own padding; the extra
   space-2 is the topbar outgrowing --topbar-height once its two-line heading is in. */
.wa-inbox {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: calc(100vh - var(--topbar-height) - var(--space-2) - var(--space-7) - var(--space-9));
  min-height: 520px;
  padding: 0;
  overflow: hidden;
}
.wa-list { display: flex; flex-direction: column; min-height: 0; border-right: var(--border-width) solid var(--border-subtle); }
.wa-list-head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: var(--border-width) solid var(--border-subtle);
}
.wa-list-head h2 { font-size: var(--text-md); }
.wa-list-head .h-count { font-size: var(--text-sm); }
.wa-convs { list-style: none; margin: 0; padding: var(--space-2); flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.wa-conv {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-md); color: var(--text-body);
}
.wa-conv:hover { background: var(--surface-hover); color: var(--text-body); text-decoration: none; }
.wa-conv.is-active { background: var(--surface-brand-subtle); }
.wa-conv:focus-visible { outline: none; box-shadow: var(--ring); }
.wa-avatar {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-circle);
  background: var(--green-100); color: var(--green-800);
  font-size: var(--text-sm); font-weight: var(--weight-bold); user-select: none;
}
/* Unmatched senders stay grey, so a known contact stands out in the list at a glance. */
.wa-avatar.unknown { background: var(--surface-sunken); color: var(--text-muted); }
.wa-conv-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.wa-conv-top, .wa-conv-bottom { display: flex; align-items: center; gap: var(--space-2); }
.wa-conv-name { flex: 1; min-width: 0; font-weight: var(--weight-semibold); color: var(--text-strong); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wa-conv-time { flex: 0 0 auto; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-muted); }
.wa-conv-sub { font-size: var(--text-xs); color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wa-conv-preview { flex: 1; min-width: 0; font-size: var(--text-sm); color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wa-conv.is-unread .wa-conv-time { color: var(--text-brand); font-weight: var(--weight-semibold); }
.wa-conv.is-unread .wa-conv-preview { color: var(--text-strong); font-weight: var(--weight-medium); }
.wa-unread {
  flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--brand); color: var(--brand-contrast);
  font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: var(--weight-bold);
}

.wa-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.wa-thread-head {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-5);
  border-bottom: var(--border-width) solid var(--border-subtle);
}
.wa-back { display: none; }
.wa-who { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.wa-who-name { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--text-strong); letter-spacing: var(--tracking-snug); }
.wa-profile { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-muted); letter-spacing: 0; }
.wa-who-meta { font-size: var(--text-sm); color: var(--text-muted); }
/* One line for the name: several people on one number would otherwise stack their names. */
.wa-who-title { min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wa-more { display: inline; }
.wa-more summary { display: inline; cursor: pointer; color: var(--text-brand); font-weight: var(--weight-semibold); }
.wa-more summary::-webkit-details-marker { display: none; }
.wa-more summary::before { content: " · "; color: var(--text-muted); font-weight: var(--weight-regular); }
.wa-more[open] > div { margin-top: 2px; }
.wa-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* column-reverse around one chronological child: the box opens scrolled to the newest
   message, and a short thread sits at the bottom like a chat, with no script. */
.wa-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column-reverse;
  background: var(--surface-page);
}
.wa-scroll-inner { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5) var(--space-6); }
.wa-day {
  align-self: center; margin: var(--space-3) 0 var(--space-1); padding: 3px 10px;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle); border-radius: var(--radius-pill);
}
.wa-note { align-self: center; margin: 0; font-size: var(--text-xs); color: var(--text-muted); }
.wa-msg { display: flex; flex-direction: column; max-width: min(560px, 78%); }
.wa-msg.in { align-self: flex-start; }
.wa-msg.out { align-self: flex-end; align-items: flex-end; }
.wa-bubble {
  padding: 8px 12px 6px; border-radius: var(--radius-lg);
  color: var(--text-strong); box-shadow: var(--shadow-xs); overflow-wrap: anywhere;
}
.wa-msg.in .wa-bubble { background: var(--surface-card); border: var(--border-width) solid var(--border-subtle); border-bottom-left-radius: var(--radius-xs); }
.wa-msg.out .wa-bubble { background: var(--green-100); border: var(--border-width) solid var(--green-200); border-bottom-right-radius: var(--radius-xs); }
.wa-msg.failed .wa-bubble { background: var(--danger-bg); border-color: var(--danger-100); }
/* Line breaks in a WhatsApp message are content; keep them (the text is always escaped). */
.wa-bubble p { margin: 0; white-space: pre-wrap; }
.wa-tpl-label {
  display: flex; align-items: center; gap: 4px; margin-bottom: 4px;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--green-800);
}
.wa-tpl-label .icon { width: 13px; height: 13px; }
/* Template names are identifiers (fatura_hatirlatma): shown as typed, not uppercased. */
.wa-tpl-label .mono { text-transform: none; letter-spacing: 0; font-weight: var(--weight-medium); }
.wa-media { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-muted); }
.wa-media .icon { width: 16px; height: 16px; }
.wa-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-muted); }
.wa-tick { width: 15px; height: 15px; }
/* Blue for "read", as in WhatsApp itself — the colour the operator already reads that way. */
.wa-tick.read { color: var(--info-500); }
.wa-tick.failed { color: var(--danger-700); }
.wa-error { margin-top: 4px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--danger-700); text-align: right; }

.wa-compose {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-3); align-items: end;
  padding: var(--space-4) var(--space-5);
  border-top: var(--border-width) solid var(--border-subtle); background: var(--surface-card);
}
.wa-compose textarea { min-height: 44px; height: 44px; max-height: 160px; padding: 10px 12px; resize: vertical; }
.wa-compose-actions { display: flex; gap: var(--space-2); }
.wa-compose-actions .btn { height: 44px; }
.wa-compose-hint { grid-column: 1 / -1; margin: 0; font-size: var(--text-xs); color: var(--text-muted); }

.wa-closed {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-top: var(--border-width) solid var(--border-subtle); background: var(--surface-card);
  font-size: var(--text-sm); color: var(--text-body);
}
.wa-closed > .icon { color: var(--text-muted); }
.wa-closed > div { flex: 1; min-width: 220px; }
.wa-closed strong { color: var(--text-strong); }
.wa-closed.warn { background: var(--warning-bg); color: var(--warning-700); }
.wa-closed.warn > .icon, .wa-closed.warn strong { color: var(--warning-700); }

.wa-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-6); color: var(--text-muted); text-align: center; }
.wa-list-empty { font-size: var(--text-sm); }

/* Template dialog: wider than the 440px default, one fieldset per template, and a preview. */
dialog.modal.wide { width: min(540px, calc(100vw - 32px)); }
.wa-params { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; border: 0; min-width: 0; }
.wa-params[hidden] { display: none; }
.wa-params label .mono { color: var(--text-muted); font-weight: var(--weight-medium); }
.wa-preview {
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--surface-sunken); border: var(--border-width) solid var(--border-subtle);
  font-size: var(--text-sm); color: var(--text-strong); white-space: pre-wrap; overflow-wrap: anywhere;
}
.wa-preview-label { display: block; margin-bottom: 4px; font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
.wa-preview mark { background: var(--warning-bg); color: var(--warning-700); border-radius: 4px; padding: 0 2px; }
.wa-preview .filled { background: var(--green-100); color: var(--green-800); border-radius: 4px; padding: 0 2px; }

/* Narrow: one pane at a time — the list at /whatsapp/, the thread at /whatsapp/<pk>/. */
@media (max-width: 860px) {
  .wa-inbox { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-height) - var(--space-2) - var(--space-7) - var(--space-7)); }
  .wa-inbox.has-thread .wa-list { display: none; }
  .wa-inbox:not(.has-thread) .wa-thread { display: none; }
  .wa-list { border-right: 0; }
  .wa-back { display: inline-flex; }
}
@media (max-width: 560px) {
  .wa-scroll-inner { padding: var(--space-4) var(--space-3); }
  .wa-msg { max-width: 88%; }
  .wa-thread-head, .wa-compose, .wa-closed { padding-left: var(--space-3); padding-right: var(--space-3); }
  .topbar-actions .btn-label { display: none; }
}

/* ============================================================
   Packages and free quotas (Paketler): balance bars, warnings,
   the package-sale line type, the contract form's quota block,
   and the invoice form's billable hint
   ============================================================ */

/* Two package-sale line types: a darker stripe of the stream each one prepays. */
.lt.t-sms_package::before { background: var(--info-700); }
.lt.t-email_package::before { background: var(--warning-700); }
.line-row.t-sms_package td.tip-cell { border-left-color: var(--info-700); }
.line-row.t-email_package td.tip-cell { border-left-color: var(--warning-700); }
/* A usage stream the allowances absorbed completely, on a planner row: shown so the
   missing line reads as intended. */
.lt.covered { background: transparent; border: 1px dashed var(--border-default); color: var(--text-muted); }
.lt.covered::before { opacity: .5; }

/* Balance: what is left as a slim bar over the pool, figures around it. */
.alw-use { min-width: 160px; }
.alw-use .alw-fig { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); font-size: var(--text-sm); }
.alw-use .alw-fig b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-strong); }
.alw-use .alw-fig .cell-sub { margin-top: 0; }
.alw-bar { display: block; height: 6px; margin: 5px 0 2px; }
.alw-bar.low::-webkit-progress-value { background: var(--warning-500); }
.alw-bar.low::-moz-progress-bar { background: var(--warning-500); }
.alw-bar.empty::-webkit-progress-value { background: var(--danger-500); }
.alw-bar.empty::-moz-progress-bar { background: var(--danger-500); }
.alw-bar.idle::-webkit-progress-value { background: var(--neutral-300); }
.alw-bar.idle::-moz-progress-bar { background: var(--neutral-300); }
.kind { font-weight: var(--weight-semibold); color: var(--text-strong); white-space: nowrap; }
.kind-pkg, .kind-free { display: inline-flex; align-items: center; gap: 6px; }
.kind-pkg::before, .kind-free::before { content: ""; width: 8px; height: 8px; border-radius: 2px; }
.kind-pkg::before { background: var(--info-500); }
.kind-free::before { background: var(--green-500); border-radius: 50%; }
tr.is-ended td, tr.is-ended .kind { color: var(--text-muted); }
.lapsed { color: var(--danger-700); font-weight: var(--weight-semibold); font-size: var(--text-xs); }
.alw-table .cust-cell { min-width: 190px; }
.alw-warn td:first-child { width: 1%; white-space: nowrap; }
.alw-warn .detail { font-size: var(--text-sm); }
.alw-warn .detail .fig { color: var(--text-strong); }
.alw-warn-card { margin-bottom: var(--space-4); }
.as-of { margin: var(--space-3) 0 0; font-size: var(--text-xs); color: var(--text-muted); }
.as-of .fig { color: var(--text-body); }
.missing-note { color: var(--warning-700); font-weight: var(--weight-semibold); }
.plan-table .cust-cell { min-width: 220px; }

/* Contract form: the included-quota block. */
.quota-block { margin: 0 0 var(--space-4); padding: var(--space-4) var(--space-5); border-radius: var(--radius-md); background: var(--surface-sunken); }
.quota-block h3 { margin: 0 0 var(--space-1); font-size: var(--text-md); color: var(--text-strong); }
.quota-block > .helptext { margin: 0 0 var(--space-3); }
.quota-grid { display: grid; grid-template-columns: 80px 1fr 1fr; gap: var(--space-2) var(--space-3); align-items: center; }
.quota-grid .q-ch { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-strong); }
.quota-grid .q-head { font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
.quota-grid .q-err .errorlist { margin: 0; }

/* Package / quota forms: an info note, the edit-after-use confirm, the delete link. */
.form-note { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); border-radius: var(--radius-md); background: var(--info-bg); color: var(--info-700); font-size: var(--text-sm); }
.form-note .icon { width: 16px; height: 16px; margin-top: 2px; }
.form-note a { color: inherit; text-decoration: underline; }
.confirm-warn { padding: var(--space-4); margin: 0 0 var(--space-4); border-radius: var(--radius-md); background: var(--warning-bg); color: var(--warning-700); font-size: var(--text-sm); }
.confirm-warn p { margin: 0 0 var(--space-3); font-weight: var(--weight-semibold); }
.confirm-warn label.check { color: var(--warning-700); margin: 0; }
.seg-row { max-width: 320px; }
.segmented input[value="sms"]:checked + span, .segmented input[value="email"]:checked + span,
.segmented input[value="monthly"]:checked + span, .segmented input[value="yearly"]:checked + span { color: var(--text-strong); }
.actions .push-right { margin-left: auto; }
.btn.ghost.danger-text { color: var(--danger-700); }

/* Invoice form: the package picker and the billable hint share the description cell. */
.line-table td.desc-cell select { margin-bottom: 4px; }
.usage-hint {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: 4px;
  font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--info-700);
}
.usage-hint .hint-apply { color: var(--green-700); font-size: var(--text-xs); }

/* --- KolayBi integration ---------------------------------------------------------- */
/* "API" chip beside a status badge: the invoice went through KolayBi's API. It stays
   after cancellation, the one state whose badge alone can't say so. */
.status-cell { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.api-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-xs); border: var(--border-width) solid var(--info-100);
  background: var(--surface-card); color: var(--info-700);
  font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: .04em; white-space: nowrap;
}
.api-chip .icon { width: 11px; height: 11px; }
/* Read-only marker where an editable invoice has its Düzenle. */
.lock-note { display: inline-flex; align-items: center; gap: 4px; color: var(--text-subtle); font-size: var(--text-xs); }
.lock-note .icon { width: 13px; height: 13px; }
.topbar-actions .lock-note { font-size: var(--text-sm); }
/* Divides the KolayBi action from the status buttons in the status bar. */
.sb-sep { width: 1px; align-self: stretch; background: var(--border-subtle); margin: 0 var(--space-1); }
/* A lasting page-level notice (unknown outcome, unrecorded success, total mismatch). */
.kb-alert {
  display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-5);
  padding: var(--space-4) var(--space-5); border-radius: var(--radius-md);
  background: var(--warning-bg); color: var(--warning-700); font-size: var(--text-sm);
}
.kb-alert > .icon { width: 18px; height: 18px; margin-top: 1px; }
.kb-alert-title { display: block; font-weight: var(--weight-bold); margin-bottom: 2px; }
/* Info card: the KolayBi band sits between the middle columns and the description. */
.info-kolaybi { grid-column: 1 / -1; border-bottom: var(--border-width) solid var(--border-subtle); }
.info-kolaybi dl { grid-template-columns: 175px 1fr; }
.info-card dd.ettn { font-size: var(--text-xs); word-break: break-all; }
.kb-card-sub { font-size: var(--text-xs); color: var(--text-muted); }
.mismatch-note { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--warning-700); white-space: nowrap; }
.mismatch-note .icon { width: 13px; height: 13px; }
.amount-cell .mismatch-note { display: flex; justify-content: flex-end; }
.confirm-pair { font-size: var(--text-sm); }
/* Trace table: one row per KolayBi call, expanding to its request and response. */
.trace-table td { vertical-align: top; }
.trace-table .ep { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-body); white-space: nowrap; }
.trace-table .ep b { font-weight: var(--weight-semibold); color: var(--text-strong); margin-right: 4px; }
.trace-table .err { display: block; margin-top: 4px; font-size: var(--text-xs); color: var(--danger-700); max-width: 48ch; }
/* An unknown outcome is a caution, not a failure. */
.trace-table .err.unk { color: var(--warning-700); }
.trace-payload { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); }
.trace-payload > div { min-width: 0; }
.trace-payload h4 { margin: 0 0 var(--space-2); font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
.trace-payload pre {
  margin: 0; padding: var(--space-3) var(--space-4); max-height: 320px; overflow: auto;
  background: var(--surface-card); border: var(--border-width) solid var(--border-subtle); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.55; color: var(--text-strong); white-space: pre;
}
@media (max-width: 860px) { .trace-payload { grid-template-columns: 1fr; } }
.deleted-ref { color: var(--text-muted); font-style: italic; }
/* Fatura Planı: the two groups of KolayBi Bekleyenler inside one card. */
.plan-sub-h {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-5);
  background: var(--neutral-50); border-bottom: var(--border-width) solid var(--border-subtle);
  font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-strong);
}
.plan-sub-h .h-count { font-size: var(--text-sm); }
.plan-sub-h .group-desc { flex-basis: auto; margin-left: auto; }
.plan-sub-next { border-top: var(--border-width) solid var(--border-subtle); }
.plan-sub-empty { margin: 0; padding: var(--space-4) var(--space-5); font-size: var(--text-sm); color: var(--text-muted); }
