/* Business Book — Vyapar-inspired, mobile-first. No build step. */

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eef2f8;
  --text: #1c2434;
  --muted: #6b778c;
  --border: #dde3ec;
  --border-strong: #c8d1de;

  --nav-bg: #14213d;
  --nav-bg-hover: #1e2e52;
  --nav-text: #b9c3da;
  --nav-muted: #7482a3;

  --brand: #1f5fd6;
  --brand-dark: #174bb0;
  --brand-soft: #e8f0fe;
  --accent: #e3343f;          /* Vyapar-style red call-to-action */
  --accent-dark: #c7242f;

  --get: #0e9f5a;             /* receivable — you will get */
  --get-soft: #e7f7ee;
  --pay: #e0393e;             /* payable — you will pay */
  --pay-soft: #fdeced;
  --pending: #c77700;
  --pending-soft: #fff6e0;
  --info-soft: #eaf1ff;
  --cancelled: #98a2b3;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 2px 6px rgba(20, 33, 61, .04);
  --shadow-lg: 0 8px 24px rgba(20, 33, 61, .14);
  --sidebar: 236px;
  --bottom-nav: 62px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 18px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.get { color: var(--get); }
.pay { color: var(--pay); }
.receivable { color: var(--get); }
.payable { color: var(--pay); }
.pending-text { color: var(--pending); }
.amount-cancelled { color: var(--cancelled); text-decoration: line-through; }
.desktop-only { display: none !important; }
@media (min-width: 900px) {
  .desktop-only { display: revert !important; }
  .mobile-only { display: none !important; }
}

/* =========================================================
   APP SHELL
========================================================= */
.app { min-height: 100vh; }
.sidebar { display: none; }
.main { padding-bottom: calc(var(--bottom-nav) + 20px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 8px 14px;
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 6px rgba(20, 33, 61, .18);
}
.topbar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { display: inline-flex; color: inherit; }
.topbar .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .28); color: #fff; }
.topbar .btn:hover { background: rgba(255, 255, 255, .24); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.quick-pills { display: none; }

.content { padding: 14px; max-width: 1280px; }

@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 25;
    background: var(--nav-bg); color: var(--nav-text);
    padding: 14px 10px;
    overflow-y: auto;
  }
  .main { margin-left: var(--sidebar); padding-bottom: 28px; }
  .bottom-nav { display: none !important; }
  .topbar {
    background: var(--surface); color: var(--text);
    border-bottom: 1px solid var(--border); box-shadow: none;
    padding: 10px 24px; min-height: 60px;
  }
  .topbar .btn { background: var(--surface); border-color: var(--border); color: var(--text); }
  .topbar .btn:hover { background: var(--surface-2); }
  .quick-pills { display: flex; gap: 8px; margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--border); }
  .content { padding: 20px 24px; }
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 700; }
.brand small { display: block; font-weight: 500; color: var(--nav-muted); font-size: 11.5px; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #ff7a45); color: #fff; font-weight: 800; font-size: 17px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--nav-text); text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--nav-bg-hover); color: #fff; }
.nav a.active { background: var(--nav-bg-hover); color: #fff; font-weight: 600; }
.nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav .nav-cta {
  justify-content: center; margin-bottom: 12px; padding: 10px 12px;
  background: var(--accent); color: #fff; font-weight: 700; border-radius: 999px;
}
.nav .nav-cta:hover { background: var(--accent-dark); }
.nav-label { margin: 18px 12px 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--nav-muted); }
.sidebar-foot {
  margin-top: auto; display: flex; gap: 10px; align-items: center;
  padding: 12px 8px 2px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px;
}
.sidebar-foot strong { color: #fff; }
.sidebar-foot .btn-link { color: var(--nav-muted); }
.icon { width: 19px; height: 19px; flex: none; }

/* Mobile bottom navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--bottom-nav) + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(20, 33, 61, .06);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 500; text-decoration: none;
}
.bottom-nav a.active { color: var(--brand); font-weight: 700; }
.bottom-nav .fab {
  display: grid; place-items: center;
  width: 54px; height: 54px; margin: -22px auto 0; border-radius: 50%;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 16px rgba(227, 52, 63, .4);
}
.bottom-nav .fab .icon { width: 26px; height: 26px; }

/* =========================================================
   SURFACES
========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px; }
.card-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2 { flex: 1; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Stat tiles */
.stat { position: relative; padding: 14px 16px; overflow: hidden; }
.stat .label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 4px; letter-spacing: -.01em; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.get { border-left: 4px solid var(--get); }
.stat.get .value, .stat.get .label { color: var(--get); }
.stat.pay { border-left: 4px solid var(--pay); }
.stat.pay .value, .stat.pay .label { color: var(--pay); }
.stat.warn { border-left: 4px solid var(--pending); }
.stat.warn .value { color: var(--pending); }
.stat.info { border-left: 4px solid var(--brand); }
a.stat { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
a.stat:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.arrow-chip {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 13px; font-weight: 800;
}
.get .arrow-chip { background: var(--get-soft); }
.pay .arrow-chip { background: var(--pay-soft); }

.balance-card { padding: 16px; }
.balance-card .label { font-size: 13px; font-weight: 700; }
.balance-card .value { font-size: 28px; font-weight: 800; }
.balance-card.receivable { background: var(--get-soft); border-color: #bfe9d1; }
.balance-card.payable { background: var(--pay-soft); border-color: #f7c6c8; }

/* =========================================================
   BUTTONS
========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-get { background: var(--get-soft); border-color: #bfe9d1; color: var(--get); }
.btn-get:hover { background: #d6f2e2; }
.btn-pay { background: var(--pay-soft); border-color: #f7c6c8; color: var(--pay); }
.btn-pay:hover { background: #fbdcde; }
.btn-danger { color: var(--pay); border-color: #f7c6c8; }
.btn-danger:hover { background: var(--pay-soft); border-color: var(--pay); }
.btn-pill { border-radius: 999px; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.ok { color: var(--get); }
.icon-btn.no { color: var(--pay); }

/* =========================================================
   FORMS
========================================================= */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; position: relative; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: #3b4658; }
.field .hint { font-size: 12px; color: var(--muted); }
.req::after { content: " *"; color: var(--pay); }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* ≥16px avoids iOS zoom */
  transition: border-color .15s, box-shadow .15s;
}
@media (min-width: 900px) { .input, select.input, textarea.input { font-size: 14px; } }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 95, 214, .15); }
.input[readonly] { background: var(--surface-2); color: #3b4658; }
.input.is-invalid { border-color: var(--pay); }
.error { color: var(--pay); font-size: 12px; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 700px) {
  .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
  .span-all { grid-column: 1 / -1; }
}
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--brand); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 699px) {
  .form-actions.sticky {
    position: sticky; bottom: calc(var(--bottom-nav) + 8px); z-index: 10;
    background: var(--bg); padding: 8px 0;
  }
  .form-actions.sticky .btn { flex: 1; }
}

.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-3); border-radius: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  padding: 6px 14px; border-radius: 6px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + label { outline: 2px solid var(--brand); }
.segmented input[value="pending"]:checked + label { color: var(--pending); }
.segmented input[value="confirmed"]:checked + label { color: var(--get); }

/* Searchable select (see public/js/app.js) */
.combo { position: relative; }
.combo-input { padding-right: 34px; }
.combo::after {
  content: ""; position: absolute; right: 13px; top: 17px; pointer-events: none;
  border: 5px solid transparent; border-top-color: var(--muted);
}
.combo-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
}
.combo-list li {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.combo-list li.active, .combo-list li:hover { background: var(--brand-soft); }
.combo-list li.selected { font-weight: 700; }
.combo-list .meta { font-size: 12px; font-weight: 600; white-space: nowrap; }
.combo-list .none { color: var(--muted); cursor: default; }

/* Filter toolbar */
.toolbar {
  display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 12px; align-items: end;
}
.toolbar .input { min-height: 38px; font-size: 14px; }
.toolbar .full { grid-column: 1 / -1; }
.toolbar .field label { font-size: 11.5px; color: var(--muted); }
@media (min-width: 900px) {
  .toolbar { display: flex; flex-wrap: wrap; }
  .toolbar > * { flex: 0 1 auto; }
  .toolbar .grow { flex: 1 1 220px; min-width: 200px; }
  .toolbar .w-sm { width: 185px; }
  .toolbar .full { grid-column: auto; }
}
.filters { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filters .input { min-height: 38px; font-size: 14px; }
.filters .full { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .filters { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .filters .full { grid-column: auto; }
}
details.filter-box > summary { cursor: pointer; list-style: none; font-weight: 600; font-size: 14px; }
details.filter-box > summary::-webkit-details-marker { display: none; }

/* =========================================================
   LISTS & TABLES
========================================================= */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-row {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 16px; color: inherit; text-decoration: none;
}
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row .main-col { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .end { text-align: right; flex: none; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-3); font-size: 11px; font-weight: 700; color: #4b5870;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.table td.num, .table th.num { text-align: right; }
.table tbody tr:hover td { background-color: rgba(31, 95, 214, .035); }
.table tr.total td { font-weight: 700; background: var(--surface-2); }
.table tr.is-cancelled td { color: var(--cancelled); text-decoration: line-through; }
.table tr.is-cancelled td.keep { text-decoration: none; }
.table .clamp { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Avatars (initials) */
.avatar {
  --h: 210;
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  background: hsl(var(--h) 75% 93%); color: hsl(var(--h) 55% 32%);
  font-weight: 700; font-size: 14px; letter-spacing: .02em;
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

/* =========================================================
   BADGES
========================================================= */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  background: var(--surface-3); color: var(--muted); vertical-align: middle;
}
.badge.pending { background: var(--pending-soft); color: var(--pending); }
.badge.confirmed { background: var(--get-soft); color: var(--get); }
.badge.cancelled { background: #f1f3f6; color: var(--cancelled); }
.badge.inactive { background: #f1f3f6; color: var(--cancelled); }
.badge.system { background: var(--brand-soft); color: var(--brand); }
.type-tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: #3b4658; white-space: nowrap;
}
.type-tag.receivable_plus { background: #e9f7ef; color: #0b7a45; }
.type-tag.receivable_minus { background: #e3f6ec; color: #0b7a45; }
.type-tag.payable_plus { background: #fdeeee; color: #b8262c; }
.type-tag.payable_minus { background: #fdeeee; color: #b8262c; }
.type-tag.none { background: var(--info-soft); color: var(--brand); }

/* =========================================================
   LEDGER REGISTER (inspired by the WordPress register)
========================================================= */
.register-card { display: flex; flex-direction: column; overflow: hidden; }
.register-scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 260px; }
@media (max-width: 899px) {
  .register-scroll { max-height: none; }
  .register-card { overflow: visible; }
}
.register-table td { vertical-align: top; }
.register-table tr.opening-row td, .register-table tr.closing-row td { background: var(--surface-2); font-weight: 700; }
.register-table tr.tint-receivable_minus td { background: #f0faf4; }
.register-table tr.tint-payable_minus td { background: #fdf3f3; }
.register-table tr.tint-none td { background: #f3f7ff; }
.register-table tr.tint-pending td { background: #fffaeb; }
.register-table tr.tint-pending td:first-child { box-shadow: inset 4px 0 0 #f0a500; }
.register-table tr.tint-none td:first-child { box-shadow: inset 4px 0 0 #6b95e8; }
.register-table .date-cell, .register-table .tx-no { white-space: nowrap; font-weight: 600; }
.register-table .items-cell { min-width: 180px; }
.register-table .items-cell .more { font-size: 12px; color: var(--muted); }
.rate-edit { display: inline-flex; gap: 2px; align-items: center; }
.rate-edit .input { width: 92px; min-height: 30px; padding: 3px 8px; font-size: 13px; text-align: right; }
.rate-edit .icon-btn { width: 26px; height: 26px; }

.total-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px;
  padding: 12px 16px;
  background: #1b2742; color: #fff;
}
.total-bar .t-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #9fb0d3; font-weight: 700; }
.total-bar .t-value { font-size: 15px; font-weight: 800; }
.total-bar .t-get { color: #5fe0a0; }
.total-bar .t-pay { color: #ff8a8f; }
.total-bar .closing { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .12); }
@media (max-width: 899px) {
  .total-bar {
    position: sticky; bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); border-radius: 12px 12px 0 0;
    grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; padding: 10px 12px;
  }
  .total-bar .t-value { font-size: 13px; }
  .total-bar .t-label { font-size: 9.5px; }
  .total-bar .closing { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; }
}
@media (min-width: 900px) {
  .total-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; }
  .total-bar .closing { grid-column: auto; padding: 0 0 0 24px; border-top: 0; border-left: 1px solid rgba(255, 255, 255, .15); }
}

/* Mobile register rows */
.reg-list .list-row { align-items: flex-start; }
.reg-list li.tint-pending { background: #fffaeb; box-shadow: inset 4px 0 0 #f0a500; }
.reg-list li.tint-receivable_minus { background: #f0faf4; }
.reg-list li.tint-payable_minus { background: #fdf3f3; }
.reg-list li.tint-none { background: #f3f7ff; }

/* =========================================================
   PARTIES — two-pane (Vyapar style)
========================================================= */
.split { display: grid; gap: 14px; }
@media (min-width: 1100px) {
  .split { grid-template-columns: 330px minmax(0, 1fr); align-items: start; }
  .split-list { position: sticky; top: 80px; }
}
@media (max-width: 1099px) {
  .split.has-detail .split-list { display: none; }
}
.party-list-scroll { max-height: calc(100vh - 230px); overflow-y: auto; }
@media (max-width: 1099px) { .party-list-scroll { max-height: none; } }
.party-list a.list-row.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.party-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.party-head .who { flex: 1; min-width: 200px; }
.party-head .name { font-size: 18px; font-weight: 800; }
.party-balance { text-align: right; }
.party-balance .label { font-size: 12px; font-weight: 700; }
.party-balance .value { font-size: 24px; font-weight: 800; }
.party-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.statement-table { display: none; }
@media (min-width: 700px) {
  .statement-table { display: block; }
  .statement-list { display: none; }
}

/* =========================================================
   ENTRY FORM (Vyapar invoice-like)
========================================================= */
.entry-head { display: grid; gap: 14px; }
@media (min-width: 900px) { .entry-head { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }
.type-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.party-balance-hint { font-size: 12.5px; font-weight: 700; }

.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  background: var(--surface-3); font-size: 11px; font-weight: 700; color: #4b5870;
  text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 8px 10px;
}
.items-table td { padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.items-table .input { min-height: 36px; padding: 6px 10px; }
.items-table .sn { width: 36px; text-align: center; color: var(--muted); font-weight: 600; }
.items-table .amt { text-align: right; font-weight: 700; white-space: nowrap; padding-right: 12px; }
.items-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }

/* Items become stacked cards on phones */
@media (max-width: 899px) {
  .items-table thead { display: none; }
  .items-table, .items-table tbody { display: block; }
  .items-table tr[data-item] {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
    margin: 10px 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  }
  .items-table tr[data-item] td { display: block; padding: 0; border: 0; }
  .items-table .sn { display: none !important; }
  .items-table .td-name { grid-column: 1 / -1; }
  .items-table .amt { grid-column: 1 / 3; text-align: left; align-self: center; }
  .items-table .td-remove { justify-self: end; }
  .items-table [data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
}

.summary-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.summary-box .total-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.summary-box .total-line .input { max-width: 200px; text-align: right; font-weight: 800; font-size: 18px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 18px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2);
  cursor: pointer; color: var(--muted); font-size: 13.5px;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone .icon { width: 28px; height: 28px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb {
  position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--surface); font-size: 12px;
}
.thumb img { display: block; width: 100%; height: 88px; object-fit: cover; }
.thumb .file { height: 88px; display: grid; place-items: center; font-weight: 800; color: var(--pay); background: var(--pay-soft); }
.thumb .name { padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb.removed { opacity: .4; }
.thumb label { display: flex; gap: 4px; padding: 0 6px 6px; align-items: center; }

/* =========================================================
   ALERTS, ACTIVITY, AUTH, PAGINATION
========================================================= */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; border: 1px solid; }
.alert-success { background: var(--get-soft); border-color: #bfe9d1; color: #0b5e37; }
.alert-error { background: var(--pay-soft); border-color: #f7c6c8; color: #8f1d22; }
.alert-info { background: var(--brand-soft); border-color: #c5d8fb; color: #173f8f; }
.alert-warn { background: var(--pending-soft); border-color: #f5dc9c; color: #7a4a00; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 16px; border-top: 1px solid var(--border); }
.timeline li:first-child { border-top: 0; }
.timeline .who { font-size: 13px; }
.changes { margin: 6px 0 0; font-size: 13px; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; }
.changes dt { color: var(--muted); text-transform: capitalize; }
.changes dd { margin: 0; overflow-wrap: anywhere; }
.changes del { color: var(--pay); }
.changes ins { color: var(--get); text-decoration: none; }

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(160deg, var(--nav-bg) 0%, #1f3a78 55%, var(--brand) 100%);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; color: #fff; font-size: 20px; }

.pagination { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; font-size: 13.5px; }

/* =========================================================
   PRINT
========================================================= */
.print-only { display: none; }
@media print {
  .sidebar, .bottom-nav, .topbar, .no-print, .toolbar, .filters, form.no-print, .alert { display: none !important; }
  .main { margin: 0; padding: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #999; border-radius: 0; }
  body { background: #fff; font-size: 11px; }
  .print-only { display: block !important; }
  .statement-table { display: block !important; }
  .statement-list, .reg-list { display: none !important; }
  .register-scroll { max-height: none; overflow: visible; }
  .register-scroll.desktop-only { display: block !important; }
  .mobile-only { display: none !important; }
  .table th { position: static; }
  .total-bar { position: static; background: #fff; color: #000; border-top: 2px solid #000; display: flex; flex-wrap: wrap; gap: 16px; }
  .total-bar .t-label, .total-bar .t-get, .total-bar .t-pay { color: #000; }
  .register-table tr[class*="tint-"] td { background: #fff !important; box-shadow: none !important; }
  .rate-edit, .icon-btn { display: none !important; }
}

.wide-only { display: none; }
@media (min-width: 1100px) { .wide-only { display: block; } }
@media (min-width: 700px) { .grid-2-md { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
