/* MyKhata — WhatsApp-inspired two-column theme, polished
 *
 * DAY / NIGHT
 * Every colour in this file comes from a token below. The night palette is a
 * single @media (prefers-color-scheme: dark) block at the very bottom that
 * re-points those tokens — no rule outside it needs a dark variant, and no
 * script runs, so the theme follows the OS instantly with no flash before
 * paint and nothing to persist. Same arrangement theme/infra.css uses.
 *
 * Adding a colour? Put it in a token here and give it a night value at the
 * bottom. A raw hex in a rule is a bug: it will stay light-mode forever.
 */

:root {
    color-scheme: light dark;

    --bg: #d9dadb;                  /* slightly cooler chat bg */
    --panel: #ffffff;
    --panel-2: #fafbfc;
    --panel-grad: linear-gradient(180deg, #fbfcfd, #f6f8fa);
    --border: #e9edef;
    --border-strong: #d1d7db;
    --border-faint: #eef1f3;        /* hairline inside panels / between rows */
    --ink: #0f1a1f;
    --ink-dim: #667781;
    --ink-soft: #8696a0;

    /* Accent (teal). Slight cooler, richer than the flat WA green so the
       gradient buttons and active states feel modern. */
    --accent: #0aa988;
    --accent-2: #04b194;            /* gradient endpoint */
    --accent-dark: #048a6f;
    --accent-soft: #e6f6f1;
    --accent-ink: #ffffff;
    /* Saturated FILLS carrying light text (primary button, avatar, current
       page chip, owner tag) are a separate role from --accent/--accent-2,
       which are for text and icons. One value can't do both: a teal light
       enough to read as text on a dark panel is too light to carry white
       text on it. Identical to --accent/--accent-2 in day mode; the night
       block darkens only these. */
    --accent-fill: #0aa988;
    --accent-fill-2: #04b194;

    --accent-wash: rgba(10,169,136,.10);   /* icon-button hover */
    --accent-glow: rgba(10,169,136,.35);   /* brand-mark drop shadow */
    --accent-hero: rgba(10,169,136,.18);   /* empty-state radial wash */
    --ring-accent: 0 0 0 3px rgba(10,169,136,.18);  /* focus ring */

    /* --brand / --brand-soft are what the .tx-image-* rules were written
       against, but nothing ever defined them — so those declarations were
       invalid and dropped, leaving the attach-image button with no hover or
       selected colour at all. Aliased onto the accent, which is what they
       were clearly meant to be. */
    --brand: var(--accent);
    --brand-soft: var(--accent-wash);

    /* Surface of inputs, secondary buttons and pagination links. Separate
       from --panel: these sit ON a panel, so in dark mode they have to step
       away from it or the control disappears into the card. */
    --control: #ffffff;

    /* Text that sits on a saturated fill (accent button, danger button,
       image-overlay chip). Stays white in both themes — the fill underneath
       is dark in both. */
    --ink-on-dark: #ffffff;

    --header-bg: #f0f2f5;
    --head-grad: linear-gradient(180deg, #f3f5f7 0%, #ebedf0 100%);
    --hover: #f4f5f7;
    --active: #ebf6f2;              /* tinted with accent so it reads "selected" */
    --good: #058a55;
    --good-soft: #e7f6ee;
    --good-border: #b6e9c8;
    --bad: #c62828;
    --bad-soft: #fde7e9;
    --bad-border: #f6c5ca;
    --bad-strong: #b42334;          /* destructive hover TEXT */
    --bad-fill: #b42334;            /* destructive FILL under light text — see --accent-fill */
    --bad-wash: rgba(220,53,69,.08);/* logout row hover */
    --warn-bg: #fff6cf;
    --warn-ink: #6e4f00;
    --warn-border: #f3df8e;

    /* Canvas: the dotted-grid page background shared by .main and
       .history-pane, as a base colour plus two wash layers. */
    --canvas: #eef0f2;
    --canvas-wash: rgba(10,169,136,.06);
    --canvas-dot: rgba(11,20,26,.05);

    /* Overlay / scrim, and the white inner hairline that gives raised
       accent surfaces their lift. */
    --overlay: rgba(0,0,0,.6);
    --overlay-soft: rgba(0,0,0,.06);
    --inset-hilite: rgba(255,255,255,.18);
    /* Scrim on top of an accent fill (e.g. the count badge inside an active
       chip). Rides on a saturated colour that is dark in both themes, so it
       stays white — deliberately absent from the night block. */
    --accent-ink-wash: rgba(255,255,255,.25);

    --scroll-thumb: #c8d1d6;
    --scroll-thumb-hover: #a3afb6;

    --avatar-user-grad: linear-gradient(135deg, #586975, #7c8a96);

    /* Categorical pills — workspace roles and the ledger/customer/vendor
       chips. Each is a soft fill plus an ink that clears 4.5:1 on it. */
    --pill-red-bg: #fde9ec;     --pill-red-ink: #c0223b;
    --pill-green-bg: #e8f8ee;   --pill-green-ink: #198754;
    --pill-indigo-bg: #eef0ff;  --pill-indigo-ink: #4f46e5;
    --pill-muted-bg: #eef0f2;   --pill-muted-ink: #6b7280;

    --chip-indigo-bg: #eef2ff;  --chip-indigo-ink: #3730a3;  --chip-indigo-border: #c7d2fe;
    --chip-green-bg: #ecfdf5;   --chip-green-ink: #065f46;   --chip-green-border: #a7f3d0;
    --chip-amber-bg: #fef3c7;   --chip-amber-ink: #92400e;   --chip-amber-border: #fde68a;
    --chip-red-bg: #fef2f2;     --chip-red-ink: #991b1b;     --chip-red-border: #fecaca;

    /* Attention surfaces (unsaved-image notice, reminder banner). */
    --warn-surface: #fff8e1;
    --warn-surface-border: #ffe082;
    --warn-surface-ink: #6b4d00;
    --warn-surface-icon: #b26a00;

    /* Layered shadow tokens — softer + more modern than flat ones. */
    --shadow-sm: 0 1px 2px rgba(11,20,26,.05);
    --shadow:    0 1px 2px rgba(11,20,26,.04), 0 2px 6px rgba(11,20,26,.06);
    --shadow-md: 0 4px 10px rgba(11,20,26,.08), 0 1px 3px rgba(11,20,26,.06);
    --shadow-lg: 0 14px 36px rgba(11,20,26,.18), 0 4px 10px rgba(11,20,26,.08);
    --shadow-avatar: 0 1px 2px rgba(11,20,26,.08);
    --shadow-accent:       0 1px 2px rgba(10,169,136,.25), 0 3px 8px rgba(10,169,136,.20);
    --shadow-accent-hover: 0 1px 2px rgba(10,169,136,.30), 0 6px 14px rgba(10,169,136,.28);
    --shadow-accent-lg:    0 8px 20px rgba(10,169,136,.45);
    --shadow-danger: 0 4px 12px rgba(198,40,40,.22);

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;

    --ease: cubic-bezier(.2, .8, .2, 1);
    --t-fast: 120ms;
    --t:      180ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

a { color: var(--accent-dark); }
a:hover { color: var(--accent); }

/* --- App shell --- */
.app {
    display: flex;
    height: 100vh;
    max-width: 1500px;
    margin: 0 auto;
    background: var(--panel);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    /* Tiny rounded corners on desktop give it an app-like feel. */
    border-radius: 0;
}

/* ===== Sidebar (left column) ===== */
.sidebar {
    width: 380px;
    flex: 0 0 380px;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--border);
    min-width: 0;
}
.sidebar-head {
    background: var(--head-grad);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    height: 60px;
    flex: 0 0 auto;
}
.sidebar-head .brand {
    font-weight: 600;
    font-size: 17px;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -.2px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.sidebar-head .brand-mark {
    color: var(--accent);
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 1px 1px var(--accent-glow));
    margin-right: 4px;
}
.sidebar-userbar {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--panel-2);
    flex: 0 0 auto;
}
.sidebar-userbar .user-info {
    flex: 1 1 auto;
    min-width: 0;
}
.sidebar-userbar .user-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-userbar .user-email {
    font-size: 12px;
    color: var(--ink-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Workspace role chip under name/email — small pill, color-coded so the
   user sees their permission tier at a glance. Mirrors the role display
   we added to ep_menu.php for the invoice side. */
.sidebar-userbar .user-role {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    line-height: 1.5;
}
.sidebar-userbar .role-admin  { background: var(--pill-red-bg);    color: var(--pill-red-ink); }
.sidebar-userbar .role-editor { background: var(--pill-green-bg);  color: var(--pill-green-ink); }
.sidebar-userbar .role-viewer { background: var(--pill-indigo-bg); color: var(--pill-indigo-ink); }
.sidebar-list {
    flex: 1 1 auto;
    overflow-y: auto;
}
.sidebar-list::-webkit-scrollbar { width: 6px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 3px;
    transition: background var(--t) var(--ease);
}
.sidebar-list:hover::-webkit-scrollbar-thumb { background: var(--scroll-thumb-hover); }

/* Cross-app switcher pinned to the bottom of the sidebar. Sits below the
   scrollable .sidebar-list (flex: 1) so it stays visible no matter how
   many accounts the workspace has. */
.sidebar-foot {
    flex: 0 0 auto;
    border-top: 1px solid var(--border);
    background: var(--panel-2);
    padding: 8px 16px 10px;
}
.sidebar-foot-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-dim);
    margin-bottom: 4px;
}
.sidebar-foot-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    transition: background var(--t-fast) var(--ease);
}
.sidebar-foot-link + .sidebar-foot-link { margin-top: 2px; }
.sidebar-foot-link:hover { background: var(--hover); }
.sidebar-foot-link svg { color: var(--accent); flex-shrink: 0; }

/* Logout variant — same row, muted icon so it reads as a utility action
   rather than a primary nav link. */
.sidebar-foot-link--logout svg { color: var(--ink-dim); }
.sidebar-foot-link--logout:hover { background: var(--bad-wash); color: var(--bad-strong); }
.sidebar-foot-link--logout:hover svg { color: var(--bad-strong); }

.account-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--border-faint);
    cursor: pointer;
    position: relative;
    transition: background var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
}
.account-item:hover {
    background: var(--hover);
}
.account-item:active { transform: scale(0.997); }
.account-item.active {
    background: var(--active);
}
.account-item.active::before {
    content: "";
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.account-item.active .account-name { color: var(--accent-dark); }
.account-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.account-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.account-name {
    font-weight: 500;
    font-size: 15px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.account-bal {
    font-size: 12px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}
.account-phone {
    color: var(--ink-dim);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.sidebar .empty {
    padding: 36px 24px;
    color: var(--ink-dim);
    text-align: center;
    font-size: 13px;
    line-height: 1.55;
}
.sidebar .empty a {
    color: var(--accent-dark);
    font-weight: 500;
    text-decoration: none;
}
.sidebar .empty a:hover { text-decoration: underline; }

/* ===== Avatar ===== */
.avatar {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-fill), var(--accent-fill-2));
    color: var(--ink-on-dark);
    font-weight: 600;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    user-select: none;
    /* Soft inner ring for depth without an explicit border. */
    box-shadow: inset 0 0 0 1px var(--inset-hilite),
                var(--shadow-avatar);
    letter-spacing: -.5px;
}
.avatar-sm { width: 36px; height: 36px; font-size: 15px; }
.avatar-lg { width: 52px; height: 52px; font-size: 22px; }
.avatar-user {
    background: var(--avatar-user-grad);
}

/* ===== Icon button ===== */
.iconbtn {
    display: inline-flex;
    width: 38px; height: 38px;
    align-items: center; justify-content: center;
    border-radius: 50%;
    color: var(--ink-dim);
    background: transparent;
    border: 0;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
}
.iconbtn:hover {
    background: var(--accent-wash);
    color: var(--accent-dark);
}
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { display: block; }

/* ===== Main pane (right column) ===== */
.main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Two-layer background: dotted grid for texture, washed gradient on top
       to keep the dots subtle and add a hint of warmth toward the bottom. */
    background-color: var(--canvas);
    background-image:
        radial-gradient(circle at top right, var(--canvas-wash), transparent 55%),
        radial-gradient(var(--canvas-dot) 1px, transparent 1px);
    background-size: auto, 18px 18px;
}
.main-head {
    background: var(--head-grad);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    height: 60px;
    flex: 0 0 auto;
}
.main-head .main-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex: 1 1 auto;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.2px;
}
.main-head .main-sub {
    color: var(--ink-dim);
    font-size: 12px;
    font-weight: 400;
    margin-left: 8px;
}
/* Compact stat triple (Received / Sent / Balance) docked on the right of
   the main-head bar — see transactions.php → layout_header($headExtras).
   Lives on the shared top line so the numbers stay visible regardless of
   how far the user has scrolled the transaction list. */
.main-head-extras {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 0 0 auto;
}
.main-head-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    line-height: 1;
}
.main-head-stat .lbl {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ink-dim);
}
.main-head-stat .val {
    font-size: 13px;
    /* .amount-pos / .amount-neg already provides the colour pill; we just
       lean on them when the value is signed. */
}
/* In narrow main columns (e.g. 3-column mode under 1100px viewport), labels
   eat too much space. Hide them — for the Received/Sent pair the pill colour
   plus the +/− sign is enough signal.
   The balance stat keeps its label: that label ("to receive" / "to pay" /
   "settled") is the ONLY thing stating which way the balance runs, since the
   value is rendered as an unsigned magnitude. Hiding it would leave a bare
   number distinguished by colour alone. */
@media (max-width: 1100px) {
    body.has-history .main-head-stat .lbl { display: none; }
    body.has-history .main-head-stat--bal .lbl { display: block; }
    body.has-history .main-head-extras    { gap: 8px; }
}
.main-body {
    flex: 1 1 auto;
    overflow-y: auto;
    /* Zero top padding so the first content panel sits flush against the
       .main-head bar — same visual top line as the sidebar's user chip
       and the history pane's first row. */
    padding: 0 24px 24px;
}
.main-body::-webkit-scrollbar { width: 8px; }
.main-body::-webkit-scrollbar-track { background: transparent; }
.main-body::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 4px;
    transition: background var(--t) var(--ease);
}
.main-body:hover::-webkit-scrollbar-thumb { background: var(--scroll-thumb-hover); }

.content-wrap {
    max-width: 980px;
    margin: 0 auto;
}

/* ===== History pane (third column) =====
 * Rendered by mykhata/_layout.php as a sibling of .main so it lays out as
 * a true third column rather than overlaying the page. Visibility is
 * controlled by the [hidden] attribute (toggled from transactions.php JS),
 * not display:none in the base ruleset — that way nothing in the cascade
 * can leave the pane stuck collapsed once shown. The chrome (gradient
 * header + dotted-grid body) mirrors .main exactly so the three columns
 * feel like first-class siblings. */
.history-pane {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-width: 0;
    border-left: 1px solid var(--border);
    background-color: var(--canvas);
    background-image:
        radial-gradient(circle at top right, var(--canvas-wash), transparent 55%),
        radial-gradient(var(--canvas-dot) 1px, transparent 1px);
    background-size: auto, 18px 18px;
    animation: history-in .2s ease-out;
}
.history-pane[hidden] { display: none !important; }

.history-pane-head {
    background: var(--head-grad);
    padding: 0 16px 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    height: 60px;
    flex: 0 0 auto;
    gap: 12px;
}
.history-pane-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    text-transform: none;
    letter-spacing: -.2px;
}
.history-pane-body {
    flex: 1 1 auto;
    overflow-y: auto;
    /* Match .main-body: zero top padding so the first row of history
       starts on the same horizontal line as the main pane's first panel
       and the sidebar's first list item. */
    padding: 0 24px 24px;
}
.history-pane-body::-webkit-scrollbar { width: 8px; }
.history-pane-body::-webkit-scrollbar-track { background: transparent; }
.history-pane-body::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 4px;
    transition: background var(--t) var(--ease);
}
.history-pane-body:hover::-webkit-scrollbar-thumb { background: var(--scroll-thumb-hover); }
.history-pane-body .panel:last-child { margin-bottom: 0; }
/* Inside the narrow third column, the .content-wrap centering would just
   waste padding. Let it use the full width of the pane. */
.history-pane-body .content-wrap { max-width: none; }

/* 3-column mode: when active, share the post-sidebar space equally between
   .main and .history-pane, and let the whole .app stretch wider so neither
   pane ends up cramped. The sidebar keeps its fixed width so the account
   list doesn't reflow each time history is toggled. */
body.has-history .app {
    max-width: 1800px;
}
body.has-history .main {
    flex: 1 1 0;
}
@keyframes history-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.back-link {
    color: var(--ink-dim);
    text-decoration: none;
    font-size: 13px;
}
.back-link:hover { color: var(--accent); }

/* ===== Flash ===== */
.flash {
    padding: 11px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    border: 1px solid transparent;
}
.flash-info  { background: var(--warn-bg);  color: var(--warn-ink); border-color: var(--warn-border); }
.flash-ok    { background: var(--good-soft);color: var(--good);     border-color: var(--good-border); }
.flash-error { background: var(--bad-soft); color: var(--bad);      border-color: var(--bad-border); }

/* ===== Panel ===== */
.panel {
    background: var(--panel);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-faint);
}
/* Collapsible panel — a .panel that is a <details> instead of a <div>.
   Used by accounts.php for the "New ledger" form and the shared bank-account
   table: both are secondary to the ledger list, so they shrink to a single
   header row and the list keeps the fold. Native <details>, so it needs no JS
   and keeps keyboard + screen-reader semantics for free. */
/* NOT overflow:hidden. The create form contains .party-results, an absolutely
   positioned autocomplete dropdown that overhangs the panel — clipping it
   would cut the suggestion list off. The summary rounds its own corners
   instead, which is all overflow:hidden was buying here. */
.panel-collapse { padding: 0; }
.panel-collapse > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    cursor: pointer;
    list-style: none;
    -webkit-user-select: none;
    user-select: none;
    transition: background var(--t-fast) var(--ease);
}
/* Both are needed: ::marker for standards engines, the -webkit- pseudo for
   older Safari, which ignores list-style on summary. */
.panel-collapse > summary::marker { content: ''; }
.panel-collapse > summary::-webkit-details-marker { display: none; }
.panel-collapse:not([open]) > summary { border-radius: var(--radius-lg); }
.panel-collapse > summary:hover { background: var(--hover); }
.panel-collapse > summary:focus-visible { outline: none; box-shadow: var(--ring-accent) inset; }
.panel-collapse > summary h2 { margin: 0; }
.panel-collapse[open] > summary { border-bottom: 1px solid var(--border-faint); }
.panel-collapse-chevron {
    flex-shrink: 0;
    color: var(--ink-soft);
    transition: transform var(--t-fast) var(--ease);
}
.panel-collapse[open] > summary .panel-collapse-chevron { transform: rotate(90deg); }
.panel-collapse-hint { font-size: 12px; margin-left: auto; text-align: right; }
.panel-collapse-body { padding: 18px 22px 22px; }
.panel-collapse-body > p:first-child { margin-top: 0; }
@media (prefers-reduced-motion: reduce) {
    .panel-collapse-chevron { transition: none; }
}
@media (max-width: 760px) {
    .panel-collapse > summary { padding: 14px 16px; }
    .panel-collapse-body { padding: 14px 16px 16px; }
    .panel-collapse-hint { display: none; }
}

h1 { font-size: 20px; margin: 0 0 16px; font-weight: 600; letter-spacing: -.2px; }
h2 {
    font-size: 14px;
    margin: 0 0 16px;
    font-weight: 600;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: .5px;
}
/* Panel headings that lead with an inline SVG from icon_svg() instead of an
   emoji. Flexing the <strong> centres the glyph against the cap height — an
   inline SVG otherwise sits on the text baseline and reads a touch low. The
   whitespace between the icon and the label collapses into the label's own
   flex item, so `gap` is the only spacing. .btn already does the same thing,
   which is why the submit buttons need no extra rule. */
.panel-h2-icon > strong,
.acct-list-title > strong {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.panel-h2-icon > strong > svg,
.acct-list-title > strong > svg { flex-shrink: 0; opacity: .75; }

/* ===== Table ===== */
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th {
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    background: var(--panel-grad);
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr {
    transition: background var(--t-fast) var(--ease);
}
.table tbody tr:hover { background: var(--hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Pill-style amounts for clearer +/- distinction. */
.amount-pos,
.amount-neg {
    display: inline-block;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}
.amount-pos { color: var(--good); background: var(--good-soft); }
.amount-neg { color: var(--bad);  background: var(--bad-soft); }
/* When the pill sits in a .num cell, keep the right alignment intact. */
td.num .amount-pos, td.num .amount-neg { margin-left: auto; }

.account-cell {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 500;
}
.account-cell:hover { color: var(--accent-dark); }
.account-cell .avatar { font-size: 13px; }

.muted-link {
    color: var(--ink-dim);
    text-decoration: none;
}
.muted-link:hover { color: var(--accent); }

.row-actions form { display: inline; margin: 0; }
.row-actions a, .row-actions button {
    margin-right: 4px;
    font-size: 13px;
}
.row-actions .row-icon:last-child { margin-right: 0; }

.row-icon {
    display: inline-flex;
    width: 30px; height: 30px;
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--ink-dim);
    background: transparent;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    vertical-align: middle;
    transition: background var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
}
.row-icon:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}
.row-icon:active { transform: scale(.92); }
.row-icon.row-icon-danger:hover {
    background: var(--bad-soft);
    color: var(--bad);
}
.row-icon svg { display: block; }

/* ===== Forms ===== */
form.inline-form {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 12px;
    align-items: end;
}
form label {
    display: block;
    font-size: 12px;
    color: var(--ink-dim);
    margin-bottom: 4px;
    font-weight: 500;
}
form.stacked label { display: block; }
form input[type=text],
form input[type=email],
form input[type=number],
form input[type=tel],
form input[type=datetime-local],
/* `date` was missing from this list, so every date picker in MyKhata kept the
   browser default — a white box, which reads as a hole punched in a dark
   panel. :root sets `color-scheme: light dark`, so once the background is a
   token the browser also paints the native calendar widget to match. */
form input[type=date],
form select,
form textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font: inherit;
    background: var(--control);
    color: var(--ink);
    transition: border-color var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease),
                background var(--t-fast) var(--ease);
}
form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--control);
    box-shadow: var(--ring-accent);
}
form input::placeholder,
form textarea::placeholder { color: var(--ink-soft); }
form input[type=file] { padding: 6px 0; border: 0; background: transparent; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--control);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    font-weight: 500;
    line-height: 1.2;
    transition: background var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
}
.btn:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(1px); box-shadow: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-fill), var(--accent-fill-2));
    color: var(--accent-ink);
    border-color: transparent;
    box-shadow: var(--shadow-accent);
}
.btn-primary:hover {
    filter: brightness(1.05);
    color: var(--ink-on-dark);
    box-shadow: var(--shadow-accent-hover);
}
.btn-primary:active { filter: brightness(.95); }

/* Icon-only button. The default .btn padding (9px 18px) is sized for a label;
   with the label gone it leaves a small glyph adrift in a wide pill, so square
   it up and let the icon set the size.

   Every .btn-icon MUST carry an aria-label AND a title. Dropping the text
   removes the button's accessible name, so without the label a screen reader
   announces nothing but "button" and a sighted user gets no tooltip to
   recover the meaning from. */
.btn.btn-icon {
    padding: 0;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    gap: 0;
}
.btn.btn-icon > svg { display: block; }

.btn-danger {
    color: var(--bad);
    border-color: var(--bad-border);
    background: var(--control);
}
.btn-danger:hover {
    color: var(--ink-on-dark);
    background: var(--bad);
    border-color: var(--bad);
    box-shadow: var(--shadow-danger);
}

.btn-link {
    background: transparent;
    border: 0;
    color: var(--accent-dark);
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}
.btn-link:hover { text-decoration: underline; color: var(--accent); }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 18px;
    color: var(--ink-dim);
    flex-wrap: wrap;
}
/* `button` is in every selector below because pager controls POST the hidden
   view form instead of linking to ?page=N — see mykhata/accounts.php. The
   font/cursor resets only matter for the button form; links already inherit. */
.pagination a, .pagination span, .pagination button {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
    transition: background var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
}
.pagination button { cursor: pointer; }
.pagination .current {
    background: linear-gradient(135deg, var(--accent-fill), var(--accent-fill-2));
    color: var(--accent-ink);
    box-shadow: var(--shadow-sm);
}
.pagination a, .pagination button {
    border: 1px solid var(--border-strong);
    color: var(--ink);
    background: var(--control);
}
.pagination a:hover, .pagination button:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: var(--accent-soft);
}
/* Prev/Next and the "…" gaps in the windowed pager (mykhata/accounts.php). */
.pagination-nav { font-weight: 600; }
.pagination-nav.is-disabled {
    color: var(--ink-soft);
    border: 1px solid var(--border-faint);
    background: transparent;
    cursor: default;
}
.pagination-gap {
    padding: 6px 2px;
    color: var(--ink-soft);
    letter-spacing: 1px;
}

/* ===== Login (bare layout) ===== */
.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background:
        radial-gradient(ellipse at top, var(--accent-hero), transparent 60%),
        linear-gradient(180deg,
                        var(--accent) 0px,
                        var(--accent-2) 260px,
                        var(--bg) 260px,
                        var(--bg) 100%);
}
.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--panel);
    border-radius: var(--radius-lg);
    padding: 44px 36px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-faint);
}
.login-card h1 {
    font-size: 26px;
    margin: 0 0 6px;
    font-weight: 600;
    letter-spacing: -.3px;
}
.login-card p {
    color: var(--ink-dim);
    margin: 0 0 24px;
}
.login-card .g_id_signin {
    display: flex;
    justify-content: center;
}
.login-brand {
    width: 72px; height: 72px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent-fill), var(--accent-fill-2));
    color: var(--ink-on-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -.8px;
    box-shadow: var(--shadow-accent-lg),
                inset 0 0 0 1px var(--inset-hilite);
}

/* ===== Misc ===== */
.thumb {
    width: 48px; height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.image-block {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.image-block img {
    max-width: 240px;
    max-height: 240px;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.muted { color: var(--ink-dim); }
.right { text-align: right; }
.spacer { height: 12px; }

.empty-pane {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--ink-dim);
    padding: 40px;
}

/* ===== Transaction type pill + inline image picker ===== */
.tx-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .2px;
    white-space: nowrap;
}
.tx-pill-in  { background: var(--good-soft); color: var(--good); }
.tx-pill-out { background: var(--bad-soft);  color: var(--bad); }

/* Empty-state cell in the transactions table — centered icon + copy. */
.table td.empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--ink-dim);
}
.table td.empty-state > div { margin: 4px 0; }

/* Center every cell horizontally + vertically. Action cells already use
   .row-actions.right, so we override that back to centered too. The
   image thumbnail / pill / amount all sit comfortably in the middle. */
.tx-table th,
.tx-table td {
    text-align: center !important;
    vertical-align: middle;
}
.tx-table .row-actions { justify-content: center; }
/* Keep the description column readable when it has long text by leaving
   it left-aligned on wider screens. Comment this out if you want every
   column dead-centered. */
.tx-table th:nth-child(2),
.tx-table td:nth-child(2) { text-align: left !important; }

/* New-transaction form: 5 input columns + submit on a single row. */
/* ===== Transaction create/edit form =====
   Reworked 2026-11-08. It was a positional grid, `1fr 130px 1.5fr 1fr 1fr
   auto`, in field order Amount · Type · Category · Description · Date. Seven
   items (plus attach and submit) across six tracks, so it wrapped unevenly and
   whichever field landed in the trailing `auto` track rendered at a width
   unrelated to its neighbours.

   Now a 6-column span grid, which makes the intended shape explicit:

       Date & time (2) | Amount (2) | Type (2)
       Category    (2) | Description (4)
       actions ................................. (6)

   Date leads the form. `align-items: start` (overriding .inline-form's `end`)
   keeps every label and input on a shared top edge regardless of whether a
   neighbour wraps to two lines. */
form.inline-form.tx-form {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: start;
    gap: 14px 12px;
}
/* min-width:0 as well as the track's minmax(0,…): a grid item's default
   min-width is auto, so a long <select> option or an unbroken description
   would otherwise push its track wider than its share and blow the row out. */
form.tx-form > .tx-f { min-width: 0; }
/* Six equal fields, two rows of three, in DOM order:
       Type | Date | Amount
       Payment mode | Category | Description

   Every field spans the same 2 tracks, so the breakpoints below only have to
   change the track count — no per-field overrides to keep in sync. The earlier
   version gave each field its own span and needed all six restated at every
   tier, which is how a `span 4` against a 2-track template slips through. */
form.tx-form > .tx-f { grid-column: span 2; }

/* Currency symbol inside the amount field. */
.tx-input-prefix { position: relative; display: block; }
.tx-input-prefix-sym {
    position: absolute;
    left: 13px; top: 50%;
    transform: translateY(-50%);
    color: var(--ink-soft);
    font-size: 14px;
    pointer-events: none;
}
.tx-input-prefix > input { padding-left: 32px !important; }

/* Sent/Received segmented control. Two radios styled as a pill pair — this is
   the most-used control on the page and only ever has two states, so a <select>
   cost an extra click and showed neither option until opened. Colours match the
   amounts in the list, so direction reads before the label does. */
.tx-type-toggle {
    display: flex;
    gap: 6px;
}
/* The <label> is only the hit area and flex box; the <span> inside it is the
   visible pill. Styling the span lets the checked state come from
   `input:checked + span`, an adjacent-sibling match supported everywhere —
   `:has()` on the label would have been tidier markup-wise but leaves older
   engines with no checked state at all, i.e. both pills looking selected. */
.tx-type-opt {
    /* `form label` is display:block / 12px / dim / margin-bottom — reset it:
       these are controls, not field captions. */
    display: inline-flex;
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    padding: 0;
    cursor: pointer;
}
/* Radio stays in the DOM and focusable, so keyboard and screen-reader
   behaviour (arrow keys move within the group) is the browser's, not ours. */
.tx-type-opt input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px; height: 1px;
    margin: 0;
    pointer-events: none;
}
.tx-type-opt > span {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 9px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--control);
    color: var(--ink-dim);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
}
.tx-type-opt:hover > span { border-color: var(--accent); }
.tx-type-opt input:focus-visible + span { box-shadow: var(--ring-accent); }
.tx-type-opt--out input:checked + span {
    background: var(--bad-soft);
    border-color: var(--bad-border);
    color: var(--bad);
}
.tx-type-opt--in input:checked + span {
    background: var(--good-soft);
    border-color: var(--good-border);
    color: var(--good);
}
@media (prefers-reduced-motion: reduce) {
    .tx-type-opt > span { transition: none; }
}

/* Payment mode in a transaction row's meta line. */
.tx-mode-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--pill-muted-bg);
    color: var(--pill-muted-ink);
    font-size: 11px;
    font-weight: 600;
}
form.tx-form > .tx-form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 2px;
    padding-top: 14px;
    border-top: 1px solid var(--border-faint);
}
/* Attach on the left, submit pushed to the right end of the row. */
form.tx-form > .tx-form-actions > .tx-form-buttons {
    margin-left: auto;
    display: flex;
    gap: 10px;
    align-items: center;
}
form.tx-form > .tx-form-actions .tx-attach-field { align-self: center; }

/* Narrow: two fields per row, description full width. */
/* Every tier yields whole rows — no field is left orphaned beside a gap:
     6 tracks × span 2 = 3 per row    4 × 2 = 2 per row
     2 tracks × span 1 = 2 per row    1 × 1 = 1 per row                      */
@media (max-width: 1100px) {
    form.inline-form.tx-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    form.inline-form.tx-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    form.tx-form > .tx-f { grid-column: span 1; }
}
@media (max-width: 480px) {
    form.inline-form.tx-form { grid-template-columns: minmax(0, 1fr); }
    form.tx-form > .tx-f { grid-column: span 1; }
    form.tx-form > .tx-form-actions > .tx-form-buttons { margin-left: 0; }
}

/* Edit mode. The form sits directly above a list of near-identical rows and
   otherwise looked exactly like the "new transaction" form, so there was no
   signal that pressing Save would overwrite an existing entry rather than add
   one. The accent edge is that signal. */
.panel.panel--editing {
    border-left: 3px solid var(--accent);
    background: linear-gradient(90deg, var(--accent-wash), transparent 220px);
}
.tx-form-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 0 0 16px;
}
.tx-form-head h2 { margin: 0; }
/* Identifies the row being edited: amount, date, note, then the id. */
.tx-form-sub {
    font-size: 12px;
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}
.tx-form-sub .amount-pos,
.tx-form-sub .amount-neg { font-weight: 600; font-variant-numeric: tabular-nums; }
/* Icon-only paperclip attach button on a single row alongside its preview.
   align-self:end so the clip baseline matches the sibling inputs (whose
   <label> on top eats ~20px of vertical space in each grid cell). */
.tx-attach-field {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: end;
}
/* The native file input is visually hidden but still focusable for a11y;
   the styled <label class="tx-image-trigger"> is what users see and click. */
.tx-image-picker {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.tx-image-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--panel-2);
    color: var(--ink-dim);
    cursor: pointer;
    user-select: none;
    transition:
        border-color var(--t-fast) var(--ease),
        background   var(--t-fast) var(--ease),
        color        var(--t-fast) var(--ease),
        transform    var(--t-fast) var(--ease);
}
.tx-image-trigger:hover,
.tx-image-picker:focus + .tx-image-trigger {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}
.tx-image-trigger:active { transform: scale(.94); }
.tx-image-trigger.has-file {
    color: var(--ink-on-dark);
    background: var(--accent-fill);
    border-color: var(--brand);
}
.tx-image-trigger svg { transform: rotate(-30deg); }

/* The two tx-form breakpoints that used to live here (1100px → 2 cols, 800px →
   1 col) were removed on 2026-11-08. They set grid-template-columns only, with
   no span resets, so against the new span grid a .tx-f-desc of `span 4` would
   have overflowed a 2-column track list. The replacements live with the rest of
   the tx-form rules above, where the spans they have to agree with are visible
   on the same screen. */

/* When the third-column history pane is open, .main shrinks to ~50% of the
   post-sidebar space — far too narrow for the 6-column tx-form grid. Collapse
   to 2 columns and reset the spans to match; setting the template alone (as
   this rule used to) would leave Description spanning 4 of 2 tracks. */
body.has-history form.inline-form:not(.tx-form) {
    grid-template-columns: 1fr !important;     /* generic forms (ledger create etc.) — 1 col */
}
body.has-history form.inline-form.tx-form {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
body.has-history form.tx-form > .tx-f { grid-column: span 1 !important; }

/* ===== Image lightbox =====
   Attachments used to open with target="_blank", which dropped you on a bare
   image document and lost your place in the list. See layout_lightbox() in
   mykhata/_layout.php — the markup is shared by every mykhata page. */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 120;                      /* above .history-pane, below SweetAlert */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    padding: 56px 24px 32px;
    background: var(--overlay);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.lightbox[hidden] { display: none; }
/* Scroll-lock the page behind the overlay. */
body.has-lightbox { overflow: hidden; }
.lightbox-figure {
    margin: 0;
    max-width: min(1100px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 0;
}
.lightbox-figure img {
    max-width: 100%;
    /* Leave room for the caption and the "open original" link. */
    max-height: calc(100vh - 170px);
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-lg);
}
.lightbox-caption {
    color: var(--ink-on-dark);
    font-size: 13px;
    text-align: center;
    max-width: 70ch;
    opacity: .85;
}
.lightbox-caption[hidden] { display: none; }
.lightbox-close {
    position: absolute;
    top: 14px; right: 16px;
    width: 40px; height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: var(--overlay-soft);
    color: var(--ink-on-dark);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease);
}
.lightbox-close:hover { background: rgba(255, 255, 255, .22); }
.lightbox-open-tab {
    color: var(--ink-on-dark);
    font-size: 13px;
    text-decoration: underline;
    opacity: .8;
}
.lightbox-open-tab:hover { opacity: 1; color: var(--ink-on-dark); }
/* The row thumbnail is now a lightbox trigger — show it. */
.tx-card-thumb { cursor: zoom-in; }
.image-block a.js-lightbox { display: inline-block; cursor: zoom-in; }
@media (max-width: 600px) {
    .lightbox { padding: 52px 12px 24px; }
    .lightbox-figure img { max-height: calc(100vh - 150px); }
}

.tx-image-preview {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
}
.tx-image-preview img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    background: var(--panel-2);
    border: 1px solid var(--border);
}
.tx-image-clear {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 0;
    background: var(--overlay);
    color: var(--ink-on-dark);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -6px; right: -6px;
    box-shadow: var(--shadow-sm);
    transition: background var(--t-fast) var(--ease);
}
.tx-image-clear:hover { background: var(--bad); }

/* ===== Terms & Conditions ===== */
.terms-placeholder {
    background: var(--warn-surface);
    border: 1px solid var(--warn-surface-border);
    color: var(--warn-surface-ink);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin: 0 0 14px;
    line-height: 1.5;
}
.terms-placeholder code {
    background: var(--overlay-soft);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}

.terms-body {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    background: var(--panel-2);
    font-size: 13.5px;
    line-height: 1.55;
}
.terms-body h3 {
    font-size: 14px;
    margin: 14px 0 4px;
    color: var(--ink);
}
.terms-body h3:first-child { margin-top: 0; }
.terms-body p { margin: 0 0 10px; color: var(--ink); }

.tnc-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 14px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}
.tnc-check input[type=checkbox] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.tnc-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ===== History drawer ===== */
.txn-row { cursor: pointer; }

/* ===== History pane: narrow-viewport fallback =====
 * The inline 3-column layout becomes too cramped on phones and small tablets.
 * Below 820px we switch to a full-width overlay so the pane is still readable;
 * above that, the 3-column layout takes over (sidebar 380 + main + history). */
@media (max-width: 820px) {
    body.has-history .app { max-width: 1500px; }
    body.has-history .main { flex: 1 1 auto; }    /* main keeps its width */
    body.has-history .history-pane {
        position: fixed;
        top: 0; bottom: 0; right: 0;
        width: 100vw;
        z-index: 100;
        box-shadow: var(--shadow-lg);
        animation: history-slide-in .2s ease-out;
    }
}
@keyframes history-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

/* ===== Mobile ===== */
@media (max-width: 800px) {
    .app {
        flex-direction: column;
        max-width: none;
        height: auto;
        min-height: 100vh;
        box-shadow: none;
        overflow: visible;
    }
    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-list {
        max-height: 45vh;
    }
    .main { min-height: 55vh; }
    form.inline-form { grid-template-columns: 1fr; }
    .main-body { padding: 14px; }
    .panel { padding: 16px; }
}

/* =========================================================================
   Accounts page — stats strip + card list (mykhata/accounts.php)
   ========================================================================= */

/* Three-up summary chips above the list. Receive / Pay / Net. */
.acct-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 0 0 16px;
}
.acct-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.acct-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-dim);
    font-weight: 600;
}
.acct-stat-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.acct-stat--recv .acct-stat-value { color: var(--good); }
.acct-stat--pay  .acct-stat-value { color: var(--bad); }
.acct-stat--net.is-pos .acct-stat-value { color: var(--good); }
.acct-stat--net.is-neg .acct-stat-value { color: var(--bad); }

@media (max-width: 720px) {
    .acct-summary { grid-template-columns: 1fr; }
}

/* List header: title + inline search box. */
.acct-list-head {
    display: flex;
    align-items: center;
    /* Was space-between, which worked only while this strip had exactly two
       children. It now also carries the "filters this page only" note, and
       space-between would have parked the search box in the middle. Pushing
       the title with margin-right:auto keeps the two-child look identical
       and groups the search + note together on the right. */
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 14px;
}
.acct-list-title { margin: 0 auto 0 0; }
.acct-search-note { font-size: 11px; line-height: 1.3; max-width: 9em; }
.acct-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--ink-dim);
    transition:
        border-color var(--t-fast) var(--ease),
        background   var(--t-fast) var(--ease);
}
.acct-search:focus-within {
    border-color: var(--accent);
    background: var(--panel);
    color: var(--accent-dark);
}
.acct-search input {
    border: 0;
    background: transparent;
    outline: none;
    font-size: 13px;
    width: 180px;
    color: var(--ink);
}

/* Card list. Replaces the table layout with chat-row style entries. */
.acct-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.acct-card {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 4px;
    border-radius: var(--radius);
    transition: background var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease);
}
.acct-card:hover {
    background: var(--hover);
    box-shadow: var(--shadow-sm);
}
.acct-card-main {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    min-width: 0;
}
.acct-card-main:hover { text-decoration: none; }

.acct-card .avatar.avatar-lg {
    width: 44px;
    height: 44px;
    font-size: 16px;
    flex: 0 0 auto;
}

.acct-card-body { min-width: 0; }
.acct-card-name {
    font-weight: 600;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.acct-card-sub {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--ink-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.acct-card-dot { color: var(--ink-soft); }
.acct-card-phone { font-variant-numeric: tabular-nums; }

/* Role chips — surfaces shared-architecture identity next to each ledger
   name. One chip per role the party plays (ledger/customer/vendor). */
.role-chips {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    vertical-align: middle;
    flex-wrap: wrap;
}
.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: .1px;
    white-space: nowrap;
    border: 1px solid transparent;
}
.role-chip--ledger   { background: var(--chip-indigo-bg); color: var(--chip-indigo-ink); border-color: var(--chip-indigo-border); }
.role-chip--customer { background: var(--chip-green-bg);  color: var(--chip-green-ink);  border-color: var(--chip-green-border); }
.role-chip--vendor   { background: var(--chip-amber-bg);  color: var(--chip-amber-ink);  border-color: var(--chip-amber-border); }

/* Payment-due state on a contact row. Overdue is the only one that shouts;
   due-today is a nudge and upcoming is just information, so they stay in the
   calm palette rather than competing with the balance figure. */
.due-chip--overdue  { background: var(--chip-red-bg);    color: var(--chip-red-ink);    border-color: var(--chip-red-border); }
.due-chip--today    { background: var(--chip-amber-bg);  color: var(--chip-amber-ink);  border-color: var(--chip-amber-border); }
.due-chip--upcoming { background: var(--chip-indigo-bg); color: var(--chip-indigo-ink); border-color: var(--chip-indigo-border); }

/* Due-state filter strip above the contacts list. Plain links, so the chosen
   state is in the URL and survives a reload or a share. */
.due-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
}
.due-filter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
/* The chips are <button>s submitting the hidden view form (navigation is
   POST-redirect-GET, not a query string), so they need the font and cursor a
   UA button would otherwise override. Kept on .due-filter rather than a
   button selector so the two render identically. */
.due-filter {
    font-family: inherit;
    line-height: 1.45;
    cursor: pointer;
}
.due-filter:hover { border-color: var(--brand); }
.due-filter.is-active {
    /* --brand aliases --accent (text role). The chip carries white text, so
       use the fill role, which deepens in dark mode to keep it legible. */
    background: var(--accent-fill);
    border-color: var(--accent-fill);
    color: var(--accent-ink);
}
/* A state with no contacts in it stays visible but recedes — "nothing
   overdue" is worth seeing, and a disappearing control is worse. */
.due-filter.is-empty { opacity: .55; }
.due-filter-count {
    display: inline-block;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--overlay-soft);
    font-size: 11px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.due-filter.is-active .due-filter-count { background: var(--accent-ink-wash); }
.due-filter--report { margin-left: auto; }

/* Stat strip + empty state, shared by reports.php (every report's totals row)
   and collections.php (the collection run's counters). Lived inline in
   reports.php until collections.php needed the same thing; one definition
   beats two that drift. */
.report-totals {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.report-stat {
    flex: 1 1 160px;
    min-width: 160px;
    padding: 12px 14px;
    background: var(--panel);
    border: 1px solid var(--border-faint);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
/* A bucket (or counter) that actually has overdue money in it gets a red edge,
   so the eye lands on the problem before reading any figure. */
.report-stat.is-late {
    border-color: var(--chip-red-border);
    box-shadow: inset 3px 0 0 var(--bad), var(--shadow);
}
.report-stat .lbl {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--ink-soft);
    letter-spacing: .5px;
}
.report-stat .val {
    margin-top: 4px;
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.report-empty {
    padding: 32px 12px;
    text-align: center;
    color: var(--ink-dim);
}


/* Role toggles inside the create/edit form — compact two-column strip. */
.ledger-roles {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    padding: 2px 0;
}
.ledger-roles label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
.ledger-roles input[type="checkbox"] { margin: 0; }

/* Grid-span helper for inline-form rows that should run the full row width
   (the ledger-roles block uses this so the "Also acts as" strip isn't
   squeezed into one of the four form columns). */
form.inline-form > .full-width { grid-column: 1 / -1; }

/* ===== Ledger create/edit form (mykhata/accounts.php) =====
   The shared .inline-form grid is `repeat(4, 1fr) auto`, where the trailing
   `auto` track exists to hold a submit button at the end of a short row. This
   form has six fields, so the button never lands there: in edit mode GSTIN
   falls into the `auto` track and renders at a different width from its four
   1fr neighbours, while the buttons wrap to a row of their own regardless. On
   top of that the shared grid sets `align-items: end`, which bottom-aligns
   cells — so the one field carrying a hint below its input ("Payment due by")
   had its input pushed visibly higher than the rest of the row.

   Scoped override rather than a change to .inline-form, which six other forms
   share (transactions, import ×2, reminders ×3). Specificity 0,2,1 beats both
   the base rule and the narrow-viewport `grid-template-columns: 1fr` override,
   so it is declared once here and auto-fit handles the collapse instead —
   below ~400px of track space it resolves to a single column on its own. */
form.inline-form.ledger-form {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    /* start, not end: lines every label and input up top-to-top, letting the
       due-date hint hang below without lifting its own field. */
    align-items: start;
    gap: 14px 12px;
}
/* The contact autocomplete owns its own row — it is a search field with an
   overlaid dropdown, not a peer of the short text inputs. */
form.inline-form.ledger-form > .party-link-wrap { grid-column: 1 / -1; }
form.inline-form.ledger-form > .ledger-form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--border-faint);
}
form.inline-form.ledger-form > div > small { display: block; margin-top: 5px; }

.acct-card-bal {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-variant-numeric: tabular-nums;
}
.acct-card-dir {
    font-size: 11px;
    color: var(--ink-dim);
    letter-spacing: .2px;
}

.acct-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 6px;
}
.acct-card-actions form { display: inline-flex; }

@media (max-width: 720px) {
    .acct-card-main {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }
    .acct-card-bal {
        grid-column: 2;
        grid-row: 2;
        align-items: flex-start;
        text-align: left;
    }
}

/* Empty state — full-width centred placeholder with emoji art. */
.acct-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--ink-dim);
}
.acct-empty-art {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 8px;
    filter: grayscale(.2);
}
.acct-empty-title {
    font-weight: 600;
    color: var(--ink);
    font-size: 16px;
    margin-bottom: 4px;
}
.acct-empty-sub { font-size: 13px; }

/* =========================================================================
   Admin page — workspace hero, role / status pills, member list
   (mykhata/admin.php)
   ========================================================================= */

.ws-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin: 0 0 16px;
}
.ws-hero .avatar.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 26px;
    flex: 0 0 auto;
}
.ws-hero-body { min-width: 0; flex: 1 1 auto; }
.ws-hero-name {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ws-hero-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--ink-dim);
    font-size: 13px;
}
.ws-hero-dot { color: var(--ink-soft); }

/* Workspace code chip — click to copy. */
.ws-code-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    color: var(--ink-dim);
    transition:
        background var(--t-fast) var(--ease),
        border-color var(--t-fast) var(--ease),
        color var(--t-fast) var(--ease);
}
.ws-code-chip:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
}
.ws-code-chip code {
    background: transparent;
    padding: 0;
    color: var(--ink);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .5px;
}
.ws-code-chip .ws-code-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    font-weight: 600;
}
.ws-code-chip.is-copied {
    background: var(--good-soft);
    border-color: var(--good);
    color: var(--good);
}
.ws-code-chip.is-copied::after {
    content: " · copied";
    font-size: 11px;
    color: var(--good);
}

/* Role + status pills shared across the admin page. */
.role-pill,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .2px;
    white-space: nowrap;
    text-transform: capitalize;
}
.role-pill--admin  { background: var(--bad-soft);         color: var(--bad-strong); }
.role-pill--editor { background: var(--good-soft);        color: var(--good); }
.role-pill--viewer { background: var(--pill-indigo-bg);   color: var(--pill-indigo-ink); }

.status-pill--active  { background: var(--good-soft); color: var(--good); }
.status-pill--invited { background: var(--warn-bg);   color: var(--warn-ink); }
.status-pill--removed { background: var(--pill-muted-bg); color: var(--pill-muted-ink); }

/* Invite form — three-up grid: email / role / submit. */
.ws-invite-hint {
    margin: -4px 0 12px;
    font-size: 13px;
}
.ws-invite-form {
    display: grid;
    grid-template-columns: 1fr 140px auto;
    gap: 12px;
    align-items: end;
}
.ws-invite-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.ws-invite-field > span {
    font-size: 12px;
    color: var(--ink-dim);
    font-weight: 500;
}
.ws-invite-field input,
.ws-invite-field select {
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--panel);
    font-size: 14px;
    transition:
        border-color var(--t-fast) var(--ease),
        box-shadow   var(--t-fast) var(--ease);
}
.ws-invite-field input:focus,
.ws-invite-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-accent);
}
@media (max-width: 720px) {
    .ws-invite-form { grid-template-columns: 1fr; }
}

/* Member list — card per member. */
.member-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.member-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius);
    transition: background var(--t-fast) var(--ease);
}
.member-card:hover { background: var(--hover); }
.member-card.is-you { background: var(--accent-soft); }
.member-card.is-you:hover { background: var(--accent-soft); }
.member-card .avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
}
.member-body { min-width: 0; }
.member-email {
    font-weight: 500;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.member-meta {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.member-tag {
    display: inline-flex;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--accent-fill);
    color: var(--ink-on-dark);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.member-tag--owner {
    background: var(--bad-fill);
}
.member-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.member-actions form { display: inline-flex; }
.member-role-select {
    padding: 5px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--panel);
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease);
}
.member-role-select:hover,
.member-role-select:focus {
    border-color: var(--accent);
    outline: none;
}

@media (max-width: 720px) {
    .member-card {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }
    .member-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

/* Inline rename UI on the workspace hero (mykhata/admin.php). */
.ws-hero-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
}
.ws-hero-name { margin: 0; }
.ws-hero-name.is-placeholder {
    color: var(--ink-soft);
    font-style: italic;
    font-weight: 600;
}
.ws-hero-rename-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-dim);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease),
                color      var(--t-fast) var(--ease);
}
.ws-hero-rename-btn:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}
.ws-hero-rename-btn svg { display: block; }

.ws-hero-rename {
    display: flex;
    gap: 8px;
    margin: 0 0 6px;
}
.ws-hero-rename[hidden] { display: none; }
.ws-hero-rename input[type=text] {
    flex: 1 1 auto;
    padding: 8px 12px;
    font-size: 18px;
    font-weight: 600;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--panel);
    transition:
        border-color var(--t-fast) var(--ease),
        box-shadow   var(--t-fast) var(--ease);
}
.ws-hero-rename input[type=text]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-accent);
}

/* =========================================================================
   Transactions page — stats strip, date-grouped feed, card rows
   (mykhata/transactions.php)
   ========================================================================= */

/* Three-up stats: received / given / balance. Mirrors .acct-summary so the
   two pages feel related, but uses tx-* class names so they can evolve
   independently. */
.tx-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 0 0 16px;
}
.tx-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.tx-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-dim);
    font-weight: 600;
}
.tx-stat-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.tx-stat--in  .tx-stat-value { color: var(--good); }
.tx-stat--out .tx-stat-value { color: var(--bad); }
.tx-stat--bal.is-pos .tx-stat-value { color: var(--good); }
.tx-stat--bal.is-neg .tx-stat-value { color: var(--bad); }
@media (max-width: 720px) {
    .tx-summary { grid-template-columns: 1fr; }
}

/* Date-grouped feed. Each date is a sticky label above its cards. */
.tx-feed {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.tx-date-group { display: flex; flex-direction: column; gap: 6px; }
.tx-date-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--ink-dim);
    padding: 4px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    align-self: flex-start;
}

.tx-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Single row card. Layout:
   [icon] [body grows] [thumb?] [amount] [actions] */
.tx-card {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius);
    transition: background var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease);
    cursor: pointer;
}
.tx-card:hover {
    background: var(--hover);
    box-shadow: var(--shadow-sm);
}

/* Directional icon — green down-arrow for income, red up-arrow for outgoing. */
.tx-card-icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0;
}
.tx-card--in  .tx-card-icon { background: var(--good-soft); color: var(--good); }
.tx-card--out .tx-card-icon { background: var(--bad-soft);  color: var(--bad); }

.tx-card-body { min-width: 0; }
.tx-card-desc {
    font-size: 14px;
    color: var(--ink);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.25;
}
.tx-card-meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--ink-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.tx-card-dot { color: var(--ink-soft); }
.tx-card-type { font-weight: 600; }

.tx-card-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    display: block;
    border: 1px solid var(--border);
    background: var(--panel-2);
    flex: 0 0 auto;
}
.tx-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tx-card-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    flex: 0 0 auto;
    min-width: 80px;
}
.tx-card-amount .amount-pos,
.tx-card-amount .amount-neg {
    font-size: 14px;
}

.tx-card-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}
.tx-card-actions form { display: inline-flex; }

@media (max-width: 720px) {
    .tx-card {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
    }
    .tx-card-thumb  { grid-column: 1; grid-row: 2; }
    .tx-card-amount { grid-column: 3; grid-row: 1; }
    .tx-card-actions {
        grid-column: 2 / 4;
        grid-row: 2;
        justify-content: flex-end;
    }
}

/* ===== Reminders banner + small buttons/badges (Daily Balance, Reminders, Import, Receipt) ===== */
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-outline { background: transparent; }

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    vertical-align: middle;
}
.badge-danger { background: var(--bad-soft); color: var(--bad); }

.reminder-banner {
    background: var(--warn-surface);
    border: 1px solid var(--warn-surface-border);
}
.reminder-banner-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    flex-wrap: wrap;
}
.reminder-banner-row + .reminder-banner-row { border-top: 1px solid var(--warn-surface-border); }
.reminder-banner-row svg { flex-shrink: 0; color: var(--warn-surface-icon); }

/* ===== Daily Balance chart (mykhata/daily_balance.php) ===== */
.daily-balance-chart {
    width: 100%;
    height: 220px;
    display: block;
}
.daily-balance-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.daily-balance-stats > div { min-width: 100px; }
.daily-balance-stats .label { font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .3px; }
.daily-balance-stats .value { font-size: 18px; font-weight: 600; }

/* ===== Receipt (mykhata/receipt.php) ===== */
.receipt-card {
    max-width: 380px;
    margin: 24px auto;
    background: var(--panel);
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}
.receipt-amount { font-size: 26px; font-weight: 700; margin: 12px 0; }
.receipt-meta { color: var(--ink-dim); font-size: 13px; margin: 2px 0; }
.receipt-footer { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-size: 12px; color: var(--ink-dim); }
@media print {
    .app > .sidebar, .main-head, .reminder-banner, .no-print { display: none !important; }
    .main-body, .content-wrap { padding: 0 !important; margin: 0 !important; }
}

/* =========================================================================
   NIGHT PALETTE
   -------------------------------------------------------------------------
   Token re-points only — if a rule needs editing to work in dark mode, the
   rule is wrong, not this block. Follows the OS automatically; there is no
   toggle and nothing stored.

   Notes on the choices:
   - Surfaces step --bg → --panel → --control so the three nesting levels
     (page, card, input-on-card) stay separable without borders doing all
     the work. --bg is darkest because .app floats above it.
   - The accent LIGHTENS: #0aa988 on a dark panel is too low-contrast for
     text, so --accent-dark (used for links and active names) becomes the
     brightest of the three rather than the darkest. Its name is now about
     its role, not its lightness.
   - Soft fills become translucent accent/semantic washes rather than pale
     tints, so they read as "tinted panel" instead of glowing blocks.
   - Shadows deepen instead of softening; a light-mode shadow is invisible
     on a dark surface.
   - --ink-on-dark, --accent-ink and --inset-hilite deliberately do NOT
     change: they sit on saturated fills that are dark in both themes.
   ========================================================================*/
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #080d0c;
        --panel: #121a19;
        --panel-2: #18211f;
        --panel-grad: linear-gradient(180deg, #192321, #141d1c);
        --border: #253230;
        --border-strong: #324340;
        --border-faint: #1e2927;
        --ink: #e9f1ef;
        --ink-dim: #a0b0ac;
        --ink-soft: #788884;

        --accent: #19c4a0;
        --accent-2: #0fb894;
        --accent-dark: #5fe0c2;     /* lightest of the three in dark — see above */
        /* Fills go the other way: deepened so white text on a primary button
           or avatar clears 4.5:1, which it does not against the brighter
           --accent used for text. */
        --accent-fill: #0b7d66;
        --accent-fill-2: #09705c;
        --accent-soft: #11322c;
        --accent-wash: rgba(25,196,160,.14);
        --accent-glow: rgba(25,196,160,.45);
        --accent-hero: rgba(25,196,160,.16);
        --ring-accent: 0 0 0 3px rgba(25,196,160,.28);

        --control: #1c2725;

        --header-bg: #16201e;
        --head-grad: linear-gradient(180deg, #1a2422 0%, #141d1b 100%);
        --hover: #1b2524;
        --active: #13302a;
        --good: #34d399;
        --good-soft: #0c2e22;
        --good-border: #1d5742;
        --bad: #fb7185;
        --bad-soft: #3a1420;
        --bad-border: #5b2030;
        --bad-strong: #fda4af;      /* text role — lightens, like --accent-dark */
        --bad-fill: #9f1d2d;        /* fill role — deepens, keeps white legible */
        --bad-wash: rgba(251,113,133,.12);
        --warn-bg: #352a10;
        --warn-ink: #fde68a;
        --warn-border: #5c4a1a;

        --canvas: #0d1413;
        --canvas-wash: rgba(25,196,160,.05);
        --canvas-dot: rgba(233,241,239,.045);

        --overlay: rgba(0,0,0,.72);
        --overlay-soft: rgba(255,255,255,.07);

        --scroll-thumb: #2e3d3a;
        --scroll-thumb-hover: #415451;

        --avatar-user-grad: linear-gradient(135deg, #3b4a52, #55666f);

        --pill-red-bg: #3a1420;     --pill-red-ink: #fda4af;
        --pill-green-bg: #0c2e22;   --pill-green-ink: #6ee7b7;
        --pill-indigo-bg: #1e1b4b;  --pill-indigo-ink: #a5b4fc;
        --pill-muted-bg: #222d2b;   --pill-muted-ink: #9aa8a4;

        --chip-indigo-bg: #1e1b4b;  --chip-indigo-ink: #a5b4fc;  --chip-indigo-border: #332f6b;
        --chip-green-bg: #0c2e22;   --chip-green-ink: #6ee7b7;   --chip-green-border: #1d5742;
        --chip-amber-bg: #352a10;   --chip-amber-ink: #fcd34d;    --chip-amber-border: #5c4a1a;
        --chip-red-bg: #3b1518;     --chip-red-ink: #fca5a5;     --chip-red-border: #6b2326;

        --warn-surface: #2d2410;
        --warn-surface-border: #52421a;
        --warn-surface-ink: #fde68a;
        --warn-surface-icon: #fbbf24;

        --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
        --shadow:    0 1px 2px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.4);
        --shadow-md: 0 4px 10px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.35);
        --shadow-lg: 0 14px 36px rgba(0,0,0,.6), 0 4px 10px rgba(0,0,0,.4);
        --shadow-avatar: 0 1px 2px rgba(0,0,0,.45);
        --shadow-accent:       0 1px 2px rgba(0,0,0,.4), 0 3px 8px rgba(25,196,160,.14);
        --shadow-accent-hover: 0 1px 2px rgba(0,0,0,.45), 0 6px 14px rgba(25,196,160,.22);
        --shadow-accent-lg:    0 8px 20px rgba(25,196,160,.28);
        --shadow-danger: 0 4px 12px rgba(0,0,0,.5);
    }

    /* The two amount pills are defined with light-mode soft fills in the
       base rules; the tokens above already carry them. Nothing else needs a
       dark-specific rule — if you find yourself adding one, add a token. */
}

