/* ============================================================
   BuildLedger — rich, layered, in motion.

   Depth comes from three things used together: a tinted gradient
   field behind everything, frosted panels that let it show
   through, and coloured light thrown by the element that matters
   most on each screen.
   ============================================================ */

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

:root {
    /* spectrum */
    --indigo:  #6366f1;
    --violet:  #8b5cf6;
    --fuchsia: #d946ef;
    --cyan:    #06b6d4;
    --emerald: #10b981;
    --amber:   #f59e0b;
    --rose:    #f43f5e;
    --sky:     #0ea5e9;

    /* money states */
    --hand:    #f59e0b;
    --owed:    #f43f5e;
    --settled: #10b981;

    /* cost categories */
    --matl: #0ea5e9;
    --labr: #f59e0b;
    --expn: #a855f7;

    /* gradients */
    --g-brand:   linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #d946ef 100%);
    --g-deep:    linear-gradient(150deg, #1e1b4b 0%, #312e81 45%, #4c1d95 100%);
    --g-hand:    linear-gradient(135deg, #f59e0b, #fbbf24);
    --g-owed:    linear-gradient(135deg, #f43f5e, #fb7185);
    --g-settled: linear-gradient(135deg, #10b981, #34d399);
    --g-sky:     linear-gradient(135deg, #0ea5e9, #06b6d4);

    /* ink */
    --ink:    #14142b;
    --ink-2:  #3f3f5e;
    --muted:  #6e6e91;
    --faint:  #9c9cb8;
    --line:   #e9e9f4;
    --line-2: #f3f3f9;
    --card:   #ffffff;
    --field:  #f6f6fb;

    --r:    12px;
    --r-lg: 18px;
    --r-xl: 24px;

    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --sh-1: 0 1px 2px rgba(20,20,43,.04);
    --sh-2: 0 2px 4px rgba(20,20,43,.04), 0 6px 16px -4px rgba(20,20,43,.08);
    --sh-3: 0 4px 8px rgba(20,20,43,.05), 0 16px 32px -8px rgba(20,20,43,.12);
    --sh-4: 0 24px 64px -12px rgba(20,20,43,.24);
    --glow-i: 0 6px 22px -6px rgba(99,102,241,.55);
    --glow-r: 0 6px 22px -6px rgba(244,63,94,.5);
    --glow-a: 0 6px 22px -6px rgba(245,158,11,.5);
    --glow-e: 0 6px 22px -6px rgba(16,185,129,.5);

    --ease:   cubic-bezier(.22,1,.36,1);
    --ease-2: cubic-bezier(.4,0,.2,1);
    --rail:   250px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    background: #f5f5fb;
}

/* the tinted field everything else floats on */
body::before {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(760px 520px at 12% -8%,  rgba(99,102,241,.16), transparent 62%),
        radial-gradient(680px 460px at 92% 2%,   rgba(217,70,239,.13), transparent 60%),
        radial-gradient(900px 620px at 68% 102%, rgba(6,182,212,.12),  transparent 62%),
        #f5f5fb;
}

a { color: var(--indigo); }

.fig, .num, td.num, th.num, input[type=number] { font-variant-numeric: tabular-nums; }
::selection { background: rgba(99,102,241,.22); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 4px; }

/* ---------- entrance: staggered, on load ---------- */
@keyframes riseIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}
.rise { opacity: 0; animation: riseIn .5s var(--ease) forwards; }
.rise:nth-child(1) { animation-delay: .02s }
.rise:nth-child(2) { animation-delay: .07s }
.rise:nth-child(3) { animation-delay: .12s }
.rise:nth-child(4) { animation-delay: .17s }
.rise:nth-child(5) { animation-delay: .22s }
.rise:nth-child(6) { animation-delay: .27s }
.rise:nth-child(7) { animation-delay: .32s }
.rise:nth-child(8) { animation-delay: .37s }

@keyframes floatSlow {
    0%,100% { transform: translate(0,0) scale(1); }
    50%     { transform: translate(14px,-12px) scale(1.06); }
}
@keyframes shimmer { to { background-position: 200% 0; } }

/* ---------- buttons ---------- */
.btn {
    position: relative; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 38px; padding: 0 17px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink-2);
    font: 600 13.5px/1 var(--font);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    box-shadow: var(--sh-1);
    transition: transform .18s var(--ease), box-shadow .18s var(--ease),
                background .16s var(--ease-2), border-color .16s var(--ease-2);
}
.btn:hover  { transform: translateY(-1.5px); box-shadow: var(--sh-2); border-color: #dcdcec; }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--g-brand); border-color: transparent; color: #fff;
    background-size: 160% 160%; box-shadow: var(--glow-i);
    transition: transform .18s var(--ease), box-shadow .18s var(--ease),
                background-position .5s var(--ease-2);
}
.btn-primary:hover { background-position: 100% 50%; box-shadow: 0 10px 30px -8px rgba(99,102,241,.65); }
.btn-brass, .btn-dark { background: var(--g-brand); border-color: transparent; color: #fff; box-shadow: var(--glow-i); }
.btn-danger { color: var(--rose); border-color: #fbd5db; background: #fff5f7; }
.btn-danger:hover { background: #ffe9ee; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ripple, on click */
.btn .rip {
    position: absolute; border-radius: 50%; transform: scale(0);
    background: rgba(255,255,255,.5); pointer-events: none;
    animation: rip .55s var(--ease-2) forwards;
}
.btn:not(.btn-primary):not(.btn-brass) .rip { background: rgba(99,102,241,.22); }
@keyframes rip { to { transform: scale(2.6); opacity: 0; } }

/* ---------- inputs ---------- */
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=search], select, textarea {
    width: 100%; height: 42px; padding: 0 14px;
    border: 1.5px solid transparent; border-radius: 10px;
    background: var(--field);
    font: 500 13.5px var(--font); color: var(--ink);
    transition: background .16s var(--ease-2), border-color .16s var(--ease-2),
                box-shadow .16s var(--ease-2);
}
textarea { height: auto; padding: 11px 14px; }
input:focus, select:focus, textarea:focus {
    outline: none; background: #fff; border-color: var(--indigo);
    box-shadow: 0 0 0 4px rgba(99,102,241,.13);
}
input[readonly] { color: var(--muted); }
select {
    cursor: pointer; appearance: none; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7'%3E%3Cpath fill='%236e6e91' d='M0 0l5.5 7L11 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; }
.opt { font-weight: 500; color: var(--faint); }

/* ---------- panels ---------- */
.panel {
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid rgba(255,255,255,.75);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-2);
    margin-bottom: 18px; overflow: hidden;
}
.panel > header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 17px 20px;
    border-bottom: 1px solid var(--line-2);
}
.panel h2 { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -.015em; }
.panel-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.panel-link { font-size: 12.5px; font-weight: 600; text-decoration: none; }
.panel-link:hover { text-decoration: underline; }
.panel-body { padding: 20px; }
.panel-wide { grid-column: 1 / -1; }

/* .sect falls back to a panel look */
.sect { margin-bottom: 18px; }
.sect-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.sect-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.sect-head .note { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-left: 9px; }
.sect-head a { font-size: 12.5px; font-weight: 600; text-decoration: none; }

/* ---------- tables ---------- */
.dtable { width: 100%; border-collapse: collapse; }
.dtable th {
    font-size: 11.5px; font-weight: 700; color: var(--faint); text-align: left;
    padding: 12px 14px; border-bottom: 1px solid var(--line-2);
    white-space: nowrap; letter-spacing: .02em;
}
.dtable td { padding: 13px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr { transition: background .16s var(--ease-2); }
.dtable tbody tr:hover { background: rgba(99,102,241,.045); }
.dtable th.num, .dtable td.num { text-align: right; white-space: nowrap; }
.dtable tfoot td {
    padding: 14px; border-top: 1px solid var(--line); border-bottom: none;
    font-weight: 700; background: rgba(99,102,241,.035);
}
.dtable th:first-child, .dtable td:first-child { padding-left: 20px; }
.dtable th:last-child,  .dtable td:last-child  { padding-right: 20px; }

.dtable tr.sub td { background: rgba(99,102,241,.03); color: var(--muted); font-size: 12.5px;
    padding-top: 9px; padding-bottom: 9px; }
.dtable tr.sub td:first-child { padding-left: 42px; position: relative; }
.dtable tr.sub td:first-child::before {
    content: ''; position: absolute; left: 24px; top: 50%;
    width: 10px; height: 1.5px; border-radius: 1px; background: var(--faint); opacity: .6;
}

.cell-name { display: block; font-weight: 600; color: var(--ink); }
.cell-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.cell-dim  { color: var(--muted); }
.num-ok    { color: var(--settled); font-weight: 700; }
.num-due   { color: var(--owed);    font-weight: 700; }

/* ---------- badges ---------- */
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 7px;
    font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge-ok      { background: rgba(16,185,129,.12); color: #059669; }
.badge-warn    { background: rgba(245,158,11,.14); color: #b45309; }
.badge-danger  { background: rgba(244,63,94,.12);  color: #e11d48; }
.badge-info    { background: rgba(14,165,233,.12); color: #0284c7; }
.badge-primary { background: rgba(99,102,241,.12); color: #4f46e5; }
.badge-muted   { background: var(--line-2);        color: var(--muted); }
.badge-active{background:rgba(16,185,129,.12);color:#059669}
.badge-suspended,.badge-rejected{background:rgba(244,63,94,.12);color:#e11d48}
.badge-pending{background:rgba(245,158,11,.14);color:#b45309}
.badge-approved{background:rgba(16,185,129,.12);color:#059669}
.badge-closed{background:var(--line-2);color:var(--muted)}

/* ---------- bars ---------- */
.bar { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; display: block; }
.bar > span {
    display: block; height: 100%; border-radius: 99px; background: var(--g-brand);
    width: 0; transition: width 1.1s var(--ease);
}
.bar-lg { height: 10px; }
.bar-row {
    display: grid; grid-template-columns: minmax(104px,1.1fr) 2fr minmax(92px,auto);
    align-items: center; gap: 15px; padding: 8px 0;
}
.bar-row .bar-label { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-value { font-size: 13.5px; font-weight: 700; text-align: right; white-space: nowrap;
    font-variant-numeric: tabular-nums; }

/* ---------- alerts ---------- */
.alert { padding: 14px 17px; border-radius: var(--r); font-size: 13.5px; font-weight: 500;
    margin-bottom: 18px; border: 1px solid transparent; }
.alert-ok    { background: rgba(16,185,129,.1);  color: #047857; border-color: rgba(16,185,129,.2); }
.alert-error { background: rgba(244,63,94,.09);  color: #be123c; border-color: rgba(244,63,94,.2); }
.alert-info  { background: rgba(99,102,241,.09); color: #4338ca; border-color: rgba(99,102,241,.2); }
.alert-warn  { background: rgba(245,158,11,.11); color: #b45309; border-color: rgba(245,158,11,.22); }
.alert ul { margin: 7px 0 0 17px; padding: 0; }
.alert strong { display: block; margin-bottom: 3px; font-weight: 700; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab {
    height: 36px; padding: 0 16px; display: inline-flex; align-items: center;
    border-radius: 10px; font-size: 13.5px; font-weight: 600;
    text-decoration: none; color: var(--muted);
    background: rgba(255,255,255,.7); border: 1px solid var(--line);
    transition: all .18s var(--ease);
}
.tab:hover { color: var(--ink); transform: translateY(-1px); }
.tab.active, .tab.on { background: var(--g-brand); color: #fff; border-color: transparent; box-shadow: var(--glow-i); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr));
    gap: 16px 18px; padding: 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.form-grid label > input, .form-grid label > select { margin-top: 7px; }
.form-grid label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.form-grid label.check input { width: auto; height: auto; margin: 0; accent-color: var(--indigo); }
.form-actions { grid-column: 1/-1; display: flex; gap: 10px; padding-top: 16px;
    border-top: 1px solid var(--line-2); margin-top: 4px; }

.filterbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px,1fr));
    gap: 14px; align-items: end; padding: 18px 20px; }
.filterbar label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.filterbar label > input, .filterbar label > select { margin-top: 7px; }
.filterbar .fb-actions { display: flex; gap: 9px; }

/* ---------- modal ---------- */
.modal-back {
    display: none; position: fixed; inset: 0; z-index: 300;
    background: rgba(20,20,43,.42);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    align-items: flex-start; justify-content: center;
    padding: 6vh 16px 24px; overflow-y: auto; -webkit-overflow-scrolling: touch;
    animation: fadeIn .2s var(--ease-2);
}
@keyframes fadeIn { from { opacity: 0 } }
.modal-back.open { display: flex; }
.modal-card {
    background: #fff; border-radius: var(--r-xl); width: 100%; max-width: 540px; margin: auto;
    box-shadow: var(--sh-4); animation: popIn .34s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(24px) scale(.96); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between;
    gap: 14px; padding: 22px 22px 17px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.modal-head .sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.modal-x { background: var(--field); border: none; cursor: pointer; width: 32px; height: 32px;
    border-radius: 9px; font-size: 19px; line-height: 1; color: var(--muted); padding: 0;
    transition: all .16s var(--ease-2); }
.modal-x:hover { background: rgba(244,63,94,.1); color: var(--rose); }

/* ---------- misc ---------- */
.empty { padding: 52px 20px; text-align: center; color: var(--muted); font-size: 13.5px; margin: 0; }
.empty strong { display: block; color: var(--ink); font-size: 16.5px; margin-bottom: 6px; font-weight: 700; }
.muted { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; }
    .rise { opacity: 1; }
}

@media (max-width: 640px) {
    .dtable th, .dtable td { padding: 11px 10px; }
    .dtable th:first-child, .dtable td:first-child { padding-left: 16px; }
    .dtable th:last-child,  .dtable td:last-child  { padding-right: 16px; }
    .dtable tr.sub td:first-child { padding-left: 30px; }
    .dtable tr.sub td:first-child::before { left: 16px; }
    .form-grid, .filterbar { grid-template-columns: 1fr; padding: 16px; }
    .modal-back { padding: 0; }
    .modal-card { max-width: none; border-radius: 0; min-height: 100vh; }
}

/* ---------- print ---------- */
.print-only { display: none; }
@media print {
    .no-print, .rail, .topbar, .position, .page-actions, .btn, .modal-back, .hero { display: none !important; }
    .print-only { display: block !important; }
    body { background: #fff; font-size: 10.5pt; }
    body::before { display: none; }
    .shell, .canvas, .page { margin: 0; padding: 0; max-width: none; display: block; }
    .panel { border: 1px solid #ccc; border-radius: 0; box-shadow: none; backdrop-filter: none;
        background: #fff; break-inside: avoid; }
    .dtable th, .dtable td { padding: 5px 8px; font-size: 9pt; }
    thead { display: table-header-group; }
    tr { break-inside: avoid; }
    .rise { opacity: 1; animation: none; }
    a { text-decoration: none; color: inherit; }
}
