/* =========================================================
   PAKISTAN FINANCIAL INTELLIGENCE
   Burgundy & cream: soft, feminine, and quietly sophisticated
   ========================================================= */

:root {
    /* Wine */
    --wine-900: #3a0f1a;
    --wine-800: #4f1424;
    --wine-700: #6b1d30;
    --wine-600: #82263c;
    --wine-500: #9c3550;
    /* Blush and rose */
    --rose-300: #e7b9bf;
    --rose-200: #f2d6d8;
    --rose-100: #f9e9e8;
    --rose-50:  #fdf4f2;
    /* Cream */
    --cream-200: #efe3d3;
    --cream-100: #f7efe4;
    --cream-50:  #fbf7f1;
    --ivory:     #fffdf9;
    /* Accents */
    --gold:      #b8896a;   /* rose gold hairlines and ornaments */
    --gold-soft: #e6d2c0;
    --sage:      #5f7f6c;   /* "down" movements */
    --berry:     #a8324e;   /* "up" movements */

    --text:  #3b2328;
    --muted: #8f7478;
    --line:  #ecdcd4;

    --serif: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;
    --sans:  "Jost", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;

    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 11px;
    --shadow-soft: 0 1px 2px rgba(79, 20, 36, .04), 0 10px 28px -12px rgba(79, 20, 36, .14);
    --shadow-lift: 0 2px 4px rgba(79, 20, 36, .05), 0 18px 40px -16px rgba(79, 20, 36, .26);
}

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

body {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text);
    background:
        radial-gradient(1200px 500px at 85% -10%, rgba(242, 214, 216, .55), transparent 60%),
        radial-gradient(900px 400px at 10% 110%, rgba(239, 227, 211, .7), transparent 60%),
        var(--cream-50);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--wine-600); }
a:hover { color: var(--wine-800); }
::selection { background: var(--rose-200); color: var(--wine-900); }

.app-shell { display: flex; min-height: 100vh; }

/* ---------------------------------------------------------- Sidebar */

.sidebar {
    width: 262px;
    min-height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 30px 20px 24px;
    color: var(--cream-100);
    background:
        radial-gradient(420px 260px at 0% 0%, rgba(231, 185, 191, .18), transparent 70%),
        linear-gradient(180deg, var(--wine-800) 0%, var(--wine-900) 100%);
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 42px; }
.brand-logo {
    width: 46px; height: 46px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 700;
    font-size: 19px;
    letter-spacing: .5px;
    color: var(--wine-800);
    background: radial-gradient(circle at 35% 30%, var(--ivory), var(--rose-200));
    box-shadow: 0 0 0 3px rgba(255, 253, 249, .12), 0 0 0 4px rgba(184, 137, 106, .55);
}
.brand h2 { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .3px; color: var(--ivory); }
.brand p { font-size: 10.5px; color: var(--rose-300); margin-top: 2px; letter-spacing: 1.4px; text-transform: uppercase; }

.nav-heading {
    color: var(--rose-300);
    opacity: .75;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 2.2px;
    margin: 0 0 12px 12px;
}
.nav-heading::before { content: "✦ "; color: var(--gold); opacity: .9; }
.nav-gap { margin-top: 28px; }

nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
    color: #ead6d3;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 13px;
    letter-spacing: .2px;
    transition: background .2s ease, color .2s ease, padding .2s ease;
}
.nav-link:hover { background: rgba(249, 233, 232, .09); color: var(--ivory); padding-left: 18px; }
.nav-link.active {
    background: linear-gradient(90deg, rgba(249, 233, 232, .2), rgba(249, 233, 232, .06));
    color: var(--ivory);
    box-shadow: inset 0 0 0 1px rgba(231, 185, 191, .25);
}
.nav-link.active::before { content: "♡ "; color: var(--rose-300); }

.sidebar-footer {
    margin-top: auto;
    padding-top: 22px;
    border-top: 1px solid rgba(231, 185, 191, .18);
    font-size: 11px;
    color: var(--rose-300);
    display: flex; align-items: center; gap: 9px;
    letter-spacing: .3px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rose-300); box-shadow: 0 0 0 3px rgba(231, 185, 191, .2); animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 6px rgba(231, 185, 191, .06); } }

/* ---------------------------------------------------------- Main */

.main-content { flex: 1; min-width: 0; padding: 38px 44px 20px; }

.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 30px; }
.eyebrow {
    color: var(--gold);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2.4px;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.eyebrow::before { content: "✦"; margin-right: 7px; color: var(--rose-300); }
.topbar h1, .detail-heading h1 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 42px;
    line-height: 1.05;
    color: var(--wine-800);
    letter-spacing: -.3px;
    margin-bottom: 8px;
}
.topbar h1::after, .detail-heading h1::after {
    content: "";
    display: block;
    width: 64px; height: 2px;
    margin-top: 12px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--gold), transparent);
}
.subtitle { color: var(--muted); font-size: 14px; line-height: 1.55; }

.system-status { text-align: right; font-size: 12px; color: var(--muted); }
.system-status span {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--ivory);
    color: var(--wine-700);
    border: 1px solid var(--rose-200);
    border-radius: 999px;
    padding: 8px 15px;
    font-weight: 500;
    margin-bottom: 7px;
    box-shadow: var(--shadow-soft);
}
.system-status span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--wine-500); }
.system-status p { font-size: 11px; }

/* ---------------------------------------------------------- Indicator tiles */

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; margin-bottom: 26px; }

.metric-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--ivory) 0%, var(--cream-50) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px 22px 18px;
    min-height: 170px;
    box-shadow: var(--shadow-soft);
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.metric-card::before {           /* blush corner bloom */
    content: "";
    position: absolute;
    top: -46px; right: -46px;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(242, 214, 216, .85), transparent 70%);
    pointer-events: none;
}
.metric-card::after {            /* rose-gold top hairline */
    content: "";
    position: absolute; left: 22px; right: 22px; top: 0;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
}
.metric-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: var(--rose-300); }
.metric-card p { position: relative; font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: .6px; text-transform: uppercase; }
.metric-card h2 {
    position: relative;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 38px;
    line-height: 1;
    color: var(--wine-800);
    margin: 14px 0 6px;
    font-variant-numeric: lining-nums tabular-nums;
}
.metric-card span { font-size: 11px; color: var(--muted); }
.metric-card .spark { display: block; width: 100%; height: 38px; margin: 10px 0 8px; }
.metric-change { display: block; font-size: 11.5px; font-weight: 500; min-height: 16px; }

.up   { color: var(--berry) !important; }
.down { color: var(--sage) !important; }

/* ---------------------------------------------------------- Panels */

.content-panel {
    background: var(--ivory);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 28px 30px;
    min-height: 0;
    box-shadow: var(--shadow-soft);
}
.content-panel>p { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 4px; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }

.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { font-family: var(--serif); font-weight: 600; font-size: 26px; color: var(--wine-800); line-height: 1.15; }
.section-heading .eyebrow { margin-bottom: 4px; }

.panel-tag {
    font-size: 10.5px;
    letter-spacing: .4px;
    background: var(--rose-50);
    color: var(--wine-600);
    border: 1px solid var(--rose-200);
    border-radius: 999px;
    padding: 6px 13px;
    white-space: nowrap;
}

/* Market brief */
.brief { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.55; color: var(--text); }
.brief li { position: relative; padding: 9px 0 9px 22px; border-bottom: 1px dashed var(--line); }
.brief li::before { content: "❀"; position: absolute; left: 0; top: 9px; color: var(--rose-300); font-size: 12px; }
.brief li:last-child { border-bottom: 0; }
.brief b { font-weight: 600; color: var(--wine-700); }
.brief.large { font-size: 14.5px; }
.brief.large li { padding: 12px 0 12px 24px; }
.brief.large li::before { top: 13px; }

/* Source status */
.source-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.source-list li { display: grid; grid-template-columns: 82px 1fr; align-items: center; column-gap: 12px; row-gap: 1px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.source-list li:last-child { border-bottom: 0; }
.source-list li .run-status { grid-row: span 2; text-align: center; }
.source-list b { font-weight: 500; color: var(--wine-800); }
.source-list small { color: var(--muted); font-size: 11px; }

.run-status { font-size: 9.5px; font-weight: 600; letter-spacing: .8px; border-radius: 999px; padding: 4px 9px; }
.run-status.ok    { color: var(--sage); background: #eef3ee; border: 1px solid #d7e3d9; }
.run-status.error { color: var(--berry); background: var(--rose-50); border: 1px solid var(--rose-200); }

/* ---------------------------------------------------------- Buttons and links */

.ghost-button, .action-link {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--rose-200);
    background: var(--ivory);
    color: var(--wine-700);
    border-radius: 999px;
    padding: 9px 16px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
}
.ghost-button:hover, .action-link:hover { background: var(--rose-50); border-color: var(--rose-300); color: var(--wine-800); box-shadow: 0 6px 16px -10px rgba(107, 29, 48, .5); }

.primary-button, .import-form button, .lower-heading button {
    border: 0;
    border-radius: 999px;
    padding: 11px 20px;
    color: var(--ivory);
    background: linear-gradient(135deg, var(--wine-600), var(--wine-800));
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .3px;
    cursor: pointer;
    box-shadow: 0 10px 22px -12px rgba(79, 20, 36, .7);
    transition: transform .2s, box-shadow .2s, filter .2s;
}
.primary-button:hover, .import-form button:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 14px 26px -12px rgba(79, 20, 36, .75); }
.primary-button:disabled { opacity: .6; cursor: wait; transform: none; }

.data-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 4px; }
.data-actions a {
    color: var(--wine-700); font-size: 12.5px; font-weight: 500; text-decoration: none;
    border: 1px solid var(--rose-200); border-radius: 999px; padding: 8px 15px; background: var(--rose-50);
}
.data-actions a:hover { background: var(--rose-100); border-color: var(--rose-300); }

/* ---------------------------------------------------------- Module cards */

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.module-card {
    position: relative;
    background: var(--ivory);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-soft);
}
.module-card h2 { font-family: var(--serif); font-weight: 600; font-size: 23px; color: var(--wine-800); margin: 4px 0 8px; }
.module-card>p:last-child { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.module-card p strong { color: var(--wine-700); font-weight: 600; }
.open-hint { display: inline-block; color: var(--gold); font-family: var(--sans); font-size: 16px; margin-left: 4px; transition: transform .25s; }

button.metric-card, button.module-card { font: inherit; text-align: left; width: 100%; cursor: pointer; color: inherit; display: block; }
button.module-card { transition: transform .25s, box-shadow .25s, border-color .25s, background .25s; }
button.module-card:hover { transform: translateY(-3px); border-color: var(--rose-300); box-shadow: var(--shadow-lift); background: linear-gradient(180deg, var(--ivory), var(--rose-50)); }
button.module-card:hover .open-hint { transform: translateX(4px); }
button.metric-card:focus-visible, button.module-card:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--wine-500); outline-offset: 3px;
}

/* ---------------------------------------------------------- Tables */

.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
    color: var(--wine-700);
    background: var(--cream-100);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: .7px;
    text-transform: uppercase;
    white-space: nowrap;
}
thead tr th:first-child { border-top-left-radius: var(--radius-sm); }
thead tr th:last-child { border-top-right-radius: var(--radius-sm); }
td { color: var(--text); }
td b { color: var(--wine-800); font-weight: 600; }
tbody tr:nth-child(even) td { background: rgba(247, 239, 228, .35); }
tbody tr:hover td { background: var(--rose-50); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--rose-100); }
.scroll-box { max-height: 520px; overflow-y: auto; border: 1px solid var(--line); }
.scroll-box thead th { position: sticky; top: 0; z-index: 1; }
.table-hint { color: var(--muted); font-size: 11.5px; margin-top: 10px; font-style: italic; }

/* ---------------------------------------------------------- Forms */

.import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 18px 0; }
.import-form {
    display: grid; gap: 12px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, var(--cream-50), var(--ivory));
}
.import-form h3, .how-to h3 { font-family: var(--serif); font-weight: 600; font-size: 20px; color: var(--wine-800); }
.import-form label { display: grid; gap: 8px; color: var(--muted); font-size: 12.5px; }
.import-form input[type="file"] { font: inherit; font-size: 12px; color: var(--text); }
.import-form input[type="file"]::file-selector-button {
    font: inherit; font-size: 12px; margin-right: 10px;
    border: 1px solid var(--rose-200); background: var(--rose-50); color: var(--wine-700);
    border-radius: 999px; padding: 6px 13px; cursor: pointer;
}
.import-form button { justify-self: start; }
.import-form input[type="password"], .import-form input[data-shown], .import-form input.text-input {
    border: 1px solid var(--rose-200); background: var(--ivory); border-radius: 999px;
    padding: 11px 16px; font: inherit; font-size: 15px; color: var(--text);
}
.import-form input[type="password"]:focus, .import-form input[data-shown]:focus, .import-form input.text-input:focus { outline: none; border-color: var(--wine-500); box-shadow: 0 0 0 4px rgba(156, 53, 80, .1); }
.import-form .show-toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; }
.import-form .show-toggle input { accent-color: var(--wine-600); }
.phone-url { font-family: var(--sans); font-size: 15px; color: var(--wine-700); background: var(--ivory); padding: 2px 8px; border-radius: 8px; user-select: all; }
.import-form [role="status"] { min-height: 1.3em; margin: 0; font-size: 12px; color: var(--wine-600); }
.how-to { padding: 20px; border: 1px dashed var(--rose-300); border-radius: var(--radius-md); font-size: 13px; color: var(--text); line-height: 1.65; background: var(--rose-50); }
.how-to h3 { margin-bottom: 8px; }
.how-to ol { padding-left: 18px; margin-bottom: 8px; }
.how-to p { color: var(--muted); }
code { background: var(--cream-100); color: var(--wine-700); padding: 1px 6px; border-radius: 6px; font-size: .92em; }

.filter {
    border: 1px solid var(--rose-200); background: var(--ivory);
    border-radius: 999px; padding: 9px 16px;
    font: inherit; font-size: 12.5px; color: var(--text); min-width: 260px;
}
.filter::placeholder { color: #b9a2a5; }
.filter:focus { outline: none; border-color: var(--wine-500); box-shadow: 0 0 0 4px rgba(156, 53, 80, .1); }

.callout { background: var(--rose-50); border: 1px solid var(--rose-200); color: var(--wine-800); border-radius: var(--radius-sm); padding: 13px 16px; font-size: 13.5px; margin-bottom: 14px; }
.callout b { color: var(--wine-700); }
.callout.error { background: #fff4f2; border-color: #efc3c3; color: var(--berry); }
.update-message { min-height: 18px; }

/* ---------------------------------------------------------- Charts */

.chart-wrap { width: 100%; margin-bottom: 0; }
.chart-wrap.tall canvas { display: block; width: 100%; cursor: crosshair; }
.chart-note { color: var(--muted); font-size: 11.5px; font-style: italic; }
.range-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

/* ---------------------------------------------------------- Detail pages */

.detail-page { min-height: 100vh; }
.detail-bar {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; gap: 22px;
    padding: 12px 30px;
    color: var(--cream-100);
    background: linear-gradient(90deg, var(--wine-900), var(--wine-800) 60%, var(--wine-700));
    box-shadow: 0 8px 24px -14px rgba(58, 15, 26, .7);
}
.detail-bar .brand { margin: 0; }
.detail-bar .brand-logo { width: 38px; height: 38px; font-size: 16px; }
.detail-bar .brand h2 { font-size: 18px; }
.detail-bar .brand p { font-size: 9px; }
nav.detail-nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 2px; flex: 1; }
.detail-nav a { color: #ead6d3; text-decoration: none; font-size: 12.5px; padding: 7px 13px; border-radius: 999px; transition: background .2s, color .2s; }
.detail-nav a:hover { background: rgba(249, 233, 232, .1); color: var(--ivory); }
.detail-nav a.active { background: var(--rose-100); color: var(--wine-800); font-weight: 500; }
.detail-bar .ghost-button { background: transparent; color: var(--ivory); border-color: rgba(231, 185, 191, .45); }
.detail-bar .ghost-button:hover { background: rgba(249, 233, 232, .12); color: var(--ivory); }

.detail-main { max-width: 1320px; margin: 0 auto; padding: 36px 34px 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.detail-main > *, #detail-body > *, .content-panel { min-width: 0; }  /* wide tables scroll inside their panel */
.detail-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.detail-heading .subtitle { max-width: 760px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#detail-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

.selector-row { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 20px; }
.selector { display: flex; align-items: center; gap: 10px; }
.selector>span { color: var(--gold); font-size: 10px; font-weight: 600; letter-spacing: 1.8px; text-transform: uppercase; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--cream-100); }
.segmented button {
    border: 0; background: transparent;
    padding: 7px 14px; border-radius: 999px;
    font: inherit; font-size: 12.5px; color: var(--wine-700);
    cursor: pointer; transition: background .2s, color .2s, box-shadow .2s;
}
.segmented button:hover { background: var(--rose-100); }
.segmented button.active { background: linear-gradient(135deg, var(--wine-600), var(--wine-800)); color: var(--ivory); box-shadow: 0 6px 14px -8px rgba(79, 20, 36, .8); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
    display: grid; gap: 3px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, var(--ivory), var(--cream-50));
}
.stat:first-child { background: linear-gradient(160deg, var(--rose-100), var(--ivory)); border-color: var(--rose-200); }
.stat span { color: var(--muted); font-size: 10.5px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; }
.stat strong { font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.1; color: var(--wine-800); font-variant-numeric: lining-nums tabular-nums; }
.stat small { color: var(--muted); font-size: 10.5px; }

/* ---------------------------------------------------------- Roles and account */

html[data-role="viewer"] .admin-only { display: none !important; }
html:not([data-local="false"]) .remote-only { display: none !important; }
.account-chip .chip-link { color: inherit; font-size: 11.5px; text-decoration: underline; text-underline-offset: 2px; }
.detail-bar .account-chip .chip-link { color: var(--rose-200); }
.signup-toggle { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13.5px; }
.signup-toggle .show-toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.signup-toggle .show-toggle input { width: 18px; height: 18px; accent-color: var(--wine-600); }
.signup-toggle [role="status"] { margin: 0; color: var(--wine-600); font-size: 12px; }
.account-chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.account-chip button { border: 1px solid var(--rose-200); background: var(--ivory); color: var(--wine-700); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 11.5px; cursor: pointer; }
.account-chip button:hover { background: var(--rose-50); }
.detail-bar .account-chip { margin: 0; color: var(--rose-300); }
.detail-bar .account-chip button { background: transparent; color: var(--ivory); border-color: rgba(231, 185, 191, .45); }
.view-only-note { display: none; }
html[data-role="viewer"] .view-only-note { display: block; }
.invite-result { display: grid; gap: 10px; margin-top: 4px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--rose-50); border: 1px solid var(--rose-200); }
.invite-result code { display: block; word-break: break-all; font-size: 12.5px; padding: 8px 10px; background: var(--ivory); }
.invite-result .row { display: flex; gap: 8px; flex-wrap: wrap; }
.role-pill { font-size: 10px; letter-spacing: .8px; text-transform: uppercase; border-radius: 999px; padding: 3px 9px; }
.role-pill.admin { color: var(--ivory); background: var(--wine-700); }
.role-pill.viewer { color: var(--wine-700); background: var(--rose-100); border: 1px solid var(--rose-200); }
.link-button { border: 0; background: none; color: var(--berry); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }

.install-hint {
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50;
    display: flex; align-items: center; gap: 12px; padding: 12px 40px 12px 12px;
    color: var(--cream-100); border-radius: 20px;
    background: linear-gradient(135deg, var(--wine-700), var(--wine-900));
    box-shadow: 0 18px 40px -14px rgba(58, 15, 26, .8);
    font-size: 12.5px; line-height: 1.45;
    animation: rise .35s ease-out;
}
.install-hint img { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; }
.install-hint b { color: var(--ivory); font-weight: 600; }
.install-hint span { display: block; color: var(--rose-200); }
.install-hint svg { width: 12px; height: 14px; vertical-align: -2px; color: var(--ivory); }
.install-hint .install-now { margin-top: 6px; border: 0; border-radius: 999px; padding: 6px 14px; background: var(--rose-100); color: var(--wine-800); font: inherit; font-weight: 600; font-size: 12px; cursor: pointer; }
.install-hint .install-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: var(--rose-200); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }
[hidden] { display: none !important; }

/* ---------------------------------------------------------- Footer */

.page-footer { color: var(--muted); font-size: 11px; letter-spacing: .5px; text-align: center; padding: 30px 0 14px; }
.page-footer::before { content: "✦  "; color: var(--gold); }
.page-footer::after { content: "  ✦"; color: var(--gold); }

/* ---------------------------------------------------------- Responsive */

@media (max-width: 1280px) { .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .overview-grid { grid-template-columns: 1fr; } .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Phones, including the iPhone home-screen app (full screen, under the notch). */
@media (max-width: 760px) {
    html { -webkit-text-size-adjust: 100%; }
    body { -webkit-tap-highlight-color: transparent; padding-bottom: env(safe-area-inset-bottom); }
    .app-shell { flex-direction: column; }

    /* Sidebar becomes a compact header with one swipeable row of chips. */
    .sidebar {
        width: 100%; height: auto; min-height: 0; position: static;
        padding: calc(14px + env(safe-area-inset-top)) 0 14px;
        border-radius: 0 0 26px 26px;
        box-shadow: 0 10px 26px -16px rgba(58, 15, 26, .8);
    }
    .brand { margin: 0 18px 14px; }
    .brand-logo { width: 40px; height: 40px; font-size: 16px; }
    .nav-heading, .sidebar-footer, .sidebar > nav:first-of-type { display: none; }
    nav, nav#detail-links {
        display: flex; flex-direction: row; flex-wrap: nowrap; gap: 7px;
        overflow-x: auto; padding: 0 18px; scroll-snap-type: x proximity;
        scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    nav::-webkit-scrollbar { display: none; }
    .nav-link {
        flex: 0 0 auto; white-space: nowrap; scroll-snap-align: start;
        padding: 8px 14px; font-size: 12.5px;
        background: rgba(249, 233, 232, .09); box-shadow: inset 0 0 0 1px rgba(231, 185, 191, .22);
    }
    .nav-link:hover { padding-left: 14px; }

    .main-content { padding: 24px 16px 10px; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
    .topbar h1, .detail-heading h1 { font-size: 34px; }
    .system-status { text-align: left; }

    /* Tiles two per row; the fifth spans the row. */
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .metric-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .metric-card { padding: 16px 14px 14px; min-height: 0; border-radius: 18px; }
    .metric-card h2 { font-size: 30px; margin: 10px 0 4px; }
    .metric-card p { font-size: 10px; letter-spacing: .4px; }
    .metric-card span { font-size: 10.5px; }
    .metric-card .spark { height: 30px; margin: 8px 0 6px; }
    .metric-card:hover { transform: none; }

    .module-grid { grid-template-columns: 1fr; gap: 12px; }
    .content-panel { padding: 20px 18px; border-radius: 20px; }
    .section-heading { flex-wrap: wrap; }
    .section-heading h2 { font-size: 23px; }

    /* Detail pages: header under the notch, nav as a swipeable chip row. */
    .detail-bar { flex-wrap: wrap; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 12px; border-radius: 0 0 22px 22px; }
    .detail-bar .brand { margin: 0; }
    .detail-bar .brand p { display: none; }
    .detail-bar .ghost-button { margin-left: auto; padding: 7px 13px; font-size: 12px; }
    nav.detail-nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; padding: 0; scrollbar-width: none; }
    .detail-nav a { flex: 0 0 auto; white-space: nowrap; background: rgba(249, 233, 232, .09); }
    .detail-main { padding: 22px 16px 10px; }
    .detail-heading { flex-direction: column; align-items: flex-start; }
    .selector, .selector-row { flex-wrap: wrap; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat strong { font-size: 22px; }
    .filter { min-width: 0; width: 100%; }
    .page-footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
