/* ==========================================================================
   TechWorksLab POC Lab — shared platform stylesheet
   Used by every POC application under /pocs/. App-shell layout with
   sidebar navigation, topbar context controls, and reusable components.
   ========================================================================== */

:root {
    --navy: #0a2540;
    --navy-2: #0f2f55;
    --ink: #16263a;
    --body: #46566b;
    --muted: #6b7a90;
    --accent: #15589f;
    --accent-dark: #0f4179;
    --accent-soft: #e8f0fa;
    --line: #e3e8ef;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 38, 64, 0.06);
    --shadow-md: 0 12px 30px rgba(16, 38, 64, 0.10);
    --green: #167a4b;
    --green-soft: #e2f5e9;
    --red: #b91c1c;
    --red-soft: #fbe4e4;
    --amber: #92400e;
    --amber-soft: #fbf0d8;
    --purple: #6d28d9;
    --purple-soft: #eee9fb;
    --teal: #155e75;
    --teal-soft: #d9f4f7;
    --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.55;
    color: var(--body);
    background: var(--bg);
}

h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }

/* App shell ---------------------------------------------------------------- */
.app {
    display: grid;
    grid-template-columns: 232px 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas: "side top" "side main";
    height: 100vh;
}

.app-side {
    grid-area: side;
    background: var(--navy);
    color: #c4d2e3;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.app-side .side-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(143, 166, 194, 0.2);
    color: #fff;
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: -0.01em;
}

.app-side .side-brand img { height: 26px; width: auto; display: block; }
.app-side .side-brand small { display: block; font-weight: 500; font-size: 0.7rem; color: #8fa6c2; letter-spacing: 0.04em; }

.side-section {
    padding: 0.9rem 1.1rem 0.35rem;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6f86a3;
}

.side-nav { list-style: none; }

.side-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1.1rem;
    color: #c4d2e3;
    font-size: 0.86rem;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.side-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side-nav a.active { background: rgba(21, 88, 159, 0.35); color: #fff; border-left-color: #7eb0e8; }
.side-nav a i { width: 18px; text-align: center; font-size: 0.85rem; color: #7eb0e8; }

.side-foot {
    margin-top: auto;
    padding: 1rem 1.1rem;
    border-top: 1px solid rgba(143, 166, 194, 0.2);
    font-size: 0.74rem;
    color: #6f86a3;
}
.side-foot a { color: #8fa6c2; display: block; margin-top: 0.3rem; }
.side-foot a:hover { color: #fff; }

.app-top {
    grid-area: top;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
}

.app-top .top-title { font-weight: 700; color: var(--ink); font-size: 0.95rem; white-space: nowrap; }
.app-top .top-spacer { flex: 1; }

.top-ctl {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.top-ctl select {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 0.32rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    max-width: 190px;
}

.synthetic-banner {
    background: var(--amber-soft);
    color: var(--amber);
    border-bottom: 1px solid #ecd9ac;
    font-size: 0.76rem;
    font-weight: 600;
    text-align: center;
    padding: 0.3rem 1rem;
}

.app-main {
    grid-area: main;
    overflow-y: auto;
    padding: 1.5rem;
}

.app-main .view { display: none; }
.app-main .view.active { display: block; }

.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.view-head h2 { font-size: 1.3rem; }
.view-head p { color: var(--muted); font-size: 0.88rem; margin-top: 0.25rem; max-width: 70ch; }
.view-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Buttons ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.82rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.2;
    background: transparent;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #10603a; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.74rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Panels & cards ----------------------------------------------------------- */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.panel-head h3 { font-size: 0.95rem; }
.panel-head .hint { font-size: 0.76rem; color: var(--muted); }
.panel-body { padding: 1.1rem; }
.panel-body.flush { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem; margin-bottom: 1.25rem; }
.kpi {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow-sm);
}
.kpi .kpi-val { font-size: 1.5rem; font-weight: 800; color: var(--ink); line-height: 1.1; letter-spacing: -0.02em; }
.kpi .kpi-label { font-size: 0.74rem; color: var(--muted); font-weight: 600; margin-top: 0.2rem; }
.kpi.accent .kpi-val { color: var(--accent); }
.kpi.warn .kpi-val { color: var(--amber); }
.kpi.bad .kpi-val { color: var(--red); }
.kpi.good .kpi-val { color: var(--green); }

/* Tables ------------------------------------------------------------------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.tbl th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 700;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--line);
    background: #fafbfd;
    white-space: nowrap;
}
.tbl td { padding: 0.55rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--body); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--accent-soft); }
.tbl tbody tr.selected { background: var(--accent-soft); }
.tbl td strong { color: var(--ink); }

/* Badges ------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.55rem;
    border-radius: 11px;
    white-space: nowrap;
}
.badge.b-blue { background: var(--accent-soft); color: var(--accent-dark); }
.badge.b-green { background: var(--green-soft); color: var(--green); }
.badge.b-red { background: var(--red-soft); color: var(--red); }
.badge.b-amber { background: var(--amber-soft); color: var(--amber); }
.badge.b-purple { background: var(--purple-soft); color: var(--purple); }
.badge.b-teal { background: var(--teal-soft); color: var(--teal); }
.badge.b-gray { background: #eef1f5; color: var(--muted); }

/* Confidence meter --------------------------------------------------------- */
.conf { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.74rem; font-weight: 600; }
.conf .conf-bar { width: 54px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.conf .conf-fill { height: 100%; border-radius: 3px; }
.conf.high .conf-fill { background: var(--green); }
.conf.med .conf-fill { background: #d97706; }
.conf.low .conf-fill { background: var(--red); }
.conf.high { color: var(--green); }
.conf.med { color: #b45309; }
.conf.low { color: var(--red); }

/* Forms -------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; }
.fld { display: flex; flex-direction: column; gap: 0.3rem; }
.fld label { font-size: 0.76rem; font-weight: 600; color: var(--ink); }
.fld input, .fld select, .fld textarea {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
}
.fld input:focus, .fld select:focus, .fld textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(21, 88, 159, 0.12);
}
.fld textarea { resize: vertical; min-height: 70px; }
.fld .fld-hint { font-size: 0.72rem; color: var(--muted); }

/* Tabs --------------------------------------------------------------------- */
.tabs { display: flex; gap: 0.15rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button {
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
}
.tabs button:hover { color: var(--accent); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Timeline ----------------------------------------------------------------- */
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 1rem; }
.tl-item::before {
    content: '';
    position: absolute;
    left: -1.4rem;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line);
}
.tl-item.tl-red::before { background: var(--red); }
.tl-item.tl-green::before { background: var(--green); }
.tl-item.tl-amber::before { background: #d97706; }
.tl-item.tl-gray::before { background: var(--muted); }
.tl-item .tl-date { font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tl-item .tl-title { font-weight: 600; color: var(--ink); font-size: 0.88rem; }
.tl-item .tl-body { font-size: 0.82rem; color: var(--body); }

/* Evidence / citation ------------------------------------------------------ */
.evidence {
    background: var(--accent-soft);
    border: 1px solid #cfe0f3;
    border-radius: 7px;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.evidence .ev-label { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-dark); margin-bottom: 0.25rem; }
.evidence mark { background: #ffe9a8; border-radius: 3px; padding: 0 0.15rem; }

.callout { border-radius: 8px; padding: 0.75rem 1rem; font-size: 0.84rem; margin-bottom: 1rem; border: 1px solid; }
.callout.c-info { background: var(--accent-soft); border-color: #cfe0f3; color: var(--accent-dark); }
.callout.c-warn { background: var(--amber-soft); border-color: #ecd9ac; color: var(--amber); }
.callout.c-bad { background: var(--red-soft); border-color: #f3c1c1; color: var(--red); }
.callout.c-good { background: var(--green-soft); border-color: #bfe6cd; color: var(--green); }

/* Code block --------------------------------------------------------------- */
.codeblock {
    background: #0d1b2c;
    color: #d7e3f4;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.6;
    border-radius: 8px;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    white-space: pre;
}
.codeblock .c-comment { color: #6f86a3; }
.codeblock .c-key { color: #7eb0e8; }
.codeblock .c-str { color: #8fd3a7; }

/* Modal -------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 37, 64, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
}
.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}
.modal.modal-lg { max-width: 900px; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 1rem; }
.modal-close { background: none; border: none; font-size: 1.1rem; color: var(--muted); cursor: pointer; padding: 0.2rem; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.9rem 1.25rem; border-top: 1px solid var(--line); }

/* Toast -------------------------------------------------------------------- */
.toast-host { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 3000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    background: var(--navy);
    color: #fff;
    font-size: 0.84rem;
    font-weight: 500;
    padding: 0.7rem 1.1rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: toast-in 0.25s ease;
    max-width: 380px;
}
.toast.t-good { background: var(--green); }
.toast.t-bad { background: var(--red); }
.toast.t-warn { background: #b45309; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Audit log ---------------------------------------------------------------- */
.audit-list { list-style: none; }
.audit-list li {
    display: flex;
    gap: 0.8rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.8rem;
    align-items: baseline;
}
.audit-list li:last-child { border-bottom: none; }
.audit-list .a-time { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.audit-list .a-user { font-weight: 700; color: var(--ink); white-space: nowrap; }
.audit-list .a-action { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* Split layouts ------------------------------------------------------------ */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: start; }
.cols-main-side { display: grid; grid-template-columns: 1fr 340px; gap: 1.25rem; align-items: start; }

/* Diff / compare ----------------------------------------------------------- */
.diff-same { }
.diff-changed { background: var(--amber-soft); }
.diff-missing { background: var(--red-soft); }
.diff-added { background: var(--green-soft); }

/* Empty state -------------------------------------------------------------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty i { font-size: 1.8rem; color: #b9c5d4; margin-bottom: 0.6rem; display: block; }

/* AI output block ---------------------------------------------------------- */
.ai-block {
    border: 1px solid #d9c8f2;
    background: #f8f5fe;
    border-radius: 10px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}
.ai-block .ai-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--purple);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.ai-block .ai-meta { font-family: var(--mono); font-size: 0.68rem; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive --------------------------------------------------------------- */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "side" "top" "main"; height: auto; min-height: 100vh; }
    .app-side { flex-direction: row; align-items: center; overflow-x: auto; }
    .app-side .side-brand { border-bottom: none; }
    .side-section, .side-foot { display: none; }
    .side-nav { display: flex; }
    .side-nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
    .side-nav a.active { border-left: none; border-bottom-color: #7eb0e8; }
    .cols-2, .cols-3, .cols-main-side { grid-template-columns: 1fr; }
    .app-main { padding: 1rem; }
}
