/* =========================================================================
   دفتر البيت · Pulse 07 web edition
   Dark, RTL-first, single-purpose rental ledger.
   ========================================================================= */

@font-face {
  font-family: 'Noto Sans Arabic';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('/fonts/noto-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: 'Noto Sans Arabic';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('/fonts/noto-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #121213;
  --bg-deep: #0d0d0e;
  --surface: #242426;
  --surface-2: #1b1b1d;
  --surface-3: #2c2c2f;
  --border: #4d4d53;
  --border-soft: rgba(255, 255, 255, 0.09);
  --border-faint: rgba(255, 255, 255, 0.055);
  --text: #f4f4f6;
  --muted: #b0b0b7;
  --muted-2: #85858d;
  --accent: #8db5ff;
  --accent-soft: rgba(141, 181, 255, 0.13);
  --accent-line: rgba(141, 181, 255, 0.38);
  --button: #e5e9ef;
  --on-button: #161719;
  --selected: #3b3f47;
  --error: #ffb4ab;
  --error-soft: rgba(255, 180, 171, 0.12);
  --mint: #a9e8c3;
  --mint-soft: rgba(169, 232, 195, 0.12);
  --sand: #efd39b;
  --sand-soft: rgba(239, 211, 155, 0.12);
  --radius-card: 28px;
  --radius-field: 20px;
  --radius-pill: 999px;
  --shadow: 0 24px 60px -38px rgba(0, 0, 0, 0.95);
  --font: 'Noto Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 88% -12%, rgba(141, 181, 255, 0.085), transparent 62%),
    radial-gradient(760px 520px at 4% 108%, rgba(141, 181, 255, 0.035), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.28;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
  mask-image: linear-gradient(to bottom, black, transparent 65%);
}

::selection { background: rgba(141, 181, 255, 0.3); color: var(--text); }

a { color: var(--accent); text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

h1, h2, h3, p { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.icon {
  width: 22px; height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.sm { width: 18px; height: 18px; }
.icon.lg { width: 26px; height: 26px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ---------------------------------------------------------------- app shell */
#global-notices[hidden] { display: none; }
.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 324px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 22px 22px;
  border-inline-end: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(24, 24, 26, 0.72), rgba(18, 18, 19, 0.38));
  backdrop-filter: blur(14px);
  overflow-y: auto;
  scrollbar-width: thin;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 2px 4px 4px;
}
.brand-mark {
  width: 46px; height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--button);
  color: var(--on-button);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 10px 26px -16px rgba(229, 233, 239, 0.65);
}
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted-2); }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  text-align: start;
  transition: background 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }
.nav-item.active {
  background: var(--selected);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.09);
}
.nav-item .icon { color: currentColor; opacity: 0.92; }
.nav-item .nav-count {
  margin-inline-start: auto;
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { color: var(--text); }

.side-block {
  border: 1px solid var(--border-soft);
  border-radius: 22px;
  padding: 15px;
  background: rgba(36, 36, 38, 0.5);
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.side-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.side-label .icon { width: 14px; height: 14px; }

.month-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 15px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.month-button:hover { border-color: var(--accent-line); background: var(--surface); }
.month-button .icon { width: 16px; height: 16px; color: var(--muted); }

.sync-line { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); flex: none; }
.dot.live { background: var(--mint); box-shadow: 0 0 0 4px var(--mint-soft); }
.dot.offline { background: var(--sand); box-shadow: 0 0 0 4px var(--sand-soft); }
.dot.error { background: var(--error); box-shadow: 0 0 0 4px var(--error-soft); }
.dot.loading { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.side-actions { display: flex; flex-direction: column; gap: 8px; }

.side-account {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px;
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  background: rgba(36, 36, 38, 0.5);
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--selected);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  flex: none;
}
.side-account .who { min-width: 0; flex: 1; }
.side-account .who strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-account .who span { display: block; font-size: 11px; color: var(--muted-2); }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px 40px 18px;
  background: linear-gradient(180deg, rgba(18, 18, 19, 0.94) 55%, rgba(18, 18, 19, 0.72));
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-faint);
}
.topbar-titles { flex: 1; min-width: 0; }
.screen-title {
  font-size: clamp(21px, 2.2vw, 26px);
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.screen-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text);
  transition: background 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease);
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.mobile-only { display: none; }

.content {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding: 30px 40px 72px;
  animation: rise 320ms var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.stack { display: flex; flex-direction: column; gap: 18px; }
.stack.sm { gap: 12px; }
.stack.lg { gap: 24px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-aside { grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.8fr); align-items: start; }
.grid.main-aside > .aside-sticky { position: sticky; top: 106px; }

/* ---------------------------------------------------------------- surfaces */
.card {
  background: linear-gradient(170deg, rgba(40, 40, 43, 0.96), rgba(32, 32, 34, 0.96));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.pad-lg { padding: 26px; }
.card.flat { background: var(--surface-2); box-shadow: none; }
.card.quiet { background: rgba(36, 36, 38, 0.42); box-shadow: none; }
.card.interactive {
  transition: transform 190ms var(--ease), border-color 190ms var(--ease), background 190ms var(--ease);
  cursor: pointer;
}
.card.interactive:hover {
  transform: translateY(-2px);
  border-color: var(--accent-line);
  background: linear-gradient(170deg, rgba(46, 46, 50, 0.98), rgba(34, 34, 36, 0.98));
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 18px; font-weight: 650; line-height: 1.45; letter-spacing: -0.01em; }
.card-kicker { font-size: 11px; color: var(--muted-2); letter-spacing: 0.04em; }

.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px 19px; }
.stat .stat-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.stat .stat-value {
  font-size: clamp(25px, 3vw, 32px);
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .stat-value.accent { color: var(--accent); }
.stat .stat-value.error { color: var(--error); }
.stat .stat-value.mint { color: var(--mint); }
.stat .stat-note { font-size: 11.5px; color: var(--muted-2); }
.stat.emphasis { border-color: rgba(141, 181, 255, 0.28); background: linear-gradient(160deg, rgba(141, 181, 255, 0.09), rgba(36, 36, 38, 0.94) 55%); }

.money { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; display: inline-block; }
.money .currency { font-size: 0.62em; color: var(--muted-2); font-weight: 500; margin-inline-start: 4px; }
.money.lg { font-size: clamp(28px, 4vw, 40px); font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; }
.money.md { font-size: 20px; font-weight: 600; }
.money.neg { color: var(--error); }
.money.pos { color: var(--mint); }

.section-head { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.section-head h2 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.section-head .spacer { flex: 1; }
.section-head .link {
  background: none; border: 0; padding: 6px 2px;
  color: var(--accent); font-size: 12.5px; font-weight: 550;
  display: inline-flex; align-items: center; gap: 4px;
}
.section-head .link:hover { text-decoration: underline; text-underline-offset: 4px; }

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.95; }
.hint strong { color: var(--text); font-weight: 600; }
.hint.error { color: var(--error); }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; color: var(--muted-2); }
.ltr { direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }

.divider { height: 1px; background: var(--border-faint); border: 0; margin: 4px 0; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 20px;
  border-radius: 26px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  transition: transform 150ms var(--ease), background 150ms var(--ease), border-color 150ms var(--ease), opacity 150ms var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.995); }
.btn:disabled { opacity: 0.42; }
.btn .icon { width: 18px; height: 18px; }
.btn.primary { background: var(--button); color: var(--on-button); }
.btn.primary:hover:not(:disabled) { background: #f2f5f9; }
.btn.secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn.secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); border-color: #62626a; }
.btn.ghost { background: transparent; color: var(--accent); min-height: 42px; padding: 6px 10px; }
.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn.danger { background: transparent; border-color: rgba(255, 180, 171, 0.42); color: var(--error); }
.btn.danger:hover:not(:disabled) { background: var(--error-soft); }
.btn.solid-danger { background: var(--error); color: #2a1210; }
.btn.wide { width: 100%; }
.btn.sm { min-height: 42px; border-radius: 21px; font-size: 13px; padding: 8px 14px; }
.btn.sm .icon { width: 16px; height: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 9px; }
.btn-row > .btn { flex: 1 1 180px; }
.btn-row.stack-mobile { flex-direction: column; }

/* ---------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .support { font-size: 11.5px; color: var(--muted-2); line-height: 1.8; }
.input, .select, .textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 15px;
  border-radius: var(--radius-field);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease), background 150ms var(--ease);
  appearance: none;
}
.input:hover, .select:hover, .textarea:hover { border-color: #5b5b63; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--surface);
}
.input::placeholder, .textarea::placeholder { color: #77777f; }
.input.num { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.input.date { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b0b0b7' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 15px center;
  padding-left: 42px;
}
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--muted); }
.check input { accent-color: var(--accent); width: 17px; height: 17px; margin-top: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px;
  padding: 6px 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border); }
.chip.active { background: var(--selected); color: var(--text); border-color: rgba(255, 255, 255, 0.12); }

.search-field { position: relative; }
.search-field .icon { position: absolute; inset-inline-start: 15px; top: 50%; transform: translateY(-50%); color: var(--muted-2); width: 18px; height: 18px; pointer-events: none; }
.search-field .input { padding-inline-start: 45px; }

.stepper { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--muted-2); }
.stepper span { display: flex; align-items: center; gap: 6px; }
.stepper i { width: 18px; height: 1px; background: var(--border); display: inline-block; }

/* ---------------------------------------------------------------- badges + rows */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 25px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
}
.badge.clear { background: var(--mint-soft); color: var(--mint); }
.badge.partial { background: var(--sand-soft); color: var(--sand); }
.badge.unpaid { background: var(--error-soft); color: var(--error); }
.badge.notready { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.plain { background: transparent; border: 1px solid var(--border-soft); color: var(--muted); }

.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 8px 0; }
.kv + .kv { border-top: 1px solid var(--border-faint); }
.kv dt, .kv .k { color: var(--muted); font-size: 12.5px; }
.kv dd, .kv .v { margin: 0; text-align: end; font-size: 13.5px; font-weight: 500; }
.kv .v.strong { font-weight: 650; }
.kv .v.accent { color: var(--accent); }
.kv .v.error { color: var(--error); }
.kv-list { margin: 0; }

.unit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.unit-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 17px 18px;
  border-radius: 24px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(165deg, rgba(38, 38, 41, 0.98), rgba(31, 31, 33, 0.98));
  cursor: pointer;
  transition: transform 180ms var(--ease), border-color 180ms var(--ease), background 180ms var(--ease);
  text-align: start;
}
.unit-card:hover { transform: translateY(-2px); border-color: var(--accent-line); }
.unit-card .u-top { display: flex; align-items: center; gap: 10px; }
.unit-card .u-icon {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  flex: none;
}
.unit-card .u-icon .icon { width: 17px; height: 17px; }
.unit-card .u-name { font-weight: 650; font-size: 15px; flex: 1; min-width: 0; }
.unit-card .u-tenant { font-size: 12px; color: var(--muted); min-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-card .u-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.unit-card .u-sum { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.unit-card .u-sum .money { font-size: 18px; font-weight: 650; }
.unit-card .u-sum .tiny { font-size: 10.5px; }
.unit-card.vacant { opacity: 0.72; }
.unit-card.vacant:hover { opacity: 1; }

.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 4px;
  border-top: 1px solid var(--border-faint);
  background: none;
  border-inline: 0;
  border-bottom: 0;
  text-align: start;
  width: 100%;
  color: inherit;
  border-radius: 12px;
  transition: background 150ms var(--ease);
}
.row-item:first-child { border-top: 0; }
.row-item:hover { background: rgba(255, 255, 255, 0.035); }
.row-item .ri-main { flex: 1; min-width: 0; }
.row-item .ri-title { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .ri-sub { font-size: 11.5px; color: var(--muted-2); }
.row-item .ri-side { text-align: end; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row-item .ri-side .money { font-size: 15.5px; font-weight: 600; }

.timeline { display: flex; flex-direction: column; position: relative; }
.timeline-item {
  display: flex;
  gap: 15px;
  padding: 13px 0;
  background: none;
  border: 0;
  width: 100%;
  text-align: start;
  color: inherit;
}
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex: none; position: relative; }
.timeline-dot::after { content: ''; position: absolute; top: 15px; bottom: -40px; inset-inline-start: 4px; width: 1px; background: var(--border-faint); }
.timeline-item:last-child .timeline-dot::after { display: none; }
.timeline-body { flex: 1; min-width: 0; }
.timeline-date { font-size: 11px; color: var(--muted-2); }
.timeline-title { font-size: 14px; font-weight: 550; }
.timeline-side { text-align: end; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.timeline-side .money { font-size: 15px; font-weight: 600; }
.timeline-side span { font-size: 11px; color: var(--muted-2); }

/* ---------------------------------------------------------------- month picker */
.month-pop { position: relative; }
.month-menu {
  position: absolute;
  z-index: 50;
  inset-inline-start: 0;
  top: calc(100% + 8px);
  width: 100%;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  padding: 7px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #232326;
  box-shadow: 0 26px 60px -20px rgba(0, 0, 0, 0.9);
  scrollbar-width: thin;
}
.month-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: start;
}
.month-menu button:hover { background: rgba(255, 255, 255, 0.06); }
.month-menu button.active { background: var(--selected); }
.month-menu button .tiny { font-size: 10px; }
.month-menu .menu-sep { height: 1px; background: var(--border-faint); margin: 5px 4px; }

/* ---------------------------------------------------------------- empty + error */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 34px 22px;
  border: 1px dashed rgba(255, 255, 255, 0.13);
  border-radius: 24px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.014);
}
.empty .empty-icon {
  width: 46px; height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}
.empty h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.empty p { font-size: 12.5px; max-width: 420px; line-height: 1.9; }
.empty .btn { margin-top: 6px; }

.banner {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 15px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--muted);
}
.banner .icon { width: 18px; height: 18px; margin-top: 2px; color: var(--muted); }
.banner.warn { border-color: rgba(239, 211, 155, 0.28); background: var(--sand-soft); color: var(--sand); }
.banner.warn .icon { color: var(--sand); }
.banner.danger { border-color: rgba(255, 180, 171, 0.3); background: var(--error-soft); color: var(--error); }
.banner.danger .icon { color: var(--error); }
.banner.info { border-color: rgba(141, 181, 255, 0.24); background: var(--accent-soft); color: #c7d9ff; }
.banner.info .icon { color: var(--accent); }
.banner .grow { flex: 1; }

/* ---------------------------------------------------------------- water + payment */
.share-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 14px; }
.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-faint);
}
.share-row .sr-label { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-row .input { width: 112px; min-height: 44px; height: 44px; padding: 8px 12px; font-size: 13.5px; border-radius: 15px; }

.total-line { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 10px 0; }
.total-line .k { font-size: 12.5px; color: var(--muted); }
.total-line .v { font-size: 18px; font-weight: 650; }
.total-line.grand .v { font-size: 24px; }

.allocation-row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border-faint); }
.allocation-row .al-main { flex: 1; min-width: 0; }
.allocation-row .al-main strong { display: block; font-size: 13.5px; font-weight: 550; }
.allocation-row .al-main span { font-size: 11.5px; color: var(--muted-2); }
.allocation-row .input { width: 136px; }

/* ---------------------------------------------------------------- auth / entry */
.entry {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.8fr);
  align-items: center;
  gap: 40px;
  max-width: 1180px;
  margin-inline: auto;
  padding: 48px 40px;
  position: relative;
  z-index: 1;
}
.entry-hero { display: flex; flex-direction: column; gap: 22px; max-width: 600px; }
.entry-brand { display: flex; align-items: center; gap: 13px; }
.entry-brand .brand-mark { width: 52px; height: 52px; border-radius: 17px; font-size: 24px; }
.entry-kicker { font-size: 12px; letter-spacing: 0.06em; color: var(--accent); }
.entry-title {
  font-size: clamp(34px, 4.6vw, 56px);
  line-height: 1.32;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.entry-title .dim { color: var(--muted-2); }
.entry-lead { font-size: 15px; line-height: 2; color: var(--muted); max-width: 520px; }
.entry-facts { display: flex; flex-wrap: wrap; gap: 9px; }
.fact {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11.5px;
  color: var(--muted);
}
.fact .icon { width: 15px; height: 15px; color: var(--accent); }
.entry-foot { font-size: 11.5px; color: var(--muted-2); line-height: 1.9; max-width: 540px; }
.entry-card { width: 100%; max-width: 440px; justify-self: center; padding: 30px; }
.entry-card .card-title { font-size: 22px; }
.entry-form { margin-top: 20px; }
.entry-note { font-size: 11.5px; color: var(--muted-2); line-height: 1.9; }

.center-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 30px 20px;
  position: relative;
  z-index: 1;
}
.center-card { width: 100%; max-width: 560px; }
.center-card .brand-mark { margin-inline: auto; margin-bottom: 16px; }

/* ---------------------------------------------------------------- navigation */
.bottom-nav {
  display: none;
  position: fixed;
  z-index: 40;
  inset-inline: 16px;
  bottom: max(12px, env(safe-area-inset-bottom));
  padding: 6px;
  border-radius: 30px;
  border: 1px solid var(--border);
  background: rgba(36, 36, 38, 0.94);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
}
.bottom-nav .bn-inner { display: flex; gap: 2px; }
.bottom-nav button {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.bottom-nav button .icon { width: 20px; height: 20px; }
.bottom-nav button.active { background: var(--selected); color: var(--text); }

.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 200ms var(--ease);
}

/* ---------------------------------------------------------------- toast + modal */
.toast-region {
  position: fixed;
  z-index: 90;
  inset-inline: 0;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 560px);
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #2a2a2d;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.6;
  box-shadow: 0 18px 50px -14px rgba(0, 0, 0, 0.85);
  animation: toast-in 260ms var(--ease) both;
  pointer-events: auto;
}
.toast.success { border-color: rgba(169, 232, 195, 0.32); }
.toast.success .icon { color: var(--mint); }
.toast.error { border-color: rgba(255, 180, 171, 0.34); }
.toast.error .icon { color: var(--error); }
.toast.leaving { animation: toast-out 200ms var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.99); } }

dialog.modal {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: #232326;
  color: var(--text);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.95);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(5px); }
.modal-inner { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-title { font-size: 19px; font-weight: 650; }
.modal-body { font-size: 13px; color: var(--muted); line-height: 1.95; max-height: 55vh; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.modal-actions .btn { flex: 1 1 140px; }

/* ---------------------------------------------------------------- login states */
.loader {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
  margin-inline: auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-line { height: 2px; width: 100%; overflow: hidden; background: rgba(255, 255, 255, 0.05); border-radius: 2px; }
.progress-line::after { content: ''; display: block; width: 35%; height: 100%; background: var(--accent); animation: slide 1.2s var(--ease) infinite; }
@keyframes slide { 0% { transform: translateX(150%); } 100% { transform: translateX(-350%); } }

.skeleton { border-radius: 12px; background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.08), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- misc */
.receipt-paper {
  border-radius: 28px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 90px),
    #202023;
  padding: 26px;
  position: relative;
  overflow: hidden;
}
.receipt-paper::before {
  content: '';
  position: absolute;
  inset-inline: 0; top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.7;
}
.receipt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.receipt-brand { display: flex; align-items: center; gap: 10px; }
.receipt-brand .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 17px; }
.receipt-seal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--mint-soft);
  color: var(--mint);
  font-size: 10.5px;
  font-weight: 600;
}
.receipt-seal.reversed { background: var(--error-soft); color: var(--error); }
.receipt-dashed { border-top: 1px dashed var(--border); margin: 16px 0; }

.amount-hero { display: flex; flex-direction: column; gap: 4px; padding: 6px 0 14px; }
.amount-hero .label { font-size: 11.5px; color: var(--muted-2); }

.audit-detail {
  font-size: 11.5px;
  color: var(--muted-2);
  font-family: ui-monospace, 'Cascadia Code', monospace;
  direction: ltr;
  text-align: left;
  word-break: break-all;
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms var(--ease);
}
.audit-detail.open { max-height: 400px; overflow-y: auto; }

.code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  direction: ltr;
  unicode-bidi: isolate;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-faint);
  border-radius: 8px;
  padding: 2px 6px;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--border-faint); border-radius: 8px; padding: 2px 7px; }

.reveal-note { font-size: 11px; color: var(--muted-2); }

.noscript { padding: 40px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .app { grid-template-columns: 284px minmax(0, 1fr); }
  .content { padding-inline: 28px; }
  .topbar { padding-inline: 28px; }
  .unit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app { display: block; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(88vw, 360px);
    height: 100dvh;
    transform: translateX(105%);
    transition: transform 260ms var(--ease);
    background: #17171a;
    border-inline-start: 0;
    border-inline-end: 1px solid var(--border-soft);
    z-index: 60;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  }
  .menu-open .sidebar { transform: none; }
  .menu-open .menu-overlay { display: block; opacity: 1; }
  .main { min-height: 100dvh; }
  .topbar { padding: 14px 20px; }
  .icon-btn.mobile-only { display: grid; }
  .content { padding: 20px 20px calc(104px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: block; }
  .grid.main-aside { grid-template-columns: minmax(0, 1fr); }
  .grid.main-aside > .aside-sticky { position: static; }
  .entry { grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 30px 22px 48px; align-content: start; }
  .entry-hero { gap: 16px; }
  .entry-title { font-size: clamp(30px, 8vw, 44px); }
  .entry-card { justify-self: stretch; max-width: none; }
  .entry-foot { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  .screen-title { font-size: 21px; }
  .screen-sub { font-size: 11.5px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-2.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .unit-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .share-list { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 17px; border-radius: 24px; }
  .card.pad-lg { padding: 19px; }
  .content { padding-inline: 16px; }
  .topbar { padding-inline: 16px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .stat { padding: 15px; }
  .stat .stat-value { font-size: 23px; }
  .entry { padding: 24px 18px 40px; }
  .entry-title { font-size: 32px; }
  .receipt-paper { padding: 20px; }
  .allocation-row { align-items: flex-start; flex-direction: column; gap: 7px; }
  .allocation-row .input { width: 100%; }
  .btn-row > .btn { flex-basis: 100%; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; gap: 9px; }
  .stat { padding: 13px; }
  .stat .stat-value { font-size: 21px; }
  .stat .stat-label { font-size: 11px; }
  .badge { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- print */
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; color: #111 !important; }
  body::before, .sidebar, .topbar, .bottom-nav, .toast-region, .menu-overlay, .no-print { display: none !important; }
  .app, .main { display: block !important; }
  .content { padding: 0 !important; max-width: none !important; animation: none !important; }
  .card, .receipt-paper {
    background: #fff !important;
    color: #111 !important;
    border-color: #bbb !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
  .card + .card { margin-top: 10px; }
  .money, .stat-value, .muted, .hint, .kv .k, .kv .v, .tiny { color: #111 !important; }
  .badge { border: 1px solid #999 !important; color: #111 !important; background: #fff !important; }
  .receipt-paper::before { display: none; }
  .section-head .link, .btn { display: none !important; }
  a { color: #111 !important; text-decoration: none; }
}
