/* Blue Sky Technology Group LLC — design tokens & layout (see docs/frontend.md) */
:root {
    --bg: #0f172a;
    --panel: #1e293b;
    --panel-2: #273449;
    --line: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --green: #34d399;
    --amber: #fbbf24;
    --red: #f87171;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
    font-size: 15px;
}

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

.boot, .page-loading {
    display: flex; align-items: center; justify-content: center;
    height: 60vh; color: var(--muted); font-size: 17px;
}

/* ---- shell: right-side vertical nav + content (RTL) ---- */
.shell { min-height: 100vh; display: flex; }

.sidenav {
    width: 250px; flex-shrink: 0;
    background: var(--panel); border-left: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand {
    padding: 16px 18px; border-bottom: 1px solid var(--line);
    background: linear-gradient(120deg, #0c4a6e, #1e293b);
    display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.brand h1 { margin: 0; font-size: 20px; }
.brand .sub { color: var(--muted); font-size: 12px; }
.brand-name {
    max-width: 100%;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 700;
    color: #e2e8f0;
}

/* ---- custom scrollbars (dark theme) ---- */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.navlist { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.navitem, .navgroup {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: var(--muted); background: none; border: none;
    font: inherit; font-size: 14px; cursor: pointer;
    width: 100%; text-align: right;
}
.navitem:hover, .navgroup:hover { background: var(--panel-2); color: var(--text); }
.navitem.active { background: rgba(56, 189, 248, .12); color: var(--accent); }
.navitem svg, .navgroup svg { flex-shrink: 0; }
.navgroup .chev { margin-inline-start: auto; font-size: 11px; opacity: .7; }

.subnav { display: flex; flex-direction: column; gap: 2px; padding: 2px 6px 6px; }
.subnav a {
    padding: 8px 12px; border-radius: 8px; margin-inline-start: 22px;
    color: var(--muted); font-size: 13.5px;
}
.subnav a:hover { background: var(--panel-2); color: var(--text); }
.subnav a.active { color: var(--accent); background: rgba(56, 189, 248, .1); }

.navbottom { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.navbottom .who { color: var(--muted); font-size: 12px; padding: 8px 12px 2px; }
.navitem.logout:hover { color: var(--red); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 22px; max-width: 1180px; margin: 0 auto; width: 100%; }
/* the invoices master-detail wants the full width (no centered cap, tighter padding) */
.content:has(.md-layout) { max-width: 100%; padding: 14px; }

@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidenav { width: 100%; height: auto; position: static; border-left: none; border-bottom: 1px solid var(--line); }
    .navlist { max-height: 50vh; }
}

/* ---- cards ---- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; padding: 16px 18px;
}
.card .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card .value { font-size: 26px; font-weight: 700; }
.card.alert .value { color: var(--amber); }
.card.danger .value { color: var(--red); }
.card.good .value { color: var(--green); }

/* ---- tables ---- */
table {
    width: 100%; border-collapse: collapse;
    background: var(--panel); border-radius: 12px; overflow: hidden;
}
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); }
th {
    position: sticky; top: 0; background: var(--panel-2);
    color: var(--muted); font-weight: 600; font-size: 13px;
}
tbody tr:hover { background: var(--panel-2); }
tr.clickable { cursor: pointer; }
.num { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; unicode-bidi: embed; }

/* ---- pills & badges ---- */
.pill {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; direction: ltr;
}
.pill.green { background: rgba(52, 211, 153, .15); color: var(--green); }
.pill.amber { background: rgba(251, 191, 36, .15); color: var(--amber); }
.pill.red { background: rgba(248, 113, 113, .15); color: var(--red); }
.pill.gray { background: rgba(148, 163, 184, .15); color: var(--muted); }

/* ---- forms & controls ---- */
input, select {
    background: var(--panel-2); border: 1px solid var(--line);
    color: var(--text); padding: 8px 12px; border-radius: 8px;
    font-family: inherit; font-size: 14px;
}
input:focus, select:focus { outline: 1px solid var(--accent); }
input[type="text"], input[type="password"] { min-width: 220px; }

button, .btn {
    background: var(--accent); color: #082f49; border: none;
    padding: 9px 18px; border-radius: 8px; font-weight: 600;
    font-family: inherit; font-size: 14px; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: default; }
.btn-ghost {
    background: transparent; color: var(--muted);
    border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { background: rgba(248, 113, 113, .15); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.toolbar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 14px; flex-wrap: wrap;
}

.pager {
    display: flex; align-items: center; justify-content: center;
    gap: 16px; margin-top: 16px;
}

/* client picker dropdown */
.picker-results {
    position: absolute; top: 100%; right: 0; z-index: 20;
    width: 320px; max-height: 280px; overflow-y: auto;
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 8px; margin-top: 4px;
}
.picker-item {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.picker-item:hover { background: var(--panel); }
.picker-item:last-child { border-bottom: none; }

.checkrow { display: flex; align-items: center; gap: 8px; }
.selbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; padding: 12px 16px; margin: 12px 0;
}
.selbar .total { font-size: 18px; font-weight: 700; }
.success-banner {
    background: rgba(52, 211, 153, .12); color: var(--green);
    border: 1px solid rgba(52, 211, 153, .4);
    padding: 12px 16px; border-radius: 8px; margin-bottom: 14px;
}

/* ---- master-detail invoices layout ---- */
.md-layout { display: flex; gap: 10px; align-items: flex-start; }
.md-clients {
    width: 250px; flex-shrink: 0; order: 1; /* order 1 = rightmost in RTL */
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    display: flex; flex-direction: column;
    height: calc(100vh - 64px); position: sticky; top: 14px; /* fixed height, doesn't grow with content */
}
.md-clients .head { padding: 10px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.md-clients .head input { width: 100%; }
.md-clients .list { overflow-y: auto; flex: 1; }
.md-client {
    padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line);
    font-size: 13.5px; display: flex; align-items: center; gap: 8px;
}
.md-client .idx { color: var(--muted); font-size: 12px; min-width: 22px; text-align: center; flex-shrink: 0; }
.md-client .nm { flex: 1; }
.md-client:hover { background: var(--panel-2); }
.md-client.active { background: rgba(56, 189, 248, .15); color: var(--accent); }
.md-main { flex: 1; min-width: 0; order: 2; display: flex; flex-direction: column; gap: 14px; }

/* bigger, nicer action icons */
.row-actions { display: flex; align-items: center; gap: 4px; }
.row-actions button, .row-actions a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
}
.row-actions svg { width: 18px; height: 18px; }
.row-actions .pay:hover { color: var(--green); background: rgba(52,211,153,.12); }
.row-actions .print:hover { color: var(--accent); }
.md-section h2 { margin: 0 0 8px; }
.md-scroll { max-height: 46vh; overflow-y: auto; }
.row-actions button, .row-actions a {
    background: none; border: none; cursor: pointer; color: var(--muted);
    padding: 2px 5px; font-size: 13px; border-radius: 6px;
}
.row-actions button:hover, .row-actions a:hover { background: var(--panel); color: var(--accent); }
tbody tr.selected { background: rgba(56, 189, 248, .12); }
.notes-input {
    width: 100%; min-width: 120px; background: transparent; border: 1px solid transparent;
    color: var(--text); padding: 4px 6px; border-radius: 6px; font-family: inherit; font-size: 13px;
}
.notes-input:hover, .notes-input:focus { border-color: var(--line); background: var(--panel-2); }

/* ---- modal ---- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
    background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
    width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.modal.wide { max-width: 640px; }
.modal .head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal .head h3 { margin: 0; font-size: 16px; }
.modal .head .close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.modal .body { padding: 18px; }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.modal .field input, .modal .field select { width: 100%; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 6px; }

h2 { font-size: 17px; margin: 26px 0 12px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.error-strip {
    background: rgba(248, 113, 113, .12); color: var(--red);
    border: 1px solid rgba(248, 113, 113, .4);
    padding: 10px 14px; border-radius: 8px; margin-bottom: 14px;
}

/* ---- login ---- */
.login-wrap {
    min-height: 80vh; display: flex;
    align-items: center; justify-content: center;
}
.login-card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 14px; padding: 36px; width: 100%; max-width: 380px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 6px; }

/* ---- detail grid ---- */
.grid2 {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px 24px; margin-bottom: 8px;
}
.kv { color: var(--muted); }

/* ---- about page ---- */
.about-head { display: flex; align-items: center; gap: 16px; }

/* ---- printable invoice (email-style Blue Sky template) ---- */
.print-shell { padding: 24px 12px; background: #eef2f7; min-height: 100vh; }
.inv {
    max-width: 860px; margin: 0 auto; background: #fff; color: #1f2937;
    border: 1px solid #dbe2ea; border-radius: 10px; overflow: hidden;
    font-family: "Segoe UI", Arial, Tahoma, sans-serif; font-size: 14px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, .10);
}
/* reset the dark-theme table styling inside the printable invoice */
.inv table { background: #fff; color: #1f2937; border-collapse: collapse; }
.inv td, .inv th { background: #fff; color: #1f2937; position: static; }
.inv tbody tr:hover { background: transparent; }

.inv-brand {
    display: grid; grid-template-columns: 220px minmax(0, 1fr) 170px;
    align-items: center; gap: 16px; padding: 20px 24px;
    background: #f8fafc; border-bottom: 1px solid #e5eaf0;
}
.inv-logo img { display: block; max-width: 190px; height: 46px; }
.inv-co-name { font-size: 22px; line-height: 1.15; font-weight: 800; color: #0f172a; }
.inv-co-tag { font-size: 12px; font-style: italic; color: #64748b; margin-top: 3px; }
.inv-doc { text-align: right; }
.inv-doc-title { font-size: 20px; line-height: 1.1; font-weight: 900; letter-spacing: .6px; color: #0f172a; }
.inv-doc-no { font-size: 12px; color: #64748b; margin-top: 4px; }
.inv-title {
    text-align: center; color: #365da5; font-size: 34px; line-height: 1.1;
    font-weight: 800; margin: 22px 24px 6px;
}

.inv-info {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px; margin: 0; padding: 14px 24px;
}
.inv-box { width: 100%; border: 1px solid #d6dde6; border-radius: 8px; overflow: hidden; }
.inv-box th, .inv-box td { border: 1px solid #e2e8f0; padding: 10px 12px; }
.inv-box th { background: #f8fafc; color: #475569; text-align: left; font-weight: 700; }
.inv-box .lbl { color: #64748b; width: 120px; }
.inv-box .val { color: #0f172a; font-weight: 700; text-align: right; }

.inv-items { width: calc(100% - 48px); margin: 2px 24px 14px; border: 1px solid #d6dde6; }
.inv-items th {
    background: #f8fafc; color: #475569; border: 1px solid #d6dde6;
    padding: 10px 12px; font-weight: 700;
}
.inv-items td { border: 1px solid #e2e8f0; padding: 12px; vertical-align: top; }
.inv-items .c-num { width: 48px; text-align: center; }
.inv-items .c-desc { line-height: 1.55; text-align: right; word-break: break-word; }
.inv-items .c-amt { width: 170px; text-align: right; font-weight: 700; }
.inv-items th.c-desc { text-align: left; }
.inv-items .empty-line { color: #64748b; text-align: center; }

.inv-foot {
    display: grid; grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px; padding: 0 24px 20px; align-items: start;
}
.inv-comments { border: 1px solid #d6dde6; border-radius: 8px; overflow: hidden; }
.inv-comments-h { background: #f8fafc; color: #475569; font-weight: 700; padding: 10px 12px; border-bottom: 1px solid #d6dde6; }
.inv-comments-b { min-height: 78px; padding: 12px; text-align: right; line-height: 1.6; color: #0f172a; }
.inv-totals { width: 100%; border: 1px solid #d6dde6; border-radius: 8px; overflow: hidden; }
.inv-totals td { padding: 10px 12px; border: 1px solid #e2e8f0; }
.inv-totals td.num { text-align: right; font-weight: 700; color: #0f172a; }
.inv-totals tr.grand td { font-size: 16px; font-weight: 900; color: #0f172a; }

.inv-contact {
    text-align: center; color: #334155; font-size: 12px; line-height: 1.8;
    padding: 16px 24px; border-top: 1px solid #e5eaf0; background: #f8fafc;
}
.inv-contact span { color: #64748b; font-weight: 700; }
.inv-actions { margin: 22px 0 26px; display: flex; gap: 14px; align-items: center; justify-content: center; }

@media (max-width: 760px) {
    .inv-brand, .inv-info, .inv-foot { grid-template-columns: 1fr; }
    .inv-doc { text-align: left; }
    .inv-items { width: calc(100% - 24px); margin-left: 12px; margin-right: 12px; }
}

@media print {
    @page { size: A4 portrait; margin: 0; }
    html, body {
        background: #fff !important;
        color: #111827 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .no-print { display: none !important; }
    .print-shell { padding: 8mm; background: #fff; min-height: auto; }
    .inv {
        width: 100%; max-width: none; border: 0; border-radius: 0; box-shadow: none;
        overflow: visible; font-size: 12px;
    }
    .inv-brand {
        grid-template-columns: 150px minmax(0, 1fr) 115px;
        gap: 10px; padding: 0 0 9px; background: #fff;
        break-inside: avoid; page-break-inside: avoid;
    }
    .inv-logo img { max-width: 138px; height: 34px; }
    .inv-co-name { font-size: 18px; }
    .inv-co-tag { font-size: 10.5px; }
    .inv-doc { text-align: right; }
    .inv-doc-title { font-size: 16px; }
    .inv-doc-no { font-size: 10.5px; }
    .inv-title { font-size: 26px; margin: 10px 0 8px; }
    .inv-info {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 12px; padding: 0 0 10px;
        break-inside: avoid; page-break-inside: avoid;
    }
    .inv-box th, .inv-box td { padding: 6px 8px; }
    .inv-box .lbl { width: 92px; }
    .inv-items { width: 100%; margin: 0 0 10px; }
    .inv-items th { padding: 6px 8px; }
    .inv-items td { padding: 7px 8px; }
    .inv-items .c-num { width: 36px; }
    .inv-items .c-desc { line-height: 1.35; }
    .inv-items .c-amt { width: 120px; }
    .inv-items thead { display: table-header-group; }
    .inv-items tr { break-inside: avoid; page-break-inside: avoid; }
    .inv-foot {
        grid-template-columns: minmax(0, 1fr) 240px;
        gap: 12px; padding: 0 0 10px;
        break-inside: avoid; page-break-inside: avoid;
    }
    .inv-comments-h { padding: 6px 8px; }
    .inv-comments-b { min-height: 48px; padding: 8px; line-height: 1.4; }
    .inv-totals td { padding: 6px 8px; }
    .inv-totals tr.grand td { font-size: 14px; }
    .inv-contact {
        padding: 8px 0 0; background: #fff; font-size: 10.5px; line-height: 1.45;
        break-inside: avoid; page-break-inside: avoid;
    }
}

/* ---- blazor error ui ---- */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; right: 0; left: 0;
    background: var(--amber); color: #1c1917; padding: 10px 20px; z-index: 999;
}
#blazor-error-ui .dismiss { float: left; cursor: pointer; }
