/* =====================================================================
   BillB2B — Application UI design system
   ---------------------------------------------------------------------
   WEBSITE UI ONLY.  This file never touches the bill / invoice / PDF /
   print templates:
     - the A4 bill is generated by mPDF from its own embedded CSS
       (templates/pdf/common.php -> pdfBaseCss) and is shown on screen
       as a pdf.js canvas, so no website stylesheet can reach it;
     - every rule below is scoped under  .app-ui  (a class on <body>), and
       only pages that opt in carry that class.  Nothing here styles a bare
       body / table / td / th / p / h1-h3 outside .app-ui.
   Loaded AFTER style.css; style.css is intentionally left unchanged.
   ===================================================================== */

/* ---- Inter (website UI font only; bundled in assets/fonts/inter) ---- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Inter Regular"), local("Inter-Regular"), url("fonts/inter/Inter-Regular.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
  src: local("Inter Medium"), local("Inter-Medium"), url("fonts/inter/Inter-Medium.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: local("Inter SemiBold"), local("Inter-SemiBold"), url("fonts/inter/Inter-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: local("Inter Bold"), local("Inter-Bold"), url("fonts/inter/Inter-Bold.ttf") format("truetype"); }

/* ---- Design tokens (scoped, so they cannot leak onto other pages) ---- */
.app-ui {
    --primary: #0f6e56;
    --primary-hover: #0b5a46;
    --primary-soft: #e8f4ef;
    --primary-ring: rgba(15, 110, 86, .18);

    --text: #111827;
    --text-secondary: #4b5563;
    --muted: #6b7280;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --background: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f9fafb;

    --success: #067647;  --success-soft: #ecfdf3;  --success-line: #abefc6;
    --warning: #b54708;  --warning-soft: #fffaeb;  --warning-line: #fedf89;
    --danger:  #b42318;  --danger-soft:  #fef3f2;  --danger-line:  #fecdca;
    --info:    #3538cd;  --info-soft:    #eef4ff;  --info-line:    #c7d7fe;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .06);

    --topbar-h: 56px;
    --sidebar-w: 240px;

    /* Aliases for the variable names the older pages / inline styles already use */
    --primary-dark: var(--primary-hover);
    --bg: var(--background);
    --card: var(--surface);
    --danger-bg: var(--danger-soft);
    --success-bg: var(--success-soft);
    --warn: var(--warning);
    --warn-bg: var(--warning-soft);

    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--background);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
.app-ui, .app-ui * { box-sizing: border-box; }
.app-ui :where(input, select, textarea, button) { font-family: inherit; }
.app-ui :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.app-ui .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Typography ---- */
.app-ui h1 { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -.015em; margin: 0 0 4px; color: var(--text); }
.app-ui h2 { font-size: 15px; line-height: 1.35; font-weight: 600; letter-spacing: -.005em; margin: 0 0 12px; color: var(--text); }
.app-ui h3 { font-size: 13.5px; font-weight: 600; margin: 16px 0 8px; color: var(--text); }
.app-ui p  { margin: 0 0 10px; }
.app-ui .muted { color: var(--muted); font-size: 13px; }
.app-ui .text-right { text-align: right; }
.app-ui hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.app-ui .content a:where(:not(.btn)) { color: var(--primary); text-decoration: none; font-weight: 500; }
.app-ui .content a:where(:not(.btn)):hover { text-decoration: underline; text-underline-offset: 2px; }
.app-ui .ico { width: 18px; height: 18px; flex: none; }

/* =====================================================================
   App shell: topbar + sidebar + content
   (class names .topbar / .sidebar / .layout / .content / .no-print are kept
   on purpose — the existing print rules in pdf_viewer.php, ledger.php and
   balance_sheet.php hide the chrome through those exact names.)
   ===================================================================== */
.app-ui .topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px;
    background: var(--surface); color: var(--text);
    border-bottom: 1px solid var(--border);
}
.app-ui .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0;
    background: transparent; color: var(--text-secondary);
    border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer;
}
.app-ui .menu-toggle:hover { background: var(--surface-2); border-color: var(--border); }
.app-ui .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.app-ui .brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 7px;
    background: var(--primary); color: #fff; font-size: 15px; font-weight: 700; letter-spacing: 0;
}
.app-ui .topbar-title { font-size: 14px; font-weight: 500; color: var(--text-secondary); padding-left: 14px; border-left: 1px solid var(--border); display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-ui .topbar-spacer { flex: 1; }
.app-ui .topbar-company { display: none; font-size: 13px; color: var(--muted); max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* profile menu (native <details>, no framework) */
.app-ui .user-menu { position: relative; }
.app-ui .user-menu > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid transparent; user-select: none;
}
.app-ui .user-menu > summary::-webkit-details-marker { display: none; }
.app-ui .user-menu > summary:hover, .app-ui .user-menu[open] > summary { background: var(--surface-2); border-color: var(--border); }
.app-ui .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.app-ui .user-email { display: none; font-size: 13px; color: var(--text-secondary); max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-ui .user-menu .chev { width: 14px; height: 14px; color: var(--muted); }
.app-ui .user-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 6px;
}
.app-ui .user-panel .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.app-ui .user-panel .who strong { display: block; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.app-ui .user-panel .who span { font-size: 12px; color: var(--muted); }
.app-ui .user-panel a, .app-ui .user-panel button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin: 0;
    background: none; border: 0; border-radius: var(--radius-md); cursor: pointer;
    font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); text-align: left; text-decoration: none;
}
.app-ui .user-panel a:hover, .app-ui .user-panel button:hover { background: var(--surface-2); text-decoration: none; }
.app-ui .user-panel form { margin: 0; }

.app-ui .layout { display: block; min-height: calc(100vh - var(--topbar-h)); }

.app-ui .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 35;
    width: var(--sidebar-w); height: auto;
    display: block; overflow-y: auto; overscroll-behavior: contain;
    padding: 12px 10px 24px;
    background: var(--surface); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .18s ease;
}
.app-ui .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
.app-ui .nav-group { margin-top: 18px; }
.app-ui .nav-group:first-child { margin-top: 0; }
.app-ui .nav-label { padding: 0 10px 6px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.app-ui .sidebar a {
    display: flex; align-items: center; gap: 10px;
    height: 36px; padding: 0 10px; margin: 1px 0;
    border: 0; border-radius: var(--radius-md);
    font-size: 13.5px; font-weight: 500; color: var(--text-secondary); text-decoration: none;
}
.app-ui .sidebar a .ico { color: var(--muted); }
.app-ui .sidebar a:hover { background: var(--surface-2); color: var(--text); }
.app-ui .sidebar a:hover .ico { color: var(--text-secondary); }
.app-ui .sidebar a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.app-ui .sidebar a.active .ico { color: var(--primary); }
.app-ui .sidebar-backdrop { display: none; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 30; background: rgba(16, 24, 40, .35); }
.app-ui .sidebar-backdrop.show { display: block; }

.app-ui .content { width: auto; max-width: 1360px; padding: 20px 16px 48px; margin: 0 auto; }

@media (min-width: 640px) {
    .app-ui .topbar-company { display: block; }
    .app-ui .user-email { display: block; }
}
@media (min-width: 992px) {
    .app-ui .menu-toggle { display: none; }
    .app-ui .topbar { padding: 0 24px; }
    .app-ui .topbar-title { display: block; }
    .app-ui .sidebar { transform: none; box-shadow: none; }
    .app-ui .sidebar-backdrop, .app-ui .sidebar-backdrop.show { display: none; }
    .app-ui .content { margin-left: var(--sidebar-w); max-width: 1344px; padding: 28px 32px 56px; }
}

/* =====================================================================
   Page header, cards, grids
   ===================================================================== */
.app-ui .page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 0 0 20px; }
.app-ui .page-head h1 { margin: 0; }
.app-ui .page-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

.app-ui .card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-xs);
}
.app-ui .card > h2:first-child, .app-ui .card > h1:first-child { margin-top: 0; }
.app-ui .card.muted { color: var(--muted); }
.app-ui .card .card { box-shadow: none; }
.app-ui .grid-2, .app-ui .grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 700px) {
    .app-ui .grid-2 { grid-template-columns: 1fr 1fr; }
    .app-ui .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.app-ui .form-row { display: flex; flex-wrap: wrap; gap: 16px; }
.app-ui .form-row > div { flex: 1; min-width: 150px; }
.app-ui .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Section title row inside a card */
.app-ui .section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.app-ui .section-head h2 { margin: 0; }

/* =====================================================================
   Buttons
   ===================================================================== */
.app-ui .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 36px; padding: 0 14px;
    background: var(--primary); color: #fff;
    border: 1px solid var(--primary); border-radius: var(--radius-md);
    font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2; white-space: nowrap;
    text-decoration: none; cursor: pointer; box-shadow: var(--shadow-xs);
    transition: background-color .12s, border-color .12s, color .12s;
}
.app-ui .btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; text-decoration: none; }
.app-ui .btn:active { transform: translateY(.5px); }
.app-ui .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.app-ui .btn.secondary:hover { background: var(--surface-2); border-color: var(--muted); color: var(--text); }
.app-ui .btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger-line); }
.app-ui .btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.app-ui .btn.small { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-sm); }
.app-ui .btn:disabled, .app-ui .btn[disabled], .app-ui .btn.disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.app-ui .btn .ico { width: 16px; height: 16px; }
.app-ui .btn.small .ico { width: 14px; height: 14px; }
.app-ui .remove-line { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; padding: 4px 6px; border-radius: var(--radius-sm); }
.app-ui .remove-line:hover { background: var(--danger-soft); }

/* Segmented tabs (e.g. Bills: All / Tax Invoice / ...) */
.app-ui .tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; margin: 0 0 16px; background: #eef0f3; border-radius: 10px; }
.app-ui .content .tabs a { padding: 6px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font-size: 13px; font-weight: 500; text-decoration: none; }
.app-ui .content .tabs a:hover { color: var(--text); text-decoration: none; }
.app-ui .content .tabs a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-xs); }
.app-ui .pill-toggle { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-secondary); padding: 8px 18px; font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.app-ui .pill-toggle.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* =====================================================================
   Forms
   ===================================================================== */
.app-ui label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.app-ui label:first-child, .app-ui .grid-2 > div:first-child > label:first-child, .app-ui .form-row > div > label:first-child { margin-top: 0; }
.app-ui :where(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit]):not([type=button]):not([type=range]):not([type=color]), select, textarea) {
    display: block; width: 100%; min-height: 38px; padding: 8px 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    font: inherit; font-size: 14px; line-height: 1.4; box-shadow: var(--shadow-xs);
    transition: border-color .12s, box-shadow .12s;
}
.app-ui textarea { min-height: 76px; resize: vertical; }
.app-ui select {
    appearance: none; -webkit-appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.app-ui input::placeholder, .app-ui textarea::placeholder { color: #9ca3af; }
.app-ui :where(input, select, textarea):hover:not(:disabled):not(:focus) { border-color: var(--muted); }
.app-ui :where(input, select, textarea):focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.app-ui :where(input, select, textarea):disabled, .app-ui :where(input, textarea)[readonly] { background: var(--surface-2); color: var(--text-secondary); }
.app-ui input[type=checkbox], .app-ui input[type=radio] { width: auto; min-height: 0; padding: 0; margin: 0 6px 0 0; accent-color: var(--primary); vertical-align: -2px; }
.app-ui input[type=file] { font: inherit; font-size: 13px; max-width: 100%; }
.app-ui input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); }
.app-ui input[type=number] { font-variant-numeric: tabular-nums; }
.app-ui .line-item-row { padding: 12px; margin-bottom: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); }
/* the compact search / filter bar used on list pages */
.app-ui form.card[method=get] { padding: 14px 16px; }
.app-ui form.card[method=get] label { margin-top: 0; }

/* =====================================================================
   Tables (website tables only — the bill table lives in the mPDF stylesheet)
   ===================================================================== */
.app-ui .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); margin-bottom: 16px; }
.app-ui .card > .table-wrap { box-shadow: none; margin-bottom: 0; }
.app-ui table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: transparent; font-variant-numeric: tabular-nums; }
.app-ui th {
    padding: 10px 14px; background: var(--surface-2); color: var(--text-secondary);
    font-size: 12.5px; font-weight: 600; text-transform: none; letter-spacing: 0; text-align: left; white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.app-ui td { padding: 11px 14px; text-align: left; white-space: nowrap; vertical-align: middle; border-bottom: 1px solid var(--border); color: var(--text); }
.app-ui th.text-right, .app-ui td.text-right { text-align: right; }
.app-ui tr:last-child > td { border-bottom: 0; }
.app-ui .table-wrap tr:hover > td { background: #fafbfc; }
.app-ui td.actions { display: table-cell; }
.app-ui td.actions > * { margin: 0 6px 0 0; vertical-align: middle; }
.app-ui td.actions > *:last-child { margin-right: 0; }
.app-ui td.actions form { display: inline-block; }
/* empty state: any single full-width muted row */
.app-ui td[colspan].muted { padding: 36px 16px; text-align: center; white-space: normal; color: var(--muted); font-size: 13.5px; }

/* =====================================================================
   Badges + alerts
   ===================================================================== */
.app-ui .badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; background: #f2f4f7; color: var(--text-secondary); font-size: 12px; font-weight: 500; line-height: 1.5; white-space: nowrap; border: 1px solid transparent; }
.app-ui .badge.pending   { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.app-ui .badge.paid,
.app-ui .badge.cleared   { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.app-ui .badge.bounced   { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-line); }
.app-ui .badge.quotation { background: var(--info-soft);    color: var(--info);    border-color: var(--info-line); }

.app-ui .flash { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; margin: 0 0 16px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; font-weight: 500; }
.app-ui .flash::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: currentColor; }
.app-ui .flash.success { background: var(--success-soft); border-color: var(--success-line); color: var(--success); }
.app-ui .flash.error   { background: var(--danger-soft);  border-color: var(--danger-line);  color: var(--danger); }
.app-ui .flash.warning { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning); }
.app-ui .flash.info    { background: var(--info-soft);    border-color: var(--info-line);    color: var(--info); }

/* =====================================================================
   Dashboard
   ===================================================================== */
.app-ui .dash-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.app-ui .dash-head h1 { font-size: 24px; }
.app-ui .quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.app-ui .stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.app-ui .stat-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.app-ui .stat-card .lbl { order: -1; margin: 0; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.app-ui .stat-card .num { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.app-ui .card .stat-card { box-shadow: none; background: var(--surface-2); }
.app-ui .bar-track { height: 8px; min-width: 120px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.app-ui .bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.app-ui .check-list { margin: 0; padding-left: 18px; color: var(--text-secondary); }
.app-ui .check-list li { margin: 3px 0; }

/* =====================================================================
   Sign-in / auth pages
   ===================================================================== */
.app-ui.auth-page { min-height: 100vh; }
.app-ui .auth-split { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.app-ui .auth-brand { display: none; padding: 48px 56px; background: var(--primary); color: #fff; flex-direction: column; justify-content: space-between; }
.app-ui .auth-brand .brand { color: #fff; font-size: 18px; }
.app-ui .auth-brand .brand-mark { background: #fff; color: var(--primary); }
.app-ui .auth-brand h2 { margin: 0 0 12px; font-size: 32px; line-height: 1.15; letter-spacing: -.02em; font-weight: 600; color: #fff; max-width: 14ch; }
.app-ui .auth-brand p { margin: 0; color: rgba(255,255,255,.82); font-size: 15px; max-width: 38ch; }
.app-ui .auth-brand small { color: rgba(255,255,255,.65); font-size: 12.5px; }
.app-ui .auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.app-ui .auth-box { width: 100%; max-width: 380px; }
.app-ui .auth-box .brand { margin-bottom: 28px; }
.app-ui .auth-box h1 { font-size: 24px; margin-bottom: 6px; }
.app-ui .auth-box .lead { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.app-ui .auth-box .btn { width: 100%; min-height: 40px; font-size: 14px; }
.app-ui .auth-box .alt { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.app-ui .auth-box a { color: var(--primary); font-weight: 500; text-decoration: none; }
.app-ui .auth-box a:hover { text-decoration: underline; }
.app-ui .auth-box .otp-input { text-align: center; letter-spacing: .5em; font-size: 20px; font-weight: 600; }
.app-ui .auth-box .split-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.app-ui .auth-box .split-actions .btn { width: auto; min-height: 32px; font-size: 12.5px; }
@media (min-width: 900px) {
    .app-ui .auth-split { grid-template-columns: minmax(360px, 5fr) 6fr; }
    .app-ui .auth-brand { display: flex; }
}
/* register / contact: legacy centred card wrappers keep working, just refined */
.app-ui.auth-page > div > .card { padding: 28px; }
.app-ui.auth-page > div > .card > h1:first-child { font-size: 22px; }

/* =====================================================================
   Bill view / preview: only the surrounding website controls are styled.
   The bill itself is the pdf.js canvas from includes/pdf_viewer.php and is
   deliberately not styled here.
   ===================================================================== */
.app-ui .viewer-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.app-ui .viewer-bar h1 { margin: 0; }
.app-ui .viewer-bar .actions { gap: 8px; }

/* =====================================================================
   Mobile refinements
   ===================================================================== */
@media (max-width: 639px) {
    .app-ui .page-head { align-items: flex-start; }
    .app-ui .page-head > .btn { width: auto; }
    .app-ui .card { padding: 16px; }
    .app-ui .form-row > div { min-width: 100%; }
    .app-ui .btn { min-height: 40px; }
    .app-ui .btn.small { min-height: 34px; }
    .app-ui :where(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit]):not([type=button]), select, textarea) { font-size: 16px; min-height: 42px; }
    .app-ui .stat-cards { grid-template-columns: 1fr 1fr; gap: 12px; }
    .app-ui .stat-card { padding: 14px; }
    .app-ui .stat-card .num { font-size: 20px; }
    .app-ui .tabs { display: flex; overflow-x: auto; flex-wrap: nowrap; }
    .app-ui .content .tabs a { white-space: nowrap; }
    .app-ui .dash-head .quick-actions { width: 100%; }
    .app-ui .dash-head .quick-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .app-ui .sidebar, .app-ui .btn, .app-ui :where(input, select, textarea) { transition: none; }
}

/* =====================================================================
   Print — the existing print pipeline hides .topbar/.sidebar/.no-print.
   Because the sidebar is now offset with margin-left, make sure the
   content is reset to full width when printing (ledger, balance sheet,
   and the bill viewer's Print button).  Bill output itself is untouched.
   ===================================================================== */
@media print {
    .app-ui { background: #fff; }
    .app-ui .topbar, .app-ui .sidebar, .app-ui .sidebar-backdrop { display: none !important; }
    .app-ui .layout { display: block; }
    .app-ui .content { margin: 0 !important; padding: 0 !important; max-width: none !important; }
    .app-ui .card, .app-ui .table-wrap { box-shadow: none; }
}


/* =====================================================================
   Mobile stability layer
   Keeps the desktop layout untouched. The bill templates / PDF canvas are
   intentionally excluded from these website-shell rules.
   ===================================================================== */
@media (max-width: 639px) {
    .app-ui .content { width:100%; min-width:0; padding:14px 12px 32px; overflow-x:hidden; }
    .app-ui .page-head { gap:10px; margin-bottom:14px; }
    .app-ui .page-head h1 { font-size:20px; line-height:1.3; }
    .app-ui .page-head .actions { width:100%; }
    .app-ui .page-head .actions .btn { flex:1 1 auto; }
    .app-ui .actions { width:100%; }
    .app-ui .actions .btn { min-width:0; }
    .app-ui .card { border-radius:12px; margin-bottom:12px; }
    .app-ui .card > .page-head { margin-left:0; margin-right:0; }
    .app-ui .grid-2, .app-ui .grid-3 { gap:10px; }
    .app-ui .form-row { gap:8px; }
    .app-ui .form-row > div { min-width:100%; }
    .app-ui .tabs { width:100%; max-width:100%; }
    .app-ui .table-wrap { width:100%; max-width:100%; overflow-x:auto; border-radius:10px; }
    .app-ui table { font-size:12.5px; }
    .app-ui th { padding:8px 10px; font-size:11.5px; }
    .app-ui td { padding:9px 10px; }
    .app-ui td.actions { white-space:normal; min-width:150px; }
    .app-ui td.actions > *, .app-ui td.actions form { margin:2px 4px 2px 0; }
    .app-ui .stat-cards { grid-template-columns:1fr 1fr; }
    .app-ui .stat-card { min-width:0; }
    .app-ui .stat-card .lbl { font-size:11px; }
    .app-ui .stat-card .num { font-size:19px; overflow-wrap:anywhere; }
    .app-ui .topbar { padding:0 10px; gap:8px; }
    .app-ui .brand { gap:7px; font-size:14px; }
    .app-ui .brand-mark { width:26px; height:26px; }
    .app-ui .topbar-title { display:none; }
    .app-ui .topbar-company { display:none; }
    .app-ui .user-menu > summary { padding-right:2px; }
    .app-ui .sidebar { width:min(290px,88vw); }

    /* New/Edit Bill: preserve the billing structure, but prevent cramped controls. */
    #billForm { width:100%; min-width:0; }
    #billForm > .card { padding:14px; }
    #billForm .pill-toggle { flex:1 1 100%; min-height:42px; }
    #billForm .product-block { overflow:hidden; }
    #billForm .product-block .page-head { align-items:flex-start; }
    #billForm .product-block .page-head > strong { min-width:0; overflow-wrap:anywhere; }
    #billForm .product-block .table-wrap { margin-left:0; margin-right:0; }
    #billForm .product-block table { min-width:650px; }
    #billForm .table-wrap { -webkit-overflow-scrolling:touch; }
    #billForm .actions .btn, #billForm button[type=submit] { width:100%; }
    #billForm .grid-3 { grid-template-columns:1fr; }
    #billForm .grid-2[style*="grid-column"] { grid-column:auto !important; }
    #billForm .inline-combo-new { flex-wrap:wrap; }
    #billForm .inline-combo-new select, #billForm .inline-combo-new input { min-width:0; flex:1 1 100%; }

    /* Lists: keep action buttons usable without making the whole page wider. */
    .app-ui .btn { white-space:normal; text-align:center; }
    .app-ui .btn.small { white-space:nowrap; }
}

/* ---- Continue with Google ---- */
.app-ui .or-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted); font-size: 12.5px; }
.app-ui .or-divider::before, .app-ui .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.app-ui .google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; box-sizing: border-box; text-decoration: none; }
