/* Ada Management - application styles.
   Mobile-first, no framework, no build step.

   Theming: :root holds light values. Dark values live in one block that is
   applied either explicitly ([data-theme="dark"]) or, for the System option,
   through prefers-color-scheme. The inline snippet in base.html sets
   data-theme before first paint, so switching never flashes. */

:root {
  --bg:          #f4f5f7;
  --surface:     #ffffff;
  --surface-2:   #f7f8fa;
  --surface-3:   #eceef2;
  --border:      #dfe3e9;
  --border-soft: #eaedf1;
  --text:        #191e26;
  --text-soft:   #5a6371;
  --accent:      #1c587f;
  --accent-ink:  #ffffff;
  --accent-soft: #e6eff6;

  --ok:        #256b4d;
  --ok-soft:   #e3f2ea;
  --warn:      #8a5510;
  --warn-soft: #fbeedb;
  --crit:      #97331f;
  --crit-soft: #fbe6e1;
  --info:      #2b5b86;
  --info-soft: #e6eff6;
  --idle:      #5f6875;
  --idle-soft: #eef0f3;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --sidebar-w: 248px;
  --focus: 2px solid var(--accent);
}

/* Dark values, shared by the explicit choice and by System. */
:root[data-theme="dark"] {
  --bg:          #101318;
  --surface:     #181c23;
  --surface-2:   #1f242c;
  --surface-3:   #262c36;
  --border:      #303845;
  --border-soft: #262c36;
  --text:        #e8ebf0;
  --text-soft:   #a3adbb;
  --accent:      #6fb0dc;
  --accent-ink:  #0c1015;
  --accent-soft: #1b2a37;

  --ok:        #6fce9f;
  --ok-soft:   #162c22;
  --warn:      #e0ae66;
  --warn-soft: #302516;
  --crit:      #f0917f;
  --crit-soft: #341d18;
  --info:      #7fb7e0;
  --info-soft: #172733;
  --idle:      #9aa4b2;
  --idle-soft: #222831;

  --shadow: 0 1px 2px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg:          #101318;
    --surface:     #181c23;
    --surface-2:   #1f242c;
    --surface-3:   #262c36;
    --border:      #303845;
    --border-soft: #262c36;
    --text:        #e8ebf0;
    --text-soft:   #a3adbb;
    --accent:      #6fb0dc;
    --accent-ink:  #0c1015;
    --accent-soft: #1b2a37;

    --ok:        #6fce9f;
    --ok-soft:   #162c22;
    --warn:      #e0ae66;
    --warn-soft: #302516;
    --crit:      #f0917f;
    --crit-soft: #341d18;
    --info:      #7fb7e0;
    --info-soft: #172733;
    --idle:      #9aa4b2;
    --idle-soft: #222831;

    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.muted { color: var(--text-soft); }
.small { font-size: .78rem; }

.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;
}

/* Visible keyboard focus everywhere, never removed. */
a:focus-visible, button:focus-visible, input:focus-visible,
label:focus-visible, [tabindex]:focus-visible {
  outline: var(--focus); outline-offset: 2px; border-radius: 6px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 9px; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: .95rem; }
.brand-text small { color: var(--text-soft); font-size: .75rem; }
.brand-lg .brand-mark { width: 42px; height: 42px; flex-basis: 42px; font-size: 1.2rem; }

/* ---------- layout ---------- */
.layout { min-height: 100vh; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.nav-scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(8, 11, 16, .5);
  opacity: 0; visibility: hidden; transition: opacity .18s ease;
}
.nav-toggle:checked ~ .nav-scrim { opacity: 1; visibility: visible; }

.sidebar {
  position: fixed; z-index: 40; inset: 0 auto 0 0;
  width: var(--sidebar-w); max-width: 84vw;
  display: flex; flex-direction: column; gap: 1rem;
  padding: 1rem .85rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform .2s ease;
  overflow-y: auto;
}
.nav-toggle:checked ~ .sidebar { transform: translateX(0); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .58rem .7rem; border-radius: 8px;
  color: var(--text-soft); text-decoration: none; font-size: .9rem;
}
a.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav-item.is-disabled { cursor: default; opacity: .7; }

.badge {
  font-size: .66rem; padding: .12rem .42rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-soft);
  background: var(--surface-2); white-space: nowrap;
}

.sidebar-foot { font-size: .75rem; padding: .2rem .7rem; }
.main-col { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

/* ---------- header ---------- */
.header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-title { min-width: 0; flex: 1; }
.header-title h1 { font-size: 1.05rem; }
.header-title p { font-size: .78rem; }
.header-right { display: flex; align-items: center; gap: .5rem; }

.user-email {
  display: none; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .82rem; color: var(--text-soft);
}

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); cursor: pointer;
}
.burger, .burger::before, .burger::after {
  content: ""; display: block;
  width: 16px; height: 2px; border-radius: 2px; background: var(--text);
}
.burger { position: relative; }
.burger::before { position: absolute; top: -5px; }
.burger::after  { position: absolute; top: 5px; }

/* ---------- theme switch ---------- */
.theme-switch {
  display: inline-flex; padding: 2px; gap: 2px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2);
}
.theme-btn {
  font: inherit; font-size: .85rem; line-height: 1;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text-soft); cursor: pointer;
}
.theme-btn:hover { background: var(--surface-3); color: var(--text); }
.theme-btn[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}

.content { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: 1rem; }

/* ---------- metric cards ---------- */
.cards { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .95rem 1rem; border-top: 3px solid var(--border); min-width: 0;
}
.card-accent-ok   { border-top-color: var(--ok); }
.card-accent-idle { border-top-color: var(--idle); }
.card-accent-warn { border-top-color: var(--warn); }
.card-label { font-size: .78rem; color: var(--text-soft); }
.card-value {
  font-size: 1.85rem; font-weight: 650; letter-spacing: -.02em;
  margin-top: .15rem; font-variant-numeric: tabular-nums;
}
.card-note { font-size: .72rem; color: var(--text-soft); margin-top: .2rem; }

/* ---------- panels ---------- */
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }

.panel {
  padding: 1.1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.panel-head {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: .8rem; flex-wrap: wrap;
}
.panel-head h2 { font-size: 1rem; flex: 1; }
.panel p + p { margin-top: .5rem; }
.panel-notice { border-left: 3px solid var(--accent); }

.count-pill {
  font-size: .74rem; font-weight: 600; padding: .1rem .5rem;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--border);
}
.empty { color: var(--text-soft); font-size: .9rem; }

/* ---------- action center ---------- */
.action-list { display: flex; flex-direction: column; gap: .55rem; }
.action {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .65rem .75rem; border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--idle);
}
.action-critical { border-left-color: var(--crit); background: var(--crit-soft); }
.action-warning  { border-left-color: var(--warn); background: var(--warn-soft); }
.action-info     { border-left-color: var(--info); background: var(--info-soft); }

/* Status is carried by this text label, not by colour alone. */
.action-tag {
  flex: 0 0 auto; font-size: .68rem; font-weight: 700;
  letter-spacing: .02em; text-transform: uppercase;
  padding: .2rem .45rem; border-radius: 6px;
  border: 1px solid currentColor; white-space: nowrap;
}
.action-critical .action-tag { color: var(--crit); }
.action-warning  .action-tag { color: var(--warn); }
.action-info     .action-tag { color: var(--info); }

.action-body { min-width: 0; }
.action-title { font-size: .9rem; font-weight: 600; }
.action-desc  { font-size: .8rem; margin-top: .12rem; }
.action-date  { font-size: .75rem; margin-top: .2rem; font-variant-numeric: tabular-nums; }

/* ---------- upcoming ---------- */
.upcoming-summary { font-size: .9rem; margin-bottom: .6rem; }
.mini-list { display: flex; flex-direction: column; gap: .3rem; }
.mini-list li {
  display: flex; justify-content: space-between; gap: .5rem;
  font-size: .85rem; padding: .35rem .5rem;
  background: var(--surface-2); border-radius: 7px;
  border: 1px solid var(--border-soft);
}
.mini-key { font-weight: 600; }

/* ---------- quick actions ---------- */
.qa-note { margin-bottom: .7rem; }
.quick-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.quick {
  font: inherit; text-align: left; cursor: not-allowed;
  display: flex; flex-direction: column; gap: .15rem; align-items: flex-start;
  padding: .7rem .8rem; border-radius: 9px;
  border: 1px dashed var(--border); background: var(--surface-2);
  color: var(--text); opacity: .72;
}
.quick-label { font-size: .88rem; font-weight: 600; }
.quick-hint  { font-size: .74rem; }
.quick .badge { margin-top: .3rem; }

/* ---------- building snapshot ---------- */
.unit-grid {
  display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
}
.unit {
  display: flex; flex-direction: column; gap: .15rem; align-items: center;
  padding: .55rem .35rem; border-radius: 9px;
  border: 1px solid var(--border); border-top-width: 3px;
  background: var(--surface-2); min-width: 0;
}
.unit-no { font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; }
.unit-status { font-size: .68rem; text-align: center; line-height: 1.25; }

.unit-occupied       { border-top-color: var(--ok);   background: var(--ok-soft); }
.unit-occupied .unit-status { color: var(--ok); }
.unit-vacant         { border-top-color: var(--idle); background: var(--idle-soft); }
.unit-vacant .unit-status { color: var(--idle); }
.unit-renovation     { border-top-color: var(--warn); background: var(--warn-soft); }
.unit-renovation .unit-status { color: var(--warn); }
.unit-reserved       { border-top-color: var(--info); background: var(--info-soft); }
.unit-reserved .unit-status { color: var(--info); }
.unit-out-of-service { border-top-color: var(--crit); background: var(--crit-soft); }
.unit-out-of-service .unit-status { color: var(--crit); }

.legend {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  margin-top: .9rem; padding-top: .8rem;
  border-top: 1px solid var(--border-soft);
  font-size: .76rem; color: var(--text-soft);
}
.legend li { display: flex; align-items: center; gap: .35rem; }
.swatch {
  width: 12px; height: 12px; border-radius: 4px;
  border: 1px solid var(--border); border-top-width: 3px;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: .87rem;
  padding: .5rem .85rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--text-soft); }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: 600;
}
.btn-ghost { background: transparent; }
.btn-block { width: 100%; padding: .68rem; font-size: .95rem; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 1.6rem 1.4rem;
}
.auth-title { font-size: 1.2rem; margin: 1.1rem 0 1rem; }
/* No brand block above the heading on the anonymous login page, so it needs no
   top margin. */
.auth-title-lead { margin-top: 0; }

.field { margin-bottom: .9rem; }
.field label {
  display: block; font-size: .8rem; font-weight: 600;
  margin-bottom: .3rem; color: var(--text-soft);
}
.field input {
  width: 100%; font: inherit; padding: .6rem .7rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.field input::placeholder { color: var(--text-soft); opacity: .75; }
.field input:focus { outline: var(--focus); outline-offset: 1px; border-color: var(--accent); }
.field-error { color: var(--crit); font-size: .78rem; margin-top: .25rem; }

.alert {
  border: 1px solid var(--crit); border-left-width: 3px; border-radius: 8px;
  padding: .6rem .75rem; font-size: .85rem;
  color: var(--crit); background: var(--crit-soft); margin-bottom: .9rem;
}


/* ---------- flash messages ---------- */
.messages { display: flex; flex-direction: column; gap: .5rem; }
.flash {
  padding: .6rem .8rem; border-radius: 9px; font-size: .88rem;
  border: 1px solid var(--border); border-left-width: 3px;
  background: var(--surface); color: var(--text);
}
.flash-success { border-left-color: var(--ok);   background: var(--ok-soft); }
.flash-error   { border-left-color: var(--crit); background: var(--crit-soft); }
.flash-warning { border-left-color: var(--warn); background: var(--warn-soft); }
.flash-info    { border-left-color: var(--info); background: var(--info-soft); }

/* ---------- notices ---------- */
.notice {
  padding: .7rem .85rem; border-radius: 9px; font-size: .87rem;
  border: 1px solid var(--border); border-left-width: 3px;
  background: var(--surface-2); margin-bottom: .9rem;
}
.notice-warn { border-left-color: var(--warn); background: var(--warn-soft); }

/* ---------- tables ---------- */
.cards-compact .card-value { font-size: 1.5rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .89rem; }
.table thead th {
  text-align: left; font-size: .74rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-soft); padding: .5rem .6rem;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td, .table tbody th {
  padding: .6rem; border-bottom: 1px solid var(--border-soft);
  text-align: left; font-weight: 400; vertical-align: middle;
}
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-key { font-weight: 600; }
.cell-sub { display: block; font-size: .72rem; font-weight: 400; }
.table-note { margin-top: .7rem; }

/* ---------- chips ---------- */
.chip {
  display: inline-block; font-size: .74rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 999px;
  border: 1px solid currentColor; white-space: nowrap;
}
.chip-occupied { color: var(--ok); background: var(--ok-soft); }
.chip-vacant   { color: var(--idle); background: var(--idle-soft); }
.chip-op-normal         { color: var(--text-soft); background: var(--surface-3); }
.chip-op-renovation     { color: var(--warn); background: var(--warn-soft); }
.chip-op-reserved       { color: var(--info); background: var(--info-soft); }
.chip-op-out_of_service { color: var(--crit); background: var(--crit-soft); }

/* ---------- empty state ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: flex-start; gap: .5rem;
  padding: 1.5rem 0;
}

/* ---------- forms ---------- */
.panel-form { max-width: 560px; }
.field-help { font-size: .74rem; margin-top: .25rem; }
.req { color: var(--crit); }
.field select, .field textarea {
  width: 100%; font: inherit; padding: .6rem .7rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.field select:focus, .field textarea:focus {
  outline: var(--focus); outline-offset: 1px; border-color: var(--accent);
}
.field textarea { resize: vertical; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }

/* Quick action that is actually wired up. */
a.quick.quick-ready {
  cursor: pointer; opacity: 1; text-decoration: none;
  border-style: solid; background: var(--surface-2);
}
a.quick.quick-ready:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- narrow screens: table becomes stacked rows ---------- */
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td, .table th { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border); border-radius: 9px;
    margin-bottom: .6rem; padding: .5rem .6rem; background: var(--surface-2);
  }
  .table tbody td, .table tbody th { border-bottom: 0; padding: .25rem 0; }
  .table tbody td {
    display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  }
  .table tbody td::before {
    content: attr(data-label);
    font-size: .74rem; color: var(--text-soft); font-weight: 600;
  }
  .table .num { text-align: right; }
  .panel-head .btn { width: 100%; }
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .sidebar { transform: none; }
  .nav-scrim, .nav-open { display: none; }
  .main-col { margin-left: var(--sidebar-w); }
  .header { padding: .85rem 1.5rem; }
  .header-title h1 { font-size: 1.15rem; }
  .user-email { display: inline-block; }
  .content { padding: 1.5rem; gap: 1.25rem; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .grid-2 { grid-template-columns: 3fr 2fr; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- lease status chips ---------- */
.chip-lease-active    { color: var(--ok);   background: var(--ok-soft); }
.chip-lease-draft     { color: var(--info); background: var(--info-soft); }
.chip-lease-ended     { color: var(--idle); background: var(--idle-soft); }
.chip-lease-cancelled { color: var(--crit); background: var(--crit-soft); }
.chip-lease-none      { color: var(--text-soft); background: var(--surface-3); }

/* ---------- search bar ---------- */
.search {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  margin-bottom: 1rem;
}
.search .input { flex: 1 1 14rem; min-width: 0; }
.search input {
  font: inherit; padding: .55rem .7rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.search input:focus { outline: var(--focus); outline-offset: 1px; border-color: var(--accent); }

/* ---------- detail pages ---------- */
.detail-grid {
  display: grid; gap: .8rem 1.5rem; margin: 0;
  grid-template-columns: 1fr;
}
.detail-grid dt {
  font-size: .74rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; color: var(--text-soft);
}
.detail-grid dd { margin: .15rem 0 0; }
.notes-body { white-space: pre-line; }

@media (min-width: 640px) {
  .detail-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* ---------- destructive actions ---------- */
.btn-danger {
  background: var(--crit); border-color: var(--crit); color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); border-color: var(--crit); }
.btn-danger-ghost, .link-danger { color: var(--crit); }
.btn-danger-ghost:hover { border-color: var(--crit); background: var(--crit-soft); }
.link-danger:hover { text-decoration: underline; }
.panel-danger { border-color: var(--crit); }
.danger-question { font-weight: 600; margin-bottom: .9rem; }
.notice-danger { border-color: var(--crit); background: var(--crit-soft); color: var(--crit); }
.row-actions { white-space: nowrap; }
.row-actions a + a { margin-left: .75rem; }

/* ---------- settlement chips ---------- */
.chip-pay-paid    { color: var(--ok);   background: var(--ok-soft); }
.chip-pay-partial { color: var(--info); background: var(--info-soft); }
.chip-pay-unpaid  { color: var(--idle); background: var(--idle-soft); }
.chip-pay-overdue { color: var(--crit); background: var(--crit-soft); }

/* ---------- filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.filter-chip {
  font-size: .8rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-soft); text-decoration: none;
}
.filter-chip:hover { border-color: var(--accent); }
.filter-chip.is-active {
  border-color: var(--accent); background: var(--accent-soft); color: var(--text);
}

/* ---------- utility chips ---------- */
.chip-utility-electricity { color: var(--warn); background: var(--warn-soft); }
.chip-utility-water       { color: var(--info); background: var(--info-soft); }
.chip-utility-natural_gas { color: var(--crit); background: var(--crit-soft); }

/* ---------- payment watch ---------- */
.text-crit { color: var(--crit); }
.promise-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.promise {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .6rem .7rem; border: 1px solid var(--border);
  border-left-width: 3px; border-radius: 9px; background: var(--surface-2);
}
.promise-dot {
  width: .6rem; height: .6rem; border-radius: 50%; flex: none;
  background: currentColor;
}
.promise-overdue  { border-left-color: var(--crit); color: var(--crit); }
.promise-today    { border-left-color: var(--warn); color: var(--warn); }
.promise-upcoming { border-left-color: var(--info); color: var(--info); }
.promise-body { flex: 1 1 14rem; min-width: 0; color: var(--text); }
.promise-title { margin: 0; font-size: .92rem; }
.promise-meta { margin: .15rem 0 0; font-size: .78rem; }
.promise-action { flex: none; }

/* ---------- tenant account ---------- */
.ledger-total {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .7rem 0 0; margin-top: .4rem;
  border-top: 2px solid var(--border); font-weight: 700;
}
.ledger-total .num { font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .promise-action { width: 100%; }
}

/* ---------- bulk finance actions ---------- */
.bulk-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.skip-details { margin-top: 1rem; font-size: .85rem; }
.skip-details summary { cursor: pointer; color: var(--text-soft); }

@media (max-width: 640px) {
  .bulk-actions .btn { width: 100%; }
}

/* ---------- record list (payments with their allocations) ---------- */
.record-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.record {
  display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-start;
  padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2);
}
.record-cancelled { opacity: .65; }
.record-cancelled .record-title strong { text-decoration: line-through; }
.record-main { flex: 1 1 16rem; min-width: 0; }
.record-title { margin: 0; font-size: .95rem; }
.record-meta { margin: .2rem 0 0; font-size: .78rem; }
.record-sub { margin: .5rem 0 .2rem; font-size: .74rem; font-weight: 600;
              text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); }
.alloc-list { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.alloc-list li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .15rem 0; border-bottom: 1px dashed var(--border-soft);
}
.alloc-list li:last-child { border-bottom: 0; }
.alloc-list .num { font-variant-numeric: tabular-nums; }
.record-actions { display: flex; gap: .4rem; flex-wrap: wrap; flex: none; }

@media (max-width: 640px) {
  .record-actions { width: 100%; }
  .record-actions .btn { flex: 1 1 auto; }
}

/* ---------- totals under a detail table ---------- */
.totals-grid { margin-top: 1rem; padding-top: .8rem; border-top: 2px solid var(--border); }
.totals-grid dd.num { font-variant-numeric: tabular-nums; font-size: 1.05rem; }

/* ---------- financial scope sections ---------- */
.scope-title {
  margin: 1.2rem 0 .1rem; font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft);
}
.scope-title:first-of-type { margin-top: .4rem; }
.card-accent-crit { border-left: 3px solid var(--crit); }
.card-accent-crit .card-value { color: var(--crit); }
.chip-scope-kira    { color: var(--info); background: var(--info-soft); }
.chip-scope-yonetim { color: var(--warn); background: var(--warn-soft); }

/* ---------- information slips ---------- */
.check-grid {
  display: grid; gap: .5rem; grid-template-columns: 1fr;
  margin-bottom: 1rem;
}
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { width: 1.05rem; height: 1.05rem; }

/* The preview overlay. The page behind it dims; the slip itself does not
   participate in the theme (see below). */
.slip-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 1.25rem 1rem 2rem;
  background: rgba(8, 10, 14, .72);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
/* The `display: flex` above is an author rule, so it beats the user agent's
   `[hidden] { display: none }`. Without this line, slip.js setting
   `overlay.hidden = true` marks the element hidden in the DOM while leaving it
   fully visible - which is exactly the bug AR-014.2 fixed. */
.slip-overlay[hidden] { display: none; }

.slip-dialog { width: 100%; max-width: 27rem; position: relative; }

/* Close button, pinned to the dialog rather than drawn inside the document,
   so it never reads as part of the slip. */
.slip-close {
  position: absolute; top: -.35rem; right: -.35rem; z-index: 1;
  width: 2.5rem; height: 2.5rem;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%;
  background: rgba(8, 10, 14, .85); color: #fff;
  font-size: 1.15rem; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.slip-close:hover { background: #000; border-color: #fff; }
.slip-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.slip-actions {
  display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem;
}
.slip-actions .btn { flex: 1 1 auto; }
body.slip-open { overflow: hidden; }

/* A slip is a document, not a UI surface: always dark ink on white paper, in
   every theme, because it is screenshotted and printed. */
.slip {
  --slip-ink: #14181f;
  --slip-soft: #5b6472;
  --slip-line: #d7dbe2;
  width: 100%;
  padding: 1.6rem 1.5rem 1.4rem;
  background: #fff;
  color: var(--slip-ink);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.slip-head { text-align: center; margin-bottom: 1.4rem; }
.slip-brand {
  margin: 0; font-size: 1.18rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
}
.slip-kind {
  margin: .35rem 0 0; font-size: .74rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--slip-soft);
}

.slip-cancelled {
  margin: 0 0 .5rem; padding: .5rem; text-align: center;
  border: 2px solid #9c2a17; border-radius: 6px;
  color: #9c2a17; font-weight: 800; letter-spacing: .16em; font-size: .9rem;
}
.slip-cancel-reason {
  margin: 0 0 1rem; text-align: center; font-size: .76rem;
  color: var(--slip-soft);
}

.slip-rule { border: 0; border-top: 1px solid var(--slip-line); margin: 1.1rem 0; }

.slip-rows { margin: 0; display: grid; gap: .45rem; }
.slip-rows div {
  display: flex; align-items: baseline; gap: .8rem;
  font-size: .88rem;
}
.slip-rows dt { color: var(--slip-soft); white-space: nowrap; }
.slip-rows dd {
  margin: 0 0 0 auto; font-weight: 600; text-align: right;
  overflow-wrap: anywhere;
}
.slip-rows-meta dd { font-weight: 700; }

.slip-block { margin: 1.1rem 0 0; }
.slip-block-title {
  margin: 0 0 .35rem; font-size: .7rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--slip-soft);
}
.slip-text { margin: .15rem 0; font-size: .88rem; overflow-wrap: anywhere; }
.slip-text-soft { color: var(--slip-soft); font-size: .82rem; }

.slip-lines { list-style: none; margin: 0; padding: 0; }
.slip-lines li {
  display: flex; justify-content: space-between; gap: .9rem;
  padding: .3rem 0; font-size: .88rem;
  border-bottom: 1px dotted var(--slip-line);
}
.slip-lines li:last-child { border-bottom: 0; }
.slip-line-label { overflow-wrap: anywhere; }
.slip-lines em { font-style: normal; color: var(--slip-soft); font-size: .78rem; }
.slip-line-amount { font-weight: 600; white-space: nowrap; }

.slip-total {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; margin: 0 0 1.3rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .12em;
}
.slip-total-amount {
  font-size: 1.35rem; letter-spacing: 0; white-space: nowrap;
}

.slip-stamp {
  margin: 0 auto 1.3rem; padding: .5rem .9rem; width: fit-content;
  border: 1px solid #1f6b46; border-radius: 999px;
  color: #1f6b46; font-weight: 700; letter-spacing: .1em; font-size: .78rem;
  text-align: center;
}
.slip-stamp-void {
  border-color: #9c2a17; color: #9c2a17; letter-spacing: .08em;
}

.slip-foot { text-align: center; }
.slip-disclaimer {
  margin: 0; font-weight: 700; letter-spacing: .16em; font-size: .74rem;
}
.slip-fine {
  margin: .6rem 0 0; font-size: .68rem; line-height: 1.6;
  color: var(--slip-soft); overflow-wrap: anywhere;
}

@media (min-width: 640px) {
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .slip-actions .btn { flex: 0 0 auto; }
}

/* ---------- print: the slip and nothing else ----------
 *
 * The application emits no print timestamp of its own; the only date on a
 * slip is the payment/expense date, and only when the operator chose to show
 * it. Chrome and Safari can still add their own header/footer (date, URL,
 * page number) because that is a browser print setting - no stylesheet can
 * switch it off. The operator turns off "Headers and footers" in the print
 * dialog if they want a bare document. Documented in DECISIONS.md (D-069).
 */
@media print {
  html, body { background: #fff !important; }

  .sidebar, .header, .nav-scrim, .nav-toggle, .messages, .panel-form,
  .no-print, .skip-link, .sidebar-foot, .theme-switch,
  .slip-close { display: none !important; }
  .layout { display: block !important; }
  .main-col { margin: 0 !important; }
  .content { padding: 0 !important; gap: 0 !important; }

  /* The overlay becomes the page: no dimming, no scroll container, no shadow. */
  .slip-overlay {
    position: static !important; inset: auto !important;
    display: block !important; padding: 0 !important;
    background: transparent !important; overflow: visible !important;
  }
  body.slip-open { overflow: visible !important; }

  /* A document width, centred - not stretched across the sheet. */
  .slip-dialog { max-width: 100% !important; margin: 0 auto !important; }
  .slip {
    width: 96mm; max-width: 96mm; margin: 0 auto !important;
    padding: 0 !important; border-radius: 0 !important;
    box-shadow: none !important; background: #fff !important;
    page-break-inside: avoid;
  }

  a[href]::after { content: ""; }
  @page { size: auto; margin: 16mm; }
}

/* ---------- targeted collection preview ---------- */
.target-preview {
  margin: .7rem 0 0; padding: .7rem .8rem; display: grid; gap: .35rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); font-size: .85rem;
}
.target-preview div {
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
}
.target-preview dt { color: var(--text-soft); }
.target-preview dd {
  margin: 0; font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.target-preview div:last-child dd { color: var(--accent); }

/* ---------- bulk charge unit picker ---------- */
.panel-wide { max-width: 44rem; }
.quick-select {
  display: flex; flex-wrap: wrap; gap: .4rem; margin: .2rem 0 .8rem;
}
.quick-select .btn { font-size: .8rem; padding: .35rem .7rem; }
.unit-picker {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .1rem;
  max-height: 22rem; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 9px;
}
.unit-pick { border-bottom: 1px solid var(--border-soft); }
.unit-pick:last-child { border-bottom: 0; }
.unit-pick .check {
  padding: .5rem .7rem; margin: 0; width: 100%; cursor: pointer;
  align-items: center;
}
.unit-pick:hover { background: var(--surface-2); }
.unit-pick.is-disabled { opacity: .55; }
.unit-pick.is-disabled .check { cursor: not-allowed; }
.unit-pick-label { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .88rem; }
.card-value-text { font-size: 1.05rem; }

@media (min-width: 640px) {
  .unit-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .unit-pick { border-bottom: 1px solid var(--border-soft); }
}

/* ---------- sortable table headers (Sözleşmeler) ---------- */
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover, .sort-link.is-sorted { color: var(--text); }
.sort-link:hover { text-decoration: underline; }
.sort-arrow { opacity: .55; }
.sort-link.is-sorted .sort-arrow, .filter-chip.is-active .sort-arrow { opacity: 1; }
/* Headers disappear on narrow screens, so the sort chips appear there only. */
.sort-bar { display: none; }
@media (max-width: 640px) {
  .sort-bar { display: flex; }
}
