/* =========================================================
   Powercode Panel — Stylesheet (v3 — full dark UI)
   Concept: ink ledger — deep charcoal-navy throughout,
   cobalt + gold accent duo, serif display numerals
   Type: Fraunces (display/serif) + Inter (body/UI)
   ========================================================= */

:root {
    --bg:          #0B0D14;
    --sidebar-bg:  #090A10;
    --surface:     #151822;
    --surface-alt: #1C2029;
    --line:        #262B38;

    --text:       #EDEEF4;
    --text-muted: #9297AB;
    --text-faint: #666C80;

    --cobalt:      #5B84FF;
    --cobalt-soft: rgba(91, 132, 255, 0.14);
    --gold:        #DDA83E;
    --gold-soft:   rgba(221, 168, 62, 0.16);

    --success:      #27C08A;
    --success-soft: rgba(39, 192, 138, 0.14);
    --danger:       #F16472;
    --danger-soft:  rgba(241, 100, 114, 0.14);

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

    --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.45);
    --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 22px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    margin: 0;
    color: var(--text);
    letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #363D50; }

/* ---------------------------------------------
   App Shell / Layout
--------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 256px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

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

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--gold);
    color: #16130A;
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-mark-lg {
    width: 58px;
    height: 58px;
    font-size: 27px;
    border-radius: 14px;
    margin-bottom: 24px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: 'Fraunces', serif; font-size: 16.5px; color: #fff; font-weight: 600; }
.brand-text small { color: var(--text-faint); font-size: 11.5px; letter-spacing: 0.02em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-link svg { flex-shrink: 0; opacity: 0.9; }

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

.nav-link.active {
    background: var(--gold-soft);
    color: var(--gold);
    border-left-color: var(--gold);
}

.sidebar-footer {
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.nav-link-muted { color: var(--text-faint); }

/* Main panel */
.main-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 36px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-title h1 { font-size: 22px; }

.topbar-user { display: flex; align-items: center; gap: 16px; }

.user-chip { display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--cobalt);
}

.user-name { font-size: 13.5px; font-weight: 500; color: var(--text); }

.btn-logout {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

.content {
    padding: 32px 36px 52px;
    animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .content { animation: none; }
}

/* ---------------------------------------------
   Stat Cards (Dashboard)
--------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--cobalt);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.stat-grid .stat-card:nth-of-type(1) { border-left-color: var(--cobalt); }
.stat-grid .stat-card:nth-of-type(2) { border-left-color: var(--gold); }
.stat-grid .stat-card:nth-of-type(3) { border-left-color: var(--success); }

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
    border-color: #323A4E;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-label { color: var(--text-muted); font-size: 13px; font-weight: 500; }

.stat-icon {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
}
.icon-blue  { background: var(--cobalt-soft); color: var(--cobalt); }
.icon-teal  { background: var(--gold-soft); color: var(--gold); }
.icon-amber { background: var(--success-soft); color: var(--success); }

.stat-value {
    font-family: 'Fraunces', serif;
    font-size: 36px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #fff;
}

.stat-sub { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot-green { background: var(--success); }
.dot-red { background: var(--danger); }

/* Panel grid (recent tables on dashboard) */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.panel-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.panel-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.panel-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-card-head h3 { font-size: 16px; }

.link-more { color: var(--cobalt); font-size: 13px; font-weight: 500; }
.link-more:hover { text-decoration: underline; }

.mini-table { width: 100%; border-collapse: collapse; }
.mini-table td { padding: 10px 4px; border-top: 1px solid var(--line); font-size: 13.5px; }
.mini-table tr:first-child td { border-top: none; }

/* ---------------------------------------------
   Toolbar / Search / Buttons
--------------------------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 260px;
}

.search-form input[type="text"],
.search-form select {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    outline: none;
}

.search-form input[type="text"] { flex: 1; min-width: 180px; }
.search-form input:focus, .search-form select:focus { border-color: var(--cobalt); }

.btn-primary {
    background: var(--cobalt);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background: #4A70E8; }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.btn-ghost:hover { border-color: var(--cobalt); background: var(--cobalt-soft); }

.btn-block { width: 100%; padding: 12px; margin-top: 8px; }

/* ---------------------------------------------
   Client Ledger
--------------------------------------------- */
.ledger-select-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--cobalt);
    border-radius: var(--radius-lg);
    padding: 24px 26px;
    box-shadow: var(--shadow-card);
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}
.ledger-select-card h3 { font-size: 17px; margin-bottom: 5px; }
.ledger-select-card p { color: var(--text-muted); font-size: 13px; margin: 0; max-width: 360px; }

.ledger-select-form {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 300px;
    max-width: 480px;
}
.ledger-select-form select {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    outline: none;
}
.ledger-select-form select:focus { border-color: var(--cobalt); }

.ledger-section-divider {
    margin: 34px 0 18px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}
.ledger-section-divider-first { margin-top: 0; padding-top: 0; border-top: none; }
.ledger-section-divider h2 { font-size: 20px; margin-bottom: 4px; }
.ledger-section-divider p { color: var(--text-muted); font-size: 13px; margin: 0; }

/* ---------------------------------------------
   Terms & Conditions
--------------------------------------------- */
.page-lead { color: var(--text-muted); font-size: 13.5px; margin: 0; max-width: 520px; }

.term-list { display: flex; flex-direction: column; gap: 12px; }

.term-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s ease;
}
.term-item:hover { border-color: #323A4E; }

.term-number {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--cobalt-soft);
    color: var(--cobalt);
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.term-text {
    flex: 1;
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    padding-top: 2px;
}

.term-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 2px;
}

.action-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* ---------------------------------------------
   Bank Details
--------------------------------------------- */
.field-hint { font-size: 12px; color: var(--text-faint); margin: 4px 0 0; }

.bank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 18px;
}

.bank-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.bank-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--line);
}
.bank-card-head h3 { font-size: 15px; }
.bank-card-actions { display: flex; gap: 2px; }

.bank-card-body {
    padding: 18px 20px 20px;
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.bank-fields { flex: 1; min-width: 0; }

.bank-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}
.bank-row:last-child { border-bottom: none; }
.bank-row span { color: var(--text-muted); flex-shrink: 0; }
.bank-row strong { color: var(--text); font-weight: 600; text-align: right; word-break: break-word; }

.bank-qr {
    flex-shrink: 0;
    width: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.bank-qr img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: #fff;
    padding: 4px;
}
.bank-qr span { font-size: 11px; color: var(--text-faint); }

@media (max-width: 560px) {
    .bank-card-body { flex-direction: column; align-items: stretch; }
    .bank-qr { width: 100%; flex-direction: row; justify-content: center; }
}

/* ---------------------------------------------
   Invoice Profile
--------------------------------------------- */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 18px;
}

.profile-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--cobalt);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 18px 20px 20px;
}

.profile-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.profile-card-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.profile-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    flex-shrink: 0;
    padding: 3px;
}
.profile-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cobalt-soft);
    color: var(--cobalt);
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 18px;
    border: none;
    padding: 0;
}

.profile-card-title h3 { font-size: 16px; margin-bottom: 3px; }
.profile-desc { color: var(--text-muted); font-size: 12.5px; margin: 0; line-height: 1.5; }

.profile-fields { margin-top: 4px; }

/* ---------------------------------------------
   Invoice Generator — form
--------------------------------------------- */
.invoice-form { display: flex; flex-direction: column; gap: 18px; max-width: 900px; }

.section-title {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}
.section-title .optional { font-size: 12.5px; font-weight: 400; color: var(--text-faint); }

.form-actions-page {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    max-width: 900px;
}

.items-table-wrap { overflow-x: auto; margin-bottom: 14px; }

.invoice-items-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.invoice-items-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 8px 10px;
}
.invoice-items-table .col-qty, .invoice-items-table .col-price, .invoice-items-table .col-amount { width: 110px; }
.invoice-items-table .col-remove { width: 36px; }

.invoice-items-table td { padding: 5px 8px; vertical-align: middle; }
.invoice-items-table input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}
.invoice-items-table input:focus { border-color: var(--cobalt); }
.invoice-items-table .amount-display {
    color: var(--text-muted);
    background: var(--surface-alt);
    cursor: default;
}

.remove-item-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-muted);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.remove-item-btn:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.remove-item-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.invoice-total-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    padding: 16px 0 4px;
    border-top: 1px solid var(--line);
    margin-top: 10px;
}
.invoice-total-row span { color: var(--text-muted); font-size: 13.5px; }
.invoice-total-row strong { font-family: 'Fraunces', serif; font-size: 22px; color: var(--gold); }

.terms-check-list { display: flex; flex-direction: column; gap: 10px; }
.term-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.term-check:hover { border-color: var(--cobalt); background: var(--cobalt-soft); }
.term-check input { margin-top: 3px; accent-color: var(--cobalt); flex-shrink: 0; }
.term-check span { font-size: 13.5px; line-height: 1.5; color: var(--text); }

/* ---------------------------------------------
   Invoice — printable paper
--------------------------------------------- */
.invoice-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 800px;
    margin-bottom: 18px;
}

.invoice-paper {
    background: #ffffff;
    color: #1a1a1a;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    max-width: 800px;
    margin: 0 auto;
    padding: 44px 48px;
    font-family: 'Inter', sans-serif;
}

.invoice-paper-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 22px;
    border-bottom: 2px solid #1a1a1a;
    margin-bottom: 24px;
}

.invoice-brand { display: flex; gap: 14px; align-items: flex-start; }
.invoice-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.invoice-brand h1 { font-family: 'Fraunces', serif; font-size: 22px; color: #1a1a1a; margin-bottom: 4px; }
.invoice-brand p { font-size: 12.5px; color: #555; margin: 2px 0; line-height: 1.5; max-width: 320px; }
.invoice-brand-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px !important; }
.invoice-brand-meta span { font-size: 11.5px; color: #666; }

.invoice-meta { text-align: right; flex-shrink: 0; }
.invoice-meta h2 { font-family: 'Fraunces', serif; font-size: 20px; letter-spacing: 0.08em; color: #1a1a1a; margin-bottom: 8px; }
.invoice-meta p { font-size: 13px; color: #444; margin: 2px 0; }

.invoice-bill-to { margin-bottom: 26px; }
.invoice-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #999; margin-bottom: 6px; }
.invoice-bill-to h3 { font-family: 'Fraunces', serif; font-size: 16px; color: #1a1a1a; margin-bottom: 3px; }
.invoice-bill-to p { font-size: 13px; color: #555; margin: 2px 0; }

.invoice-print-table { width: 100%; border-collapse: collapse; margin-bottom: 26px; }
.invoice-print-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #888;
    padding: 0 6px 10px;
    border-bottom: 2px solid #1a1a1a;
}
.invoice-print-table td { padding: 11px 6px; font-size: 13.5px; color: #333; border-bottom: 1px solid #e5e5e5; }
.invoice-print-table .ta-right { text-align: right; }
.invoice-print-table tfoot td { border-bottom: none; padding-top: 16px; font-size: 14px; color: #1a1a1a; }
.invoice-total-cell { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 600; color: #1a1a1a; }

.invoice-payment { margin-bottom: 24px; padding-top: 20px; border-top: 1px solid #e5e5e5; }
.invoice-payment-body { display: flex; gap: 24px; align-items: flex-start; }
.invoice-payment-fields { flex: 1; min-width: 0; }
.invoice-payment .bank-row { border-bottom: 1px solid #f0f0f0; padding: 6px 0; font-size: 12.5px; }
.invoice-payment .bank-row span { color: #888; }
.invoice-payment .bank-row strong { color: #1a1a1a; }
.invoice-payment .bank-qr img { border: 1px solid #ddd; }
.invoice-payment .bank-qr span { color: #999; }

.invoice-terms { padding-top: 18px; border-top: 1px solid #e5e5e5; }
.invoice-terms ol { margin: 8px 0 0; padding-left: 18px; }
.invoice-terms li { font-size: 12px; color: #555; line-height: 1.7; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    body, .content { background: #fff !important; padding: 0 !important; margin: 0 !important; }
    .main-panel { width: 100%; }
    .invoice-paper { box-shadow: none; border-radius: 0; margin: 0; max-width: 100%; padding: 0; }
    .app-shell { display: block; }
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
    transition: color 0.15s ease;
}
.back-link:hover { color: var(--cobalt); }

.client-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.client-head h1 { font-size: 26px; margin-bottom: 6px; }
.client-head-meta { color: var(--text-muted); font-size: 13.5px; margin: 0; }

.value-due     { color: var(--gold) !important; }
.value-advance { color: var(--cobalt) !important; }
.value-clear   { color: var(--success) !important; }

.balance-amt { font-size: 13.5px; font-weight: 600; }
.balance-due     { color: var(--gold); }
.balance-advance { color: var(--cobalt); }
.balance-clear   { color: var(--success); font-weight: 500; }

.amt-due     { color: var(--gold); }
.amt-payment { color: var(--success); }

.btn-due {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.btn-due:hover { background: var(--gold-soft); }

.btn-payment {
    background: var(--success);
    border: none;
    color: #06120C;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s ease;
}
.btn-payment:hover { filter: brightness(1.1); }

/* ---------------------------------------------
   Modal (Add Client / Add Company popup)
--------------------------------------------- */
.hidden { display: none !important; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 10, 0.62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    animation: overlayIn 0.18s ease both;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    animation: modalIn 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 26px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-head h3 { font-size: 18px; }

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }

.modal-body { padding: 24px 26px 26px; }

.modal-body .form-grid { gap: 16px 18px; }

@media (max-width: 620px) {
    .modal-body .form-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------
   Table
--------------------------------------------- */
.table-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-alt);
}

.data-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: var(--surface-alt); }

.cell-strong { font-weight: 600; color: #fff; }
.muted { color: var(--text-faint); }
.col-actions { text-align: right; white-space: nowrap; }

.empty-state {
    text-align: center;
    padding: 46px 20px;
    color: var(--text-muted);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: var(--text-muted);
    margin-left: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}
.action-btn:hover { background: var(--cobalt-soft); color: var(--cobalt); }
.action-danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------
   Forms (Add / Edit)
--------------------------------------------- */
.form-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 760px;
    box-shadow: var(--shadow-card);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 20px;
}

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

.field label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.field .optional { color: var(--text-faint); font-weight: 400; }

.field input, .field select, .field textarea {
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: vertical;
    transition: border-color 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--cobalt); }

.field input[type="file"] {
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
}
.field input[type="file"]::file-selector-button,
.field input[type="file"]::-webkit-file-upload-button {
    background: var(--cobalt);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-right: 12px;
    transition: background 0.15s ease;
}
.field input[type="file"]::file-selector-button:hover,
.field input[type="file"]::-webkit-file-upload-button:hover {
    background: #4A70E8;
}

.field select option { background: var(--surface); color: var(--text); }

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 6px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); color: var(--success); border-color: rgba(39, 192, 138, 0.3); }
.alert-error   { background: var(--danger-soft); color: var(--danger); border-color: rgba(241, 100, 114, 0.3); }

/* ---------------------------------------------
   Login Page
--------------------------------------------- */
.login-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.login-wrap {
    display: flex;
    width: 100%;
    max-width: 940px;
    min-height: 540px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    margin: 24px;
}

.login-side {
    flex: 1;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 46px;
    position: relative;
    overflow: hidden;
}

.login-side::before {
    content: '';
    position: absolute;
    width: 340px;
    height: 340px;
    right: -120px;
    bottom: -130px;
    border-radius: 50%;
    background: var(--gold);
    opacity: 0.14;
}

.login-side::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    left: -80px;
    top: -80px;
    border-radius: 50%;
    background: var(--cobalt);
    opacity: 0.16;
}

.login-side-inner { position: relative; z-index: 1; }

.login-side h2 {
    font-size: 27px;
    line-height: 1.3;
    margin-bottom: 12px;
    color: #fff;
}

.login-side p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.65;
    margin-bottom: 22px;
}

.login-points { display: flex; flex-direction: column; gap: 11px; }
.login-points li {
    font-size: 13.5px;
    color: var(--text);
    padding-left: 20px;
    position: relative;
}
.login-points li::before {
    content: '';
    position: absolute;
    left: 0; top: 7px;
    width: 8px; height: 8px;
    border-radius: 2px;
    background: var(--gold);
}

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 46px;
    background: var(--surface);
}

.login-card { width: 100%; max-width: 320px; }
.login-card h1 { font-size: 26px; margin-bottom: 5px; color: #fff; }
.login-sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 24px; }

.login-card label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin: 14px 0 7px;
}

.login-card input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}
.login-card input:focus { border-color: var(--cobalt); }

/* ---------------------------------------------
   Responsive
--------------------------------------------- */
@media (max-width: 900px) {
    .login-side { display: none; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        padding: 14px 16px;
        gap: 14px;
    }
    .sidebar-brand { border-bottom: none; padding: 0; margin: 0; }
    .brand-text { display: none; }
    .sidebar-nav { flex-direction: row; overflow-x: auto; }
    .nav-link span { display: none; }
    .nav-link { border-left: none; border-bottom: 2px solid transparent; }
    .nav-link.active { border-left: none; border-bottom-color: var(--gold); }
    .sidebar-footer { display: none; }
    .topbar { padding: 16px 18px; }
    .content { padding: 20px 18px 36px; }
    .data-table th, .data-table td { padding: 12px; }
}