/* ════════════════════════════════════════════════════════════
   BillingDesk — Main Stylesheet
   A clean, professional accounting interface
   ════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* === THEME COLORS (Your palette) === */
  --saffron:       #C95F1A;
  --saffron-light: #E8813A;
  --saffron-pale:  #FDF0E6;
  --ochre:         #A64A0A;
  --gold:          #D4963A;
  --gold-light:    #F5D9A0;
  --turmeric:      #E8B84B;
  --ink:           #1C1208;
  --ink-mid:       #3D2B0E;
  --ink-soft:      #6B4C22;
  --parchment:     #FBF6EF;
  --parchment-2:   #F5EDD8;
  --stone:         #E9E0D0;
  --stone-dark:    #CFC3AD;
  --white:         #FFFDF9;

  /* === BASE STATE COLORS (UNCHANGED MEANING) === */
  --red-soft:      #C0392B;
  --green-soft:    #2D7D46;

  /* === NEW: TEXT ROLES (critical fix) === */
  --red-text-strong:   #7A1F1A;  /* for light backgrounds */
  --green-text-strong: #1E4D2B;

  --on-red:   #ffffff; /* for solid red bg */
  --on-green: #ffffff; /* for solid green bg */

  /* === SEMANTIC MAPPING === */
  --bg:            var(--parchment);
  --surface:       var(--white);
  --surface-hover: var(--parchment-2);

  /* FIXED (correct hierarchy) */
  --border:        var(--stone-dark);
  --border-light:  var(--stone);

  --accent:        var(--saffron);
  --accent-hover:  var(--saffron-light);
  --accent-soft:   rgba(201, 95, 26, 0.1);

  /* IMPORTANT: keep base colors for background usage */
  --green:         var(--green-soft);
  --red:           var(--red-soft);

  /* Soft backgrounds */
  --green-soft-bg: rgba(45,125,70,0.12);
  --red-soft-bg:   rgba(192,57,43,0.12);

  --amber:         var(--turmeric);
  --amber-soft:    rgba(232,184,75,0.15);

  --purple:        var(--gold);
  --purple-soft:   rgba(212,150,58,0.12);

  --text:          var(--ink);
  --text-muted:    var(--ink-soft);
  --text-dim:      var(--ink-mid);

  /* === UI TOKENS === */
  --radius:        10px;
  --radius-lg:     14px;
  --shadow:        0 4px 24px rgba(100, 60, 0, 0.12);

  /* === TYPOGRAPHY === */
  --font-body:  'DM Sans', sans-serif;
  --font-serif: 'Libre Baskerville', serif;
  --font-deva:  'Noto Sans Devanagari', sans-serif;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}




*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

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

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border-light); border-radius:3px; }

/* ── Layout ────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
}

.mobile-header {
    display: none;
}

.mobile-tabbar {
    display: none;
}

/* ── Sidebar ───────────────────────────────── */
.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.mobile-logout {
    display: none;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
    color: #fff;
}

.sidebar-brand h1 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-brand small {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.sidebar-nav a svg { width:18px; height:18px; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-dim);
}

/* ── Main Content ──────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    min-height: 100vh;
    width: 100%;
    max-width: calc(100vw - 240px);
    overflow-x: hidden;
}

/* ── Page Header ───────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.main-content > * {
    min-width: 0;
}

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: 0 2px 14px rgba(100, 60, 0, 0.04);
    min-width: 0;
}

.card.no-pad { padding: 0; }

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg { width:20px; height:20px; stroke-width:2; fill:none; stroke-linecap:round; stroke-linejoin:round; }

.stat-label { font-size:12px; color:var(--text-muted); margin-bottom:2px; }
.stat-value { font-size:22px; font-weight:700; }

/* ── Grid layouts ──────────────────────────── */
.grid-4 { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:16px; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }

/* ── Tables ────────────────────────────────── */
.card.no-pad {
    overflow-x: auto;
    max-width: 100%;
}

.data-table { width:100%; max-width:100%; border-collapse:collapse; }
.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
}
.data-table th.right { text-align:right; }
.data-table th.center { text-align:center; }

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:hover { background: var(--surface-hover); }
.data-table tr:last-child td { border-bottom:none; }

.mono { font-family:'JetBrains Mono', monospace; font-size:13px; }
.text-right { text-align:right; }
.text-center { text-align:center; }
.fw-600 { font-weight:600; }
.fw-700 { font-weight:700; }
.text-muted { color:var(--text-muted); }
.text-dim { color:var(--text-dim); }
.text-green { color:var(--green); }
.text-red { color:var(--red); }
.text-amber { color:var(--amber); }
.text-accent { color:var(--accent); }

/* ── Badges ────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-blue   { color:var(--accent); background:var(--accent-soft); }
.badge-green  { color:var(--white);  background:var(--green-soft); }
.badge-red    { color:var(--white);    background:var(--red-soft); }
.badge-amber  { color:var(--amber);  background:var(--amber-soft); }
.badge-purple { color:var(--purple); background:var(--purple-soft); }

/* ── Buttons ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 18px;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg { width:16px; height:16px; }

/* PRIMARY */
.btn-primary {
    background: var(--accent);
    color: var(--white);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--white);
}

/* SUCCESS (FIXED) */
.btn-success {
    background: var(--green-soft);   /* solid green */
    color: var(--on-green);          /* white text */
}
.btn-success:hover {
    background: #256b3a;             /* slightly darker green */
    color: var(--on-green);
}

/* DANGER (FIXED) */
.btn-danger {
    background: var(--red-soft);     /* solid red */
    color: var(--on-red);            /* white text */
}
.btn-danger:hover {
    background: #a93226;             /* darker red */
    color: var(--on-red);
}

/* GHOST */
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* SMALL */
.btn-sm {
    font-size: 12px;
    padding: 6px 12px;
}
.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* GROUP */
.btn-group {
    display: flex;
    gap: 6px;
}
/* ── Forms ─────────────────────────────────── */
.form-group { margin-bottom:16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-control:focus { outline:none; border-color:var(--accent); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238B8FA3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

textarea.form-control { resize:vertical; min-height:70px; }

.form-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.form-row-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }
.form-full { grid-column:1/-1; }

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ── Search bar ────────────────────────────── */
.search-bar {
    position: relative;
    margin-bottom: 20px;
    max-width: 100%;
}
.search-bar .form-control { padding-left:40px; }
.search-bar svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--text-dim);
    fill: none;
    stroke-width: 2;
}

/* ── Filter tabs ───────────────────────────── */
.filter-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
    transition: all var(--transition);
}

.filter-tab:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.filter-tab.active {
    background: var(--accent-soft);
    border-color: rgba(201, 95, 26, 0.2);
    color: var(--accent);
}

.filter-tab-count {
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    font-size: 11px;
    text-align: center;
}

/* ── Flash / Alert ─────────────────────────── */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}
/* SUCCESS */
.alert-success {
  background: var(--green-soft-bg);
  color: var(--green-text-strong);
  border: 1px solid rgba(45,125,70,0.25);
}

/* ERROR */
.alert-error {
  background: var(--red-soft-bg);
  color: var(--red-text-strong);
  border: 1px solid rgba(192,57,43,0.25);
}

/* INFO */
.alert-info {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(201,95,26,0.25);
}

/* ── Empty state ───────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}
.empty-state .icon { font-size:48px; margin-bottom:12px; }
.empty-state h3 { font-size:15px; font-weight:600; color:var(--text-muted); margin-bottom:4px; }
.empty-state p { font-size:13px; }

/* ── Avatar / Initial ──────────────────────── */
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.customer-cell { display:flex; align-items:center; gap:10px; }
.customer-cell .name { font-weight:600; }
.customer-cell .sub { font-size:12px; color:var(--text-muted); }

/* ── Invoice detail ────────────────────────── */
.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.invoice-title { font-size:24px; font-weight:800; color:var(--accent); letter-spacing:-0.5px; }

.invoice-meta { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-bottom:24px; }
.invoice-meta .block { padding:14px; border-radius:var(--radius); background:var(--surface); }
.invoice-meta .block-label { font-size:11px; font-weight:700; color:var(--text-dim); text-transform:uppercase; letter-spacing:1px; margin-bottom:6px; }

.invoice-totals {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}
.invoice-totals table { width:280px; }
.invoice-totals td { padding:6px 0; font-size:14px; }
.invoice-totals .total-row td { border-top:2px solid var(--accent); padding-top:12px; font-size:18px; font-weight:800; }

.amount-words {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

/* ── Login page ────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-box {
    width: 400px;
    padding: 40px;
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-box h1 { text-align:center; font-size:24px; margin-bottom:8px; }
.login-box p { text-align:center; color:var(--text-muted); margin-bottom:28px; font-size:14px; }

/* ── Animations ────────────────────────────── */
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideIn { from{opacity:0;transform:translateX(-12px)} to{opacity:1;transform:translateX(0)} }

.fade-in { animation: fadeIn 0.3s ease; }

/* ── Responsive ────────────────────────────── */
@media (max-width: 1080px) {
    .grid-2,
    .grid-3,
    .form-row,
    .form-row-3,
    .invoice-meta {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: flex-start;
        gap: 16px;
        flex-direction: column;
    }

    .page-header .btn-group {
        flex-wrap: wrap;
    }
}

@media (max-width: 860px) {
    .app-layout {
        display: block !important;
        width: 100vw !important;
        max-width: 100vw !important;
    }

    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 90;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 16px;
        background: rgba(255, 253, 249, 0.95);
        backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--border);
    }

    .mobile-header-brand {
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .mobile-header-brand .logo {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        background: linear-gradient(135deg, var(--accent), var(--purple));
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-weight: 800;
    }

    .mobile-header-brand strong {
        display: block;
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-header-brand small {
        display: block;
        font-size: 11px;
        color: var(--text-dim);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-logout {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 42px;
        padding: 0 12px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
        color: var(--text);
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
    }

    .sidebar {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
    }

    .sidebar * {
        display: none !important;
    }

    .main-content {
        display: block;
        margin: 0 !important;
        padding: 78px 16px 92px !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
    }

    .mobile-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 95;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 253, 249, 0.98);
        border-top: 1px solid var(--border);
        backdrop-filter: blur(16px);
        box-shadow: 0 -10px 30px rgba(100, 60, 0, 0.08);
    }

    .mobile-tabbar a {
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 4px;
        border-radius: 14px;
        color: var(--text-dim);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.02em;
    }

    .mobile-tabbar a svg {
        width: 20px;
        height: 20px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .mobile-tabbar a span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .mobile-tabbar a.active {
        color: var(--accent);
        background: var(--accent-soft);
    }

    .card.no-pad {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 620px;
    }

    .invoice-header {
        flex-direction: column;
        gap: 18px;
    }

    .invoice-totals {
        justify-content: stretch;
    }

    .invoice-totals table {
        width: 100%;
    }

    .btn,
    .form-control {
        min-height: 44px;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 74px 12px 92px !important;
    }

    .page-header,
    .search-bar,
    .filter-tabs,
    .grid-2,
    .grid-3,
    .grid-4,
    .card,
    .invoice-header,
    .invoice-meta,
    .invoice-totals,
    .amount-words {
        max-width: 100%;
    }

    .card {
        padding: 16px;
        border-radius: 12px;
    }

    .card.no-pad {
        padding: 0;
    }

    .page-header h1 {
        font-size: 22px;
    }

    .stat-card {
        align-items: flex-start;
        gap: 12px;
    }

    .stat-value {
        font-size: 20px;
    }

    .btn-group {
        width: 100%;
        flex-wrap: wrap;
        max-width: 100%;
    }

    .btn-group .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .login-wrapper {
        padding: 16px;
        align-items: stretch;
    }

    .login-box {
        width: 100%;
        padding: 24px 18px;
        border-radius: 14px;
        margin: auto 0;
    }

    .mobile-header {
        padding: 10px 12px;
    }

    .mobile-header-brand strong {
        font-size: 13px;
    }

    .mobile-header-brand small {
        font-size: 10px;
    }

    .mobile-logout {
        min-height: 38px;
        padding: 0 10px;
        font-size: 11px;
    }

    .data-table {
        min-width: 560px;
    }

    .data-table.responsive-stack {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 12px;
    }

    .data-table.responsive-stack thead {
        display: none;
    }

    .data-table.responsive-stack tbody {
        display: block;
    }

    .data-table.responsive-stack tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 14px;
        box-shadow: 0 2px 14px rgba(100, 60, 0, 0.05);
        overflow: hidden;
    }

    .data-table.responsive-stack td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        padding: 10px 14px;
        border-bottom: 1px solid var(--border);
        text-align: right !important;
        white-space: normal;
    }

    .data-table.responsive-stack td:last-child {
        border-bottom: none;
    }

    .data-table.responsive-stack td::before {
        content: attr(data-label);
        flex: 0 0 40%;
        min-width: 94px;
        text-align: left;
        font-size: 11px;
        font-weight: 700;
        color: var(--text-dim);
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }

    .data-table.responsive-stack td[data-label="Customer"],
    .data-table.responsive-stack td[data-label="User"],
    .data-table.responsive-stack td[data-label="Product / Service"],
    .data-table.responsive-stack td[data-label="Invoice #"] {
        align-items: flex-start;
    }

    .data-table.responsive-stack td[data-label="Customer"] .customer-cell,
    .data-table.responsive-stack td[data-label="User"] .customer-cell,
    .data-table.responsive-stack td[data-label="Actions"] .btn-group {
        width: 100%;
    }

    .data-table.responsive-stack td[data-label="Actions"] .btn-group {
        justify-content: flex-start !important;
    }

    .data-table.responsive-stack td[data-label="Actions"] {
        text-align: left !important;
    }

    .data-table.responsive-stack td[data-label="Actions"]::before {
        align-self: center;
    }

    .data-table.responsive-stack td[data-label="Customer"] .customer-cell {
        align-items: flex-start;
    }

    .data-table.responsive-stack td[data-label="User"] .customer-cell {
        align-items: flex-start;
    }

    .data-table.responsive-stack td[data-label="Product / Service"] > div,
    .data-table.responsive-stack td[data-label="Invoice #"] > a {
        text-align: left;
    }

    .data-table.responsive-stack td .badge {
        white-space: nowrap;
    }

    .settings-inline-action,
    .settings-table-header,
    .settings-role-form {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .settings-inline-action .btn,
    .settings-role-form .btn {
        width: 100%;
        justify-content: center;
    }

    .settings-role-form .form-control {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* ── Print styles ──────────────────────────── */
@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    html,
    body {
        background: #fff !important;
        color: #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .mobile-header,
    .mobile-tabbar {
        display:none !important;
    }
    .sidebar,
    .page-header .btn,
    .btn-group,
    .no-print,
    .alert {
        display:none !important;
    }

    .app-layout {
        display: block !important;
        min-height: auto !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        min-height: auto !important;
    }

    .fade-in {
        animation: none !important;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }

    .badge {
        border: 1px solid currentColor;
    }

    .page-invoice_view .fade-in > .invoice-sheet {
        margin: 0 !important;
    }

    .page-invoice_view .invoice-sheet {
        background: #fff !important;
        border: 1px solid #d8c8b2 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 18mm 16mm !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .page-invoice_view .invoice-sheet .invoice-title,
    .page-invoice_view .invoice-sheet .text-accent {
        color: var(--accent) !important;
    }

    .page-invoice_view .invoice-sheet .invoice-header {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start;
        gap: 20px;
        border-bottom: 1px solid #cdbca3;
        page-break-after: avoid;
    }

    .page-invoice_view .invoice-sheet .invoice-meta {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 16px !important;
        page-break-inside: avoid;
    }

    .page-invoice_view .invoice-sheet .invoice-totals {
        display: flex !important;
        justify-content: flex-end !important;
    }

    .page-invoice_view .invoice-sheet .invoice-totals table {
        width: 280px !important;
    }

    .page-invoice_view .invoice-sheet .invoice-meta .block {
        background: #f7f0e5 !important;
        border: 1px solid #d8c8b2;
    }

    .page-invoice_view .invoice-sheet .data-table {
        table-layout: fixed;
    }

    .page-invoice_view .invoice-sheet .data-table th,
    .page-invoice_view .invoice-sheet .data-table td {
        border-color: #d8c8b2 !important;
    }

    .page-invoice_view .invoice-sheet .data-table th {
        background: #f7f0e5 !important;
        color: #5f4825 !important;
    }

    .page-invoice_view .invoice-sheet .data-table tr:hover {
        background: transparent !important;
    }

    .page-invoice_view .invoice-sheet .invoice-totals {
        margin-top: 16px;
        page-break-inside: avoid;
    }

    .page-invoice_view .invoice-sheet .invoice-totals .total-row td {
        border-top: 2px solid var(--accent) !important;
    }

    .page-invoice_view .invoice-sheet .amount-words {
        background: #fdf0e6 !important;
        border: 1px solid #e9c49d;
        color: #8a3f11 !important;
    }

    .page-invoice_view .invoice-sheet .text-muted,
    .page-invoice_view .invoice-sheet .text-dim {
        color: #6a5741 !important;
    }

    .page-invoice_view .invoice-sheet .text-white,
    .page-invoice_view .invoice-sheet .text-amber,
    .page-invoice_view .invoice-sheet .text-red,
    .page-invoice_view .invoice-sheet .text-green {
        color: inherit !important;
    }

    .page-invoice_view .invoice-sheet .badge-blue {
        background: rgba(201, 95, 26, 0.12) !important;
        color: var(--accent) !important;
    }

    .page-invoice_view .invoice-sheet .badge-purple {
        background: rgba(212, 150, 58, 0.14) !important;
        color: #8b6418 !important;
    }

    .page-invoice_view .invoice-sheet .badge-green {
        background: rgba(45, 125, 70, 0.14) !important;
        color: #1f5b30 !important;
    }

    .page-invoice_view .invoice-sheet .badge-amber {
        background: rgba(232, 184, 75, 0.16) !important;
        color: #8a6111 !important;
    }

    .page-invoice_view .invoice-sheet .badge-red {
        background: rgba(192, 57, 43, 0.12) !important;
        color: #8d2e25 !important;
    }

    .page-invoice_view .invoice-sheet .mono {
        font-size: 12px;
    }
}
