/* Nan Pao Resins India — finance dashboard, modern house style (23 Sep 2026).
   Identity kept: company red C00000, Calibri, grey section band F2F2F2, logo, lakh amounts,
   accounting totals (double rule). Modern layer: left sidebar, soft cards, rounded controls. */
:root {
  color-scheme: light;
  --red: #C00000;
  --red-dark: #960000;
  --red-50: #FDF2F2;
  --red-100: #F9E0E0;
  --red-200: #F0BFBF;
  --ink: #1A1A1A;
  --body: #1F1F1F;
  --muted: #5F6368;
  --muted-2: #4A4A4A;
  --muted-3: #8A8F95;
  --shade: #F2F2F2;          /* house grey band */
  --shade-2: #FAFAFA;
  --border: #D5D7DB;
  --border-light: #E8E9EC;
  --paper: #FFFFFF;
  --page: #F5F6F8;
  --good: #0F7A3D;
  --good-50: #EAF6EF;
  --warn: #8A5A00;
  --warn-50: #FFF6E0;
  --info: #1D4F91;
  --info-50: #EAF1FB;
  --debit: #A30000;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-hover: 0 4px 16px rgba(16, 24, 40, .10);
  --sidebar-w: 232px;
  --font: Calibri, Carlito, "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--body); background: var(--page); min-height: 100vh; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 700; color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3.sub-head { font-size: 15px; margin-top: 20px; margin-bottom: 8px; }
h2.sub-head { margin-top: 24px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.req { color: var(--red); }
.ico { width: 20px; height: 20px; flex: none; }

/* ---------- App shell: sidebar + content ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.has-sidebar .shell { margin-left: var(--sidebar-w); }
.container { max-width: 1400px; margin: 0 auto; padding: 26px 28px; width: 100%; flex: 1; }
.footer { text-align: center; font-size: 12px; color: var(--muted-3); padding: 16px 24px 24px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--paper);
  border-right: 1px solid var(--border-light); display: flex; flex-direction: column; z-index: 40;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; border-bottom: 1px solid var(--border-light); }
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand img { height: 36px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: var(--red); font-size: 18px; letter-spacing: .02em; text-transform: uppercase; }
.brand-text small { color: var(--muted); font-size: 12px; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-3); margin: 16px 10px 6px; }
.side-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: var(--radius-sm);
  color: var(--muted-2); font-weight: 600; position: relative;
}
.side-link:hover { background: var(--shade-2); color: var(--ink); text-decoration: none; }
.side-link.active { background: var(--red-50); color: var(--red); }
.side-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.side-sub { margin: 2px 0 8px 22px; padding-left: 12px; border-left: 1px solid var(--border-light); }
.side-sub a { display: block; padding: 6px 10px; border-radius: 6px; font-size: 14px; color: var(--muted); }
.side-sub a:hover { color: var(--ink); background: var(--shade-2); text-decoration: none; }
.side-sub a.active { color: var(--red); font-weight: 700; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border-light); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.side-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.side-user-text strong { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text small { font-size: 12px; color: var(--muted); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--shade); color: var(--red); }
.icon-btn .ico { width: 18px; height: 18px; }

.nav-toggle, .mobilebar, .nav-scrim { display: none; }
@media (max-width: 960px) {
  .has-sidebar .shell { margin-left: 0; }
  .mobilebar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; background: var(--paper); border-bottom: 1px solid var(--border-light); padding: 10px 16px; }
  .mobilebar .brand { display: flex; align-items: center; gap: 10px; color: var(--red); font-weight: 700; font-size: 16px; }
  .mobilebar .brand img { height: 28px; }
  .mobilebar-menu { display: inline-flex; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--ink); }
  .mobilebar-menu:hover { background: var(--shade); }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-hover); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 35; }
  .container { padding: 20px 16px; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p.muted { margin: 4px 0 0; }
.page-head h1 .chip { vertical-align: middle; margin-left: 6px; }
.crumbs { font-size: 13px; margin-bottom: 4px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--red); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.balance-box { text-align: right; }
.balance-box .btn { margin-top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--shade-2); border-color: var(--muted-3); text-decoration: none; }
.btn:focus-visible, .side-link:focus-visible, a:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 1px 2px rgba(192, 0, 0, .25); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--shade); color: var(--ink); border-color: transparent; }
.btn-danger { background: var(--paper); border-color: var(--red-200); color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.inline { display: inline; }

/* ---------- Flash messages ---------- */
.flashes { margin-bottom: 18px; }
.flash { padding: 11px 14px 11px 16px; border: 1px solid var(--border-light); border-left: 4px solid var(--muted-3); border-radius: var(--radius-sm); background: var(--paper); margin-bottom: 8px; box-shadow: var(--shadow); }
.flash-success { border-left-color: var(--good); background: var(--good-50); border-color: #cfe9d9; }
.flash-error { border-left-color: var(--red); background: var(--red-50); border-color: var(--red-100); }

/* ---------- Tiles, KPIs, cards ---------- */
.tiles, .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tile, .kpi {
  display: block; background: var(--paper); border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 18px 20px; color: inherit; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s;
}
a.tile:hover, .kpi:hover { text-decoration: none; box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.tile-alert, .kpi-alert { border-color: var(--red-100); background: linear-gradient(180deg, var(--red-50) 0%, var(--paper) 70%); }
.tiles-compact .tile { padding: 12px 16px; }
.tiles-compact .tile-value { font-size: 21px; }
.tile-selected { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-50), var(--shadow); }
.tile-label, .kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.tile-value, .kpi-value { font-size: 28px; font-weight: 700; color: var(--ink); margin: 6px 0 2px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-value { font-size: 30px; }
.kpi-alert .kpi-value, .tile-alert .tile-value { color: var(--red); }
.tile-sub, .kpi-sub { font-size: 13px; color: var(--muted); }
.tile-value-2 { font-size: 20px; color: var(--ink); }
.tile-value.credit { color: var(--good); }
.tile-value.debit { color: var(--debit); }
.delta { display: inline-block; font-size: 12px; font-weight: 700; margin-top: 4px; padding: 1px 8px; border-radius: 999px; }
.delta.up { color: var(--good); background: var(--good-50); }
.delta.down { color: var(--red); background: var(--red-50); }
.kpi-split { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border-light); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-split b { color: var(--ink); font-weight: 700; margin-right: 3px; }
.kpi-split small { color: var(--muted-3); }

.section-head, .panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { display: block; background: var(--paper); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 16px 18px; color: inherit; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s; }
a.card:hover, .card:hover { text-decoration: none; box-shadow: var(--shadow-hover); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-title { font-weight: 700; color: var(--ink); }
.card-sub { font-size: 13px; color: var(--muted); }
.card-value { font-size: 22px; font-weight: 700; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.card-foot { font-size: 12px; color: var(--muted); }
.chip { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 2px 9px; background: var(--shade); border: 1px solid var(--border-light); color: var(--muted-2); border-radius: 999px; }
.chip-light { background: rgba(255, 255, 255, .9); }
.chip-export { background: var(--red-50); border-color: var(--red-100); color: var(--red); }
.chip-domestic { background: var(--shade); }
.count { font-size: 11px; font-weight: 700; background: var(--shade); border: 1px solid var(--border-light); padding: 1px 7px; border-radius: 999px; margin-left: 4px; color: var(--muted); }
.section-title { font-size: 18px; margin: 8px 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title::before { content: ""; width: 4px; height: 20px; border-radius: 2px; background: var(--red); }

/* ---------- Panels and grids ---------- */
.panel { background: var(--paper); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow); overflow-x: auto; }
.panel-narrow { max-width: 680px; }
.panel h2 { margin-bottom: 12px; }
.panel .panel-head h2 { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2.grid-wide { grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr)); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 > .panel, .grid-3 > .panel { margin-bottom: 20px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 960px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.chart-wrap { position: relative; height: 240px; margin-bottom: 10px; }
.empty { background: var(--paper); border: 1px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center; margin-bottom: 24px; }
.empty h2 { font-size: 20px; margin-bottom: 8px; }
.empty-inline { padding: 12px 0; }

/* ---------- Tables: house grey band header, accounting totals ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; }
.table thead th {
  background: var(--shade); color: var(--muted-2); font-size: 12px; font-weight: 700; letter-spacing: .02em;
  border-bottom: 1px solid var(--border-light); vertical-align: bottom;
}
.table .col-name { min-width: 190px; }
.table thead th.num { white-space: normal; }
.table thead th:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.table thead th:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.table tbody td { border-bottom: 1px solid #F0F1F3; }
.table tbody tr:hover td { background: var(--shade-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .credit { color: var(--good); }
.table .debit { color: var(--debit); }
.table .ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-2 .table .ellipsis { max-width: 190px; }
.table-compact td, .table-compact th { padding: 7px 10px; font-size: 13px; }
.table tfoot td { font-weight: 700; border-top: 3px double var(--body); padding-top: 10px; }
.row-actions { white-space: nowrap; text-align: right; }
.table .nowrap { white-space: nowrap; }
.row-inactive td { color: var(--muted-3); }
.kv td:first-child { color: var(--muted); width: 38%; }

/* ---------- Status and badges ---------- */
.status { display: inline-block; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-good { color: var(--good); }
.status-critical { color: var(--red); }
.status-open { color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border-light); background: var(--shade); color: var(--muted-2); vertical-align: middle; }
.badge-submitted { background: var(--warn-50); border-color: #F2DDA0; color: var(--warn); }
.badge-reviewed { background: var(--info-50); border-color: #C7D8F2; color: var(--info); }
.badge-approved { background: var(--good-50); border-color: #BFE3CD; color: var(--good); }
.badge-paid { background: #DDF2E5; border-color: #9ED3B3; color: #0B5E2F; }
.badge-rejected { background: var(--red-50); border-color: var(--red-200); color: var(--red); }
.badge-cancelled { text-decoration: line-through; }
/* Under litigation: charcoal, deliberately not red - these are not chased as overdue */
.badge-litigation { background: #3A3A3A; border-color: #3A3A3A; color: #fff; white-space: nowrap; }
.tile-litigation { border-color: #cfcfcf; background: linear-gradient(180deg, #F2F2F2 0%, var(--paper) 70%); }
.flash-litigation { border-left-color: #3A3A3A; background: var(--shade); }

/* Collection follow-up */
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .row-3 { grid-template-columns: 1fr; } }
.fu-add { margin-bottom: 14px; }
.fu-add > summary { list-style: none; display: inline-flex; }
.fu-add > summary::-webkit-details-marker { display: none; }
.fu-add[open] > summary { margin-bottom: 12px; }
.fu-form { background: var(--shade-2); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 14px 16px 4px; margin-bottom: 8px; }
.badge-promise-kept { background: var(--good-50); border-color: #BFE3CD; color: var(--good); }
.badge-promise-due { background: var(--red-50); border-color: var(--red-200); color: var(--red); }
.badge-promise-pending { background: var(--warn-50); border-color: #F2DDA0; color: var(--warn); }
.fu-next { font-size: 12px; color: var(--muted); font-weight: 400; display: block; }
.fu-next.due { color: var(--red); font-weight: 700; }

/* Change history */
.hist-changes { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.hist-changes li { padding: 1px 0; }
.hist-changes .old { color: var(--debit); text-decoration: line-through; }
.hist-changes .new { color: var(--good); }
.badge-insert { background: var(--good-50); border-color: #BFE3CD; color: var(--good); }
.badge-update { background: var(--info-50); border-color: #C7D8F2; color: var(--info); }
.badge-delete { background: var(--red-50); border-color: var(--red-200); color: var(--red); }

/* ---------- Forms ---------- */
form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted-2); margin-bottom: 14px; }
form input[type=text], form input[type=password], form input[type=date], form input[type=search], form input[type=email],
form select, form textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 12px; font: inherit; font-size: 15px; font-weight: 400;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--paper); color: var(--body);
  transition: border-color .15s, box-shadow .15s;
}
form input:hover, form select:hover, form textarea:hover { border-color: var(--muted-3); }
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(192, 0, 0, .12); }
form input[type=file] { display: block; margin-top: 6px; font: inherit; font-size: 13px; }
form small { display: block; font-weight: 400; margin-top: 5px; color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--red); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .row-2 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.rate-row { display: flex; align-items: center; gap: 12px; }
.rate-row input { width: 160px; margin-top: 0; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-light); }
.inline-form { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border-light); }
.inline-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin: 0; }
.inline-label input { margin: 0; }
details summary { cursor: pointer; }
.fx-details { margin: 4px 0 14px; }
.fx-details[open] summary { margin-bottom: 8px; }

/* ---------- Toolbar, tabs, search, segmented control ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--paper); border: 1px solid var(--border-light); border-radius: 10px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; color: var(--muted-2); font-weight: 600; border-radius: 7px; }
.tabs a.active { background: var(--red); color: #fff; }
.tabs a.active .count { background: rgba(255, 255, 255, .2); border-color: transparent; color: #fff; }
.tabs a:hover { text-decoration: none; }
.tabs a:not(.active):hover { background: var(--shade); }
.search { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.search .btn { white-space: nowrap; }
.search input, .search select { width: auto; min-width: 160px; margin: 0; padding: 7px 12px; }
.search input[type=search] { width: 240px; }
.search input[type=date] { min-width: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--shade); border-radius: 8px; font-size: 12px; }
.seg a { padding: 3px 10px; color: var(--muted); font-weight: 600; border-radius: 6px; }
.seg a.active { background: var(--paper); color: var(--red); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg a:hover { text-decoration: none; color: var(--ink); }

/* ---------- Misc lists ---------- */
ul.plain { list-style: none; padding: 0; margin: 0; font-size: 13px; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid #F0F1F3; }
pre.log { font: 12px/1.45 Consolas, monospace; background: var(--shade-2); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; }
code { font: 13px Consolas, monospace; background: var(--shade); padding: 1px 5px; border-radius: 4px; }
.att-list { list-style: none; padding: 0; margin: 0 0 10px; }
.att-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #F0F1F3; flex-wrap: wrap; }
.att-form { margin-top: 12px; }
.alloc-table input.alloc-amt { width: 130px; margin: 0; padding: 5px 8px; text-align: right; }
.alloc-table input[type=checkbox] { width: 16px; height: 16px; }
.alloc-summary { display: flex; gap: 28px; padding: 12px 0; border-top: 1px solid var(--border-light); margin-top: 8px; font-size: 14px; }
.alloc-summary strong.over { color: var(--red); }
.plain-link { color: inherit; }
.plain-link:hover { color: var(--red); }

/* Settings > Email alerts */
.alerts-wrap { overflow-x: auto; }
.alerts-table td { vertical-align: top; }
.alerts-table textarea { min-width: 170px; margin-top: 0; font-size: 13px; padding: 7px 9px; }
form label.check { display: flex; align-items: center; gap: 7px; font-weight: 400; color: var(--body); margin: 0 0 5px; white-space: nowrap; }
form label.check input { width: 15px; height: 15px; margin: 0; }
.check-list { max-height: 240px; overflow-y: auto; columns: 2; column-gap: 24px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; }
@media (max-width: 700px) { .check-list { columns: 1; } }
.check-list label.check { white-space: normal; break-inside: avoid; }
.inline-controls { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.inline-controls input[type=search] { width: 240px; margin: 0; padding: 7px 12px; }

/* ---------- Dashboard: total cash hero + bank cards ---------- */
.cash-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  background: var(--red); color: #fff; border-radius: var(--radius); padding: 22px 26px; margin-bottom: 16px;
  box-shadow: 0 6px 20px rgba(192, 0, 0, .22); position: relative; overflow: hidden;
}
.cash-summary::after { content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .07); pointer-events: none; }
.cash-summary .kpi-label { color: rgba(255, 255, 255, .85); }
.cash-summary .kpi-label .chip { margin-left: 8px; vertical-align: middle; background: rgba(255, 255, 255, .18); border-color: transparent; color: #fff; }
.cash-summary-amount { font-size: 36px; font-weight: 700; color: #fff; letter-spacing: -.01em; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.cash-summary-side { display: flex; gap: 12px; position: relative; z-index: 1; }
.cash-stat { display: flex; flex-direction: column; align-items: flex-end; text-align: right; background: rgba(255, 255, 255, .12); border-radius: 10px; padding: 8px 14px; }
.cash-stat-n { font-size: 22px; font-weight: 700; color: #fff; line-height: 1.2; }
.cash-stat-n.up, .cash-stat-n.down { color: #fff; }
.cash-stat-l { font-size: 12px; color: rgba(255, 255, 255, .85); }
.bank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; margin-bottom: 26px; }
.bank-card {
  position: relative; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 16px 18px 14px; color: inherit; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s; overflow: hidden;
}
.bank-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand, var(--ink)); }
.bank-card:hover { text-decoration: none; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.bank-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.bank-logo-box { display: flex; align-items: center; height: 32px; min-width: 0; }
.bank-logo-box .bank-logo { height: auto; max-height: 30px; max-width: 120px; width: auto; }
.bank-name { font-weight: 700; color: var(--ink); font-size: 14px; line-height: 1.25; }
.bank-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bank-amount { font-size: 23px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; line-height: 1.15; margin-top: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bank-amount-2 { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bank-foot { font-size: 12px; color: var(--muted-3); margin-top: auto; padding-top: 10px; }
@media (max-width: 760px) { .bank-grid { grid-template-columns: repeat(2, 1fr); } .cash-summary-side { width: 100%; justify-content: flex-start; } .cash-stat { align-items: flex-start; text-align: left; } }
@media (max-width: 460px) { .bank-grid { grid-template-columns: 1fr; } .cash-summary-amount { font-size: 30px; } }
.bank-logo { height: 28px; width: auto; max-width: 96px; object-fit: contain; }
.bank-logo.lg { height: 44px; max-width: 140px; } .bank-logo.sm { height: 18px; max-width: 60px; margin-right: 8px; vertical-align: middle; }
.bank-mono { display: inline-flex; align-items: center; justify-content: center; height: 28px; min-width: 28px; padding: 0 8px; border-radius: 6px; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .04em; }
.bank-mono.lg { height: 44px; min-width: 44px; font-size: 16px; } .bank-mono.sm { height: 18px; min-width: 18px; font-size: 9px; padding: 0 5px; margin-right: 8px; vertical-align: middle; }
.with-logo { display: flex; align-items: center; gap: 14px; }

/* ---------- Approval workflow strip ---------- */
.workflow-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 24px; }
.wf { display: flex; align-items: center; gap: 14px; background: var(--paper); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 12px 16px; color: inherit; box-shadow: var(--shadow); }
.wf:hover { text-decoration: none; box-shadow: var(--shadow-hover); }
.wf-n { font-size: 20px; font-weight: 800; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--shade); color: var(--muted-2); flex: none; }
.wf-hot { border-color: var(--red-200); } .wf-hot .wf-n { background: var(--red); color: #fff; }
.wf small { color: var(--muted); }
.req-card .card-value { font-size: 20px; }
.approvals .card { border-top: 3px solid var(--red); }

/* ---------- Analysis ---------- */
.analysis .panel { min-width: 0; }
.donut-wrap { position: relative; height: 200px; margin: 4px 0 10px; }
.chart-short { height: 200px; }
.legend-table td:first-child { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analysis .legend-table { table-layout: fixed; }
.analysis .legend-table td:first-child, .analysis .legend-table th:first-child { width: 58%; max-width: none; }
.analysis .legend-table td, .analysis .legend-table th { padding-left: 6px; padding-right: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; background: var(--border); }

/* ---------- Grouped tables, reconciliation ---------- */
.grouped .group-row { cursor: pointer; }
.grouped .group-row td { background: var(--shade-2); border-top: 1px solid var(--border-light); padding-top: 11px; padding-bottom: 11px; }
.grouped .group-row .caret { color: var(--muted); font-size: 12px; transition: transform .15s; display: inline-block; }
.grouped .group-row.open .caret { transform: rotate(90deg); }
.grouped .group-item td:nth-child(2) { padding-left: 18px; }
.recon { border-left: 4px solid var(--border); }
.recon-ok { border-left-color: var(--good); } .recon-diff { border-left-color: var(--red); }
.recon-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 8px 0 12px; }

/* ---------- Statement / letterhead (Nan Pao house layout, printable) ---------- */
.statement { background: var(--paper); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 36px; max-width: 980px; margin: 0 auto 20px; }
.letterhead { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; border-bottom: 2px solid var(--red); padding-bottom: 10px; margin-bottom: 18px; }
.letterhead img { height: 54px; width: auto; }
.lh-text { text-align: center; }
.lh-company { color: var(--red); font-size: 17px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.lh-title { color: var(--ink); font-size: 13px; font-weight: 700; margin-top: 2px; }
.lh-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.stmt thead th { background: var(--shade); }
.stmt .section-row td { font-weight: 700; background: var(--shade-2); }
.stmt tfoot td { font-weight: 700; }
.stmt tfoot tr.subtotal td { border-top: 1px solid var(--body); border-bottom: none; }
.stmt tfoot tr.grand td { border-top: 3px double var(--body); }
.signatures { display: flex; justify-content: space-between; margin-top: 40px; font-size: 13px; }
.signatures .right { text-align: right; }
.notes { margin-top: 20px; }
.print-only { display: none; }
.report-wide { max-width: none; }
.scroll-x { overflow-x: auto; }
.aging-table { font-size: 12px; white-space: nowrap; }
.aging-table th, .aging-table td { padding: 6px 8px; }
.aging-table .section-row td { font-weight: 700; background: var(--shade-2); }
.aging-table tr.subtotal td { font-weight: 700; border-top: 1px solid var(--body); }
.aging-table tfoot tr.grand td { font-weight: 700; border-top: 3px double var(--body); font-size: 12px; }

/* ---------- Auth pages ---------- */
.no-sidebar .shell { background: radial-gradient(1200px 500px at 50% -10%, var(--red-50) 0%, var(--page) 60%); }
.auth-card { max-width: 420px; margin: 10vh auto 4vh; background: var(--paper); border: 1px solid var(--border-light); border-radius: 16px; padding: 36px 34px 30px; box-shadow: 0 10px 40px rgba(16, 24, 40, .10); position: relative; overflow: hidden; }
.auth-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--red); }
.auth-card h1 { color: var(--red); text-transform: uppercase; font-size: 20px; letter-spacing: .03em; margin-bottom: 6px; text-align: center; }
.auth-card > p.muted { text-align: center; margin-bottom: 22px; }
.auth-card .btn { margin-top: 8px; padding: 11px 16px; }
.auth-logo { height: 56px; width: auto; display: block; margin: 0 auto 14px; }

/* ---------- Print ---------- */
@media print { .aging-table { font-size: 9px; } .aging-table th, .aging-table td { padding: 2px 4px; } .report-wide { padding: 0; } @page { size: A4 landscape; margin: 10mm; } }
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .mobilebar, .nav-scrim, .footer, .no-print, .actions, .page-head .actions, .flashes, .row-actions, .btn { display: none !important; }
  .has-sidebar .shell { margin-left: 0; }
  .container { padding: 0; max-width: none; }
  .statement, .panel { border: none; padding: 0; margin: 0 0 12px; box-shadow: none; border-radius: 0; }
  .table thead th { border-radius: 0 !important; }
  .print-only { display: grid; }
  .table { font-size: 11px; }
  a { color: inherit; text-decoration: none; }
  @page { size: A4 portrait; margin: 12mm; }
}

/* "Data updated" notice (NOTES 32 e): on screen only; .no-print keeps it out of every printout / PDF */
.data-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; color: var(--ink);
  background: var(--shade); border-left: 4px solid var(--red); border-radius: var(--radius-sm); padding: 8px 14px; margin-bottom: 14px; }
.data-notice .sep { color: var(--muted); }
.data-notice a { color: var(--red); }

[data-href] { cursor: pointer; }      /* whole row / card opens the record (NOTES 40) */

/* Share bank details (NOTES 39) */
.share-acc { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid #F0F1F3;
  font-size: 15px; font-weight: 400; color: var(--body); cursor: pointer; }
.share-acc:last-child { border-bottom: none; }
.share-acc input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--red); }
.share-acc .muted { display: block; margin-top: 2px; }
.share-text { display: block; width: 100%; font: 14px/1.5 var(--font); color: var(--body); background: var(--shade-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; resize: vertical; }
.share-actions { margin-top: 12px; }

/* =================================================================== PHONES
   NOTES 33 / MOBILE-DESIGN-GUIDE.md (29 Sep 2026): the same phone treatment as the Shipment Tracker.
   Everything below applies ONLY to screens up to 700 px wide (a phone held upright; reference phone
   Motorola Edge 70 Pro, ~412 px). The desktop layout above is untouched - the user's rule - and so is
   printing: the block is "screen and", so a printout never picks it up. Display only: no figure changes. */
.m-only { display: none; }            /* phone-only elements; never shown on a desktop */
@media screen and (max-width: 700px) {
  .m-only { display: revert; }
  .nb { white-space: nowrap; }          /* amounts in running text, wrapped by mobile.js on phones only */

  /* P7 readable text, P6 thumb-sized targets; 16 px in fields stops phones zooming in on tap */
  body { font-size: 15px; }
  h1 { font-size: 21px; }
  h2 { font-size: 16.5px; }
  .chip, .count, .side-label, .lh-meta, .bank-mono.sm { font-size: 12px; }
  .btn, .btn-sm { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .icon-btn { width: 44px; height: 44px; }
  form input[type=text], form input[type=password], form input[type=date], form input[type=search], form input[type=email],
  form select, form textarea, .search input, .search select { min-height: 46px; font-size: 16px; }
  form label { font-size: 13px; }
  small, form small { font-size: 12.5px; }
  form label.check { white-space: normal; min-height: 44px; align-items: center; }
  input[type=radio], form label.check input { width: 22px; height: 22px; flex: none; }

  /* P1 slim top bar: logo, page title and the menu; menu items 48 px; Log out apart and in red */
  .mobilebar { padding: 6px 10px; gap: 8px; }
  .mobilebar-menu { width: 46px; height: 44px; align-items: center; justify-content: center; flex: none; }
  .mobilebar .brand span { display: none; }
  .mobilebar-title { display: block; flex: 1; min-width: 0; font-weight: 700; font-size: 15.5px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-link { min-height: 48px; }
  .side-sub a { display: flex; align-items: center; min-height: 44px; font-size: 15px; }
  .side-user { flex-wrap: wrap; }
  .side-user form.inline { flex: 1 1 100%; order: 3; }
  .logout-btn { width: 100%; height: 46px; gap: 8px; margin-top: 6px; color: var(--red); font-weight: 700; font-size: 15px;
    border: 1px solid var(--red-200); background: var(--paper); }
  .logout-btn .m-only { display: inline; }

  .container { padding: 12px 12px 40px; }

  /* P2 page header: title on its own line, actions in a row below sharing the width */
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 14px; }
  .page-head > .actions, .page-head > form.search, .toolbar > form.search, .toolbar > .actions { width: 100%; }
  .actions .btn, .search .btn, .form-actions .btn { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
  .balance-box { text-align: left; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .search input, .search select { flex: 1 1 140px; min-width: 0; width: auto; }
  .search input[type=search], .inline-controls input[type=search] { flex: 1 1 100%; width: 100%; }
  .search .inline-label { flex: 1 1 100%; }
  .search .inline-label input { flex: 1; }
  .tabs { display: flex; }
  .tabs a { flex: 1 1 auto; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
  .seg a { min-height: 40px; display: inline-flex; align-items: center; }

  /* P3 dashboard cards: two per row where the (short) figures fit, one per row for full amounts */
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 12px 10px; }
  .kpi, .tile, .panel, .bank-card, .wf { border-color: #C4C8CE; }   /* NOTES 37: outline only, slightly more visible */
  .kpi-value { font-size: 22px; }
  .kpi-sub, .tile-sub { font-size: 12.5px; }
  .kpi-split { gap: 6px 12px; }
  .tiles { grid-template-columns: 1fr; gap: 10px; }
  .tile { padding: 14px 16px; }
  .tile-value { font-size: 23px; }
  .cash-summary { padding: 16px 18px; gap: 12px; }
  .cash-summary-amount { font-size: 28px; }
  .workflow-strip { grid-template-columns: 1fr; gap: 10px; }
  .wf { min-height: 56px; }

  /* Panels breathe less; P9 tap a panel heading to fold it (mobile.js), the ▾ shows it can */
  .panel { padding: 14px; margin-bottom: 12px; overflow-x: visible; }
  .panel-head { flex-wrap: nowrap; }
  .panel-head > h2 { flex: 1; min-width: 0; }
  .panel-head > :not(h2) { flex: none; }
  .panel > h2, .panel > .panel-head { cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .panel > h2::before, .panel > .panel-head > h2::before { content: "▾"; display: inline-block; margin-right: 6px; color: var(--muted);
    font-size: 13px; transition: transform .15s; }
  .panel.collapsed > h2, .panel.collapsed > .panel-head { margin-bottom: 0; }
  .panel.collapsed > h2::before, .panel.collapsed > .panel-head > h2::before { transform: rotate(-90deg); }
  .panel.collapsed > :not(h2):not(.panel-head) { display: none !important; }
  .grid-2, .grid-3 { gap: 0; }
  .table .ellipsis, .grid-2 .table .ellipsis, .legend-table td:first-child { max-width: 46vw; }

  /* P4 tables -> cards: "LABEL ........ value" per line; labels are the column headings (mobile.js).
     Amounts never break across lines. Tables with class no-cards stay tables. */
  table.rt thead { display: none; }
  table.rt, table.rt tbody, table.rt tfoot, table.rt tr, table.rt td { display: block; width: 100%; }
  /* NOTES 37: card outline slightly darker than before (#E8E9EC was too faint on a phone); design otherwise unchanged */
  table.rt tr { background: var(--paper); border: 1px solid #C4C8CE; border-radius: 12px; padding: 4px 12px;
    margin-bottom: 10px; box-shadow: var(--shadow); }
  table.rt tbody tr:hover td { background: transparent; }
  table.rt tfoot tr { background: var(--shade); }
  table.rt td, table.rt tfoot td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 8px 0;
    border: 0; border-bottom: 1px dashed var(--border-light); font-size: 14.5px; text-align: right; overflow-wrap: break-word; }
  table.rt td:last-child { border-bottom: none; }
  table.rt td::before { content: attr(data-label); flex: none; max-width: 48%; text-align: left; color: var(--muted);
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
  table.rt td[data-label=""] { justify-content: flex-start; text-align: left; }
  table.rt td[data-label=""]::before { content: none; }
  table.rt td:empty { display: none; }
  table.rt td.num, table.rt td.num * { white-space: nowrap; }
  table.rt td[colspan]:not([colspan="1"]) { display: block; text-align: left; }
  table.rt td.ellipsis { max-width: none; white-space: normal; }
  /* Settings > Email alerts: cells holding several tick-boxes or a text box stack under their label */
  .alerts-table.rt td { display: block; text-align: left; }
  .alerts-table.rt td::before { display: block; max-width: none; margin-bottom: 4px; }
  .alerts-table.rt textarea { min-width: 0; width: 100%; }
  table.rt td.row-actions { justify-content: flex-end; }
  table.rt td.row-actions:not(:has(*)) { display: none; }
  .grouped.rt .group-row td { background: transparent; border-top: 0; padding: 8px 0; }
  .grouped.rt .group-row td.caret { display: none; }                 /* the ▸ goes beside the name instead */
  .grouped.rt .group-row td:nth-child(2)::after { content: "▸"; margin-left: 8px; color: var(--muted); }
  .grouped.rt .group-row.open td:nth-child(2)::after { content: "▾"; }
  .grouped.rt .group-row { background: var(--shade-2); }
  .grouped.rt .group-item td:nth-child(2) { padding-left: 0; }
  .grouped.rt .group-item { margin-left: 12px; width: calc(100% - 12px); }
  table.rt input.alloc-amt { width: 60%; min-height: 44px; font-size: 16px; }
  table.rt input[type=checkbox] { width: 22px; height: 22px; }

  /* P5 ageing (14 buckets): stays a table, scrolls sideways inside its own box, party name pinned left;
     a phone summary sits above it (ageing.html) */
  .m-summary { display: grid; gap: 8px; margin-bottom: 12px; }
  .m-summary > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; background: var(--paper);
    border: 1px solid #C4C8CE; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
  .m-summary span { color: var(--muted); font-weight: 600; font-size: 13px; }
  .m-summary strong { font-size: 17px; white-space: nowrap; }
  .m-summary .debit { color: var(--debit); }
  .scroll-x { -webkit-overflow-scrolling: touch; }
  .aging-table th:first-child, .aging-table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper);
    box-shadow: 1px 0 0 var(--border-light); max-width: 42vw; white-space: normal; }
  .aging-table thead th:first-child { background: var(--shade); }
  .aging-table .section-row td:first-child { background: var(--shade-2); }

  /* Statement / report pages: the printed layout is untouched; on screen they fit the phone */
  .statement { padding: 14px 12px; border-radius: 12px; }
  .letterhead { grid-template-columns: 44px 1fr; gap: 8px; }
  .letterhead img { height: 40px; }
  .lh-company { font-size: 15px; }
  .signatures { flex-direction: column; gap: 24px; }
  .signatures .right { text-align: left; }

  /* P8 forms: one field per row, full width */
  .row-2, .row-3, .recon-grid { grid-template-columns: 1fr; }
  .rate-row input { width: 100%; }
  .check-list { columns: auto; }       /* one column in a fixed-height box overflowed sideways into extra columns */
  .alloc-summary { gap: 16px; flex-wrap: wrap; }

  /* P12 login: centred card on every phone width */
  .auth-card { width: calc(100% - 24px); max-width: 420px; margin: 6vh auto; padding: 26px 18px 22px; }
}
