/* ============================================================================
   LILA FENCE — "Craftsman Editorial" identity.
   Loaded only for the fence pack, so it re-skins the shared UI kit into a
   warm, hand-crafted, premium-woodworking product without touching others.
   Language: bone/cream field, warm white panels, RICH DARK-PINE panel headers
   (the signature move), cedar accent, Fraunces serif display + Inter body,
   soft warm-tinted shadows, medium refined radii. Editorial, not industrial.

   Fonts (Fraunces + Inter) are loaded via the pack's font_import <link> in the
   shell — Fraunces drives --display-font below; body stays Inter. Keep both.
   ============================================================================ */
:root {
    --accent: #b0884f;            /* cedar */
    --accent-2: #c79a5c;          /* light cedar / brass */
    --accent-deep: #8f6b39;       /* burnt cedar (hover) */
    --accent-soft: #f0e7d8;       /* pale cedar wash */
    --pine: #243d31;              /* pine green (signature dark surface) */
    --pine-deep: #1b2e25;         /* deep pine */
    --bg: #f4f0e7;                /* warm bone field */
    --panel: #fffdf8;             /* warm white panel */
    --panel-cream: #faf6ec;       /* cream sub-surface */
    --ink: #23211d;              /* warm ink */
    --ink-soft: #6b6557;          /* soft warm ink */
    --line: #e3d9c6;              /* warm hairline */
    --line-soft: #ece4d4;
    --side: #243d31;              /* pine sidebar */
    --side-ink: #b6c5ba;
    --side-ink-bright: #f6f1e6;
    --display-font: "Fraunces", Georgia, "Times New Roman", serif;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(36,61,49,.05), 0 16px 34px -24px rgba(36,61,49,.42);
}

body {
    font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
    background-color: var(--bg);
    /* extremely faint warm vignette — tasteful texture, no loud pattern */
    background-image:
        radial-gradient(1200px 620px at 78% -8%, rgba(176,136,79,.06), transparent 60%),
        radial-gradient(900px 540px at -6% 108%, rgba(36,61,49,.05), transparent 55%);
    background-attachment: fixed;
}

/* ---------------- Sidebar: refined pine rail ---------------- */
.side {
    background: linear-gradient(185deg, #294435, var(--pine-deep) 86%);
    border-right: 1px solid rgba(0,0,0,.28);
    box-shadow: inset -1px 0 0 rgba(246,241,230,.04);
}
.brand { border-bottom: 1px solid rgba(246,241,230,.12); margin: -2px -6px 14px; padding: 6px 14px 17px; }
.brand-mark {
    background: linear-gradient(165deg, var(--accent-2), var(--accent));
    color: #2b211a; border-radius: 8px;
    font-family: var(--display-font); font-weight: 700; letter-spacing: 0;
    box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 3px 10px -3px rgba(0,0,0,.5);
}
.brand-name { font-family: var(--display-font); font-weight: 600; letter-spacing: -.2px; font-size: 16px; }
.brand-pack { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); opacity: .92; }
.nav-link {
    border-radius: 7px; font-size: 13px; font-weight: 500;
    color: var(--side-ink); border-left: 2px solid transparent; padding-left: 11px;
    transition: background .14s, color .14s, border-color .14s;
}
.nav-link:hover { background: rgba(246,241,230,.07); color: var(--side-ink-bright); }
.nav-link.active {
    background: linear-gradient(90deg, rgba(176,136,79,.26), rgba(176,136,79,.05));
    color: #fff; border-left-color: var(--accent); font-weight: 600;
}
.nav-link.active .nav-ico { color: var(--accent-2); opacity: 1; }
.nav-ico { opacity: .82; }
.side-foot { font-size: 10.5px; letter-spacing: .06em; color: var(--side-ink); opacity: .6; }

/* ---------------- Topbar ---------------- */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); }
.client-id strong { font-family: var(--display-font); font-weight: 600; letter-spacing: -.2px; color: var(--pine); }
.client-id .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(176,136,79,.18); }
.switcher select { border-radius: 7px; border-color: var(--line); background: var(--panel); }
.switcher select:focus { outline-color: var(--accent); }

/* ---------------- Page header: editorial masthead ---------------- */
.page-head { position: relative; margin-bottom: 24px; padding-left: 16px; }
.page-head::before {
    content: ""; position: absolute; left: 0; top: 4px; bottom: 6px; width: 3px;
    background: linear-gradient(var(--accent), var(--accent-deep)); border-radius: 3px;
}
.page-head h1 {
    font-family: var(--display-font); font-weight: 600; font-size: 28px;
    letter-spacing: -.4px; color: var(--pine); line-height: 1.12;
    /* sentence case — do NOT uppercase */
}
.page-head h1 .badge { vertical-align: middle; margin-left: 6px; }
.page-head .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 5px; }
.page-head .back { color: var(--ink-soft); font-size: 12.5px; font-weight: 500; }
.page-head .back:hover { color: var(--accent-deep); }
/* refined cedar underline rule under the masthead block */
.page-head::after {
    content: ""; position: absolute; left: 16px; right: 0; bottom: -10px; height: 1px;
    background: linear-gradient(90deg, rgba(176,136,79,.55), rgba(227,217,198,.15) 55%, transparent);
}

/* ---------------- KPI cards: editorial stat plates ---------------- */
.kpis { gap: 14px; }
.kpi-card {
    position: relative; border: 1px solid var(--line); border-radius: var(--radius);
    background: linear-gradient(180deg, var(--panel), var(--panel-cream));
    box-shadow: var(--shadow); padding: 17px 19px 16px; overflow: hidden;
}
.kpi-card::before {                              /* thin cedar top hairline */
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.kpi-ic { color: var(--accent); background: var(--accent-soft); border-radius: 7px; padding: 5px; top: 14px; right: 14px; opacity: 1; }
.kpi-ic svg { width: 18px; height: 18px; }
.kpi-lab { text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; font-weight: 600; color: var(--ink-soft); }
.kpi-num { font-family: var(--display-font); font-weight: 600; font-size: 34px; letter-spacing: -.6px; color: var(--pine); line-height: 1.06; margin-top: 5px; }
.kpi-delta { font-size: 11.5px; margin-top: 6px; color: var(--ink-soft); }
.kpi-delta.up { color: #3f6f53; }
.kpi-delta.down { color: #9d4b3e; }

/* ---------------- Panels: SIGNATURE pine-header letterhead ---------------- */
.rpanel { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--panel); }
.panel-h {
    background: linear-gradient(180deg, var(--pine), var(--pine-deep));
    border-bottom: 1px solid rgba(0,0,0,.25); padding: 13px 18px;
}
.panel-h h3 {
    font-family: var(--display-font); font-weight: 600; font-size: 15px;
    letter-spacing: -.1px; color: var(--side-ink-bright);
    display: flex; align-items: baseline; gap: 9px;
}
.panel-h h3::before {                            /* small cedar editorial tick */
    content: ""; width: 7px; height: 7px; background: var(--accent-2);
    border-radius: 2px; flex: none; align-self: center;
    box-shadow: 0 0 0 3px rgba(199,154,92,.16);
}
.panel-sub { font-weight: 400; color: rgba(246,241,230,.66); font-size: 12px; letter-spacing: 0; }
.panel-act a { color: var(--accent-2); text-decoration: none; font-size: 12.5px; font-weight: 600; }
.panel-act a:hover { color: #e6cf9f; }
.panel-b { background: var(--panel); }

/* List rows inside panels — warm dividers + cream hover */
.list-row { border-bottom: 1px solid var(--line-soft); }
a.list-row:hover { background: var(--panel-cream); }
.list-row .grow b { font-weight: 600; }
.feed-row { border-bottom: 1px solid var(--line-soft); }

/* ---------------- Tables: pine-headed registers ---------------- */
table.data.card { border-radius: var(--radius); border-color: var(--line); }
table.data thead th {
    background: linear-gradient(180deg, var(--pine), var(--pine-deep));
    color: #d9e2da; border-bottom: none;
    text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 600;
    padding: 12px 14px;
}
table.data thead th:first-child { border-top-left-radius: var(--radius); }
table.data thead th:last-child  { border-top-right-radius: var(--radius); }
table.data td { border-bottom: 1px solid var(--line-soft); font-size: 13px; color: var(--ink); }
table.data tbody tr:nth-child(even) td { background: rgba(176,136,79,.035); }
table.data tbody tr.clickable:hover td { background: var(--accent-soft); }
table.data td .num, table.data .num { font-variant-numeric: tabular-nums; }

/* ---------------- Badges: warm rounded tints ---------------- */
.badge {
    border-radius: 5px; font-size: 11px; font-weight: 600; letter-spacing: .01em;
    padding: 3px 9px; border: 1px solid transparent; line-height: 1.5;
}
/* good — warm green */
.badge-won, .badge-complete, .badge-accepted, .badge-paid, .badge-active,
.badge-confirmed, .badge-deposit-paid { background: #e4f0e7; color: #2f6a47; border-color: #cbe2d2; }
/* in-progress / motion — cedar */
.badge-in-progress, .badge-pending-deposit, .badge-scheduled, .badge-repeat { background: #f4e7d2; color: #976a26; border-color: #e8d3ac; }
/* informational / fresh — slate blue */
.badge-new, .badge-sent, .badge-quoted, .badge-draft { background: #e6edf2; color: #41617a; border-color: #d3dee6; }
/* bad — clay red */
.badge-lost, .badge-declined, .badge-overdue, .badge-cancelled,
.badge-expired, .badge-inactive { background: #f3e2dd; color: #9d4b3e; border-color: #e7cabf; }
/* awaiting / outstanding — amber-tan */
.badge-pending, .badge-outstanding { background: #f7eed8; color: #8a6a22; border-color: #ecddb4; }
/* neutral classifier — tan */
.badge-commercial { background: #ece4d4; color: #6b5b3c; border-color: #ddd0b6; }

/* ---------------- Atoms ---------------- */
.pill {
    border-radius: 6px; background: var(--accent-soft); border: 1px solid var(--line);
    color: var(--accent-deep); font-size: 11px; font-weight: 600; padding: 2px 9px;
}
.rprogress { height: 7px; background: #e7ddca; border: 1px solid var(--line); border-radius: 999px; }
.rprogress i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }
.datebox { background: linear-gradient(180deg, var(--pine), var(--pine-deep)); color: #f3eee2; border-radius: 7px; }
.datebox b { font-family: var(--display-font); font-weight: 600; }
.datebox span { color: var(--accent-2); }
.avatar { border-radius: 9px; background: linear-gradient(165deg, var(--accent-2), var(--accent)); color: #2b211a; font-family: var(--display-font); font-weight: 600; }
.feed-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(176,136,79,.16); }

/* ---------------- Buttons ---------------- */
.btn { border-radius: 7px; font-weight: 600; border-color: var(--line); background: var(--panel); color: var(--ink); }
.btn:hover { background: var(--panel-cream); }
.btn-primary {
    background: linear-gradient(165deg, var(--accent-2), var(--accent));
    border-color: var(--accent-deep); color: #2b211a;
    box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 16px -8px rgba(143,107,57,.6);
}
.btn-primary:hover { filter: none; background: linear-gradient(165deg, var(--accent), var(--accent-deep)); color: #fff7ec; }
.btn-danger { color: #9d4b3e; border-color: #e7cabf; background: var(--panel); }
.btn-danger:hover { background: #f3e2dd; }

/* ---------------- Generic detail (customers / materials / etc.) ---------------- */
.detail.card { border-radius: var(--radius); border-color: var(--line); }
.detail-row { border-bottom: 1px solid var(--line-soft); }
.detail-key {
    background: var(--panel-cream); color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: .04em; font-size: 11px; font-weight: 600;
}

/* ---------------- Empty / misc warmth ---------------- */
.empty, .rempty { color: var(--ink-soft); }
.empty { border-color: var(--line); background: var(--panel); }

/* KPI value safety: keep money legible on the big Fraunces numerals */
.kpi-num { word-break: keep-all; }
