/* PHD Capital — Compliance Platform
   Dark, institutional design system. "A calm professional terminal."
   Brand: bg #0c0d12, panel #14151c, purple #7B5CF5, green #22C55E,
   amber #f5b942, red #ef5350. Fraunces display + IBM Plex Sans/Mono. */

:root {
    --bg: #0c0d12;
    --panel: #14151c;
    --panel-2: #1b1d27;
    --border: #262834;
    --text: #e6e7ea;
    --muted: #8b8e9c;
    --faint: #5b5e6c;

    --purple: #7B5CF5;
    --purple-dim: #6b4fe0;
    --green: #22C55E;
    --amber: #f5b942;
    --red: #ef5350;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);

    --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --serif: 'Fraunces', Georgia, serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; margin: 0 0 0.5rem; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---- Layout shell ---- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.85rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { padding: 0.25rem 0.6rem 1.25rem; }
.sidebar .brand { text-align: center; }
.sidebar .brand .brand-logo { margin: 0 auto; }
.brand .logo { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; color: var(--text); }
.brand .logo b { color: var(--purple); }
.brand .brand-logo { width: auto; height: auto; max-height: 38px; max-width: 100%; object-fit: contain; display: block; }
.brand .tag { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 0.35rem; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 0.5rem; }
.nav a {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.6rem 0.7rem; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 500; font-size: 0.92rem;
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(123, 92, 245, 0.14); color: var(--text); }
.nav a.active .ico { color: var(--purple); }
.nav .ico { width: 18px; height: 18px; flex: none; opacity: 0.9; display: inline-flex; align-items: center; justify-content: center; }
.nav .ico svg { width: 18px; height: 18px; display: block; }

.sidebar .foot { margin-top: auto; padding: 0.75rem 0.6rem 0; border-top: 1px solid var(--border); }
.sidebar .foot .who { font-size: 0.82rem; }
.sidebar .foot .role { font-size: 0.72rem; color: var(--muted); text-transform: capitalize; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.75rem; border-bottom: 1px solid var(--border);
    background: rgba(12, 13, 18, 0.85); backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }

.content { padding: 1.75rem; max-width: none; width: 100%; }

/* ---- Readiness gauge ---- */
.gauge { display: flex; align-items: center; gap: 0.75rem; }
.gauge .ring { position: relative; width: 46px; height: 46px; }
.gauge .ring svg { transform: rotate(-90deg); }
.gauge .ring .val {
    position: absolute; inset: 0; display: grid; place-items: center;
    font-family: var(--mono); font-size: 0.82rem; font-weight: 600;
}
.gauge .label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.gauge .label b { display: block; font-size: 0.9rem; color: var(--text); font-family: var(--sans); }

/* ---- Cards & panels ---- */
.panel {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.panel h2 { font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.panel .sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1rem; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.statcard {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.1rem 1.2rem;
    position: relative; overflow: hidden;
}
.statcard .k { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.statcard .v { font-family: var(--mono); font-size: 2.1rem; font-weight: 600; margin-top: 0.35rem; line-height: 1; }
.statcard .accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.statcard.red .accent { background: var(--red); }
.statcard.amber .accent { background: var(--amber); }
.statcard.green .accent { background: var(--green); }
.statcard.purple .accent { background: var(--purple); }
.statcard.red .v { color: var(--red); }
.statcard.amber .v { color: var(--amber); }
.statcard.green .v { color: var(--green); }

/* ---- Status pills ---- */
.pill {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.22rem 0.6rem; border-radius: 999px;
    font-size: 0.76rem; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.pill.green { background: rgba(34, 197, 94, 0.12); color: var(--green); border-color: rgba(34,197,94,0.25); }
.pill.green .dot { background: var(--green); }
.pill.red { background: rgba(239, 83, 80, 0.12); color: var(--red); border-color: rgba(239,83,80,0.25); }
.pill.red .dot { background: var(--red); }
.pill.amber { background: rgba(245, 185, 66, 0.12); color: var(--amber); border-color: rgba(245,185,66,0.25); }
.pill.amber .dot { background: var(--amber); }
.pill.grey { background: rgba(139,142,156,0.12); color: var(--muted); border-color: rgba(139,142,156,0.2); }
.pill.grey .dot { background: var(--muted); }

/* ---- Coverage bars ---- */
.cover { margin-bottom: 0.85rem; }
.cover .row { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.35rem; }
.cover .row .cap { text-transform: capitalize; }
.cover .track { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.cover .fill { height: 100%; border-radius: 999px; background: var(--green); transition: width 0.4s; }
.cover .fill.low { background: var(--red); }
.cover .fill.mid { background: var(--amber); }

/* ---- Tables / task rows ---- */
.tasktabs { display: flex; gap: 0.4rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.tasktabs a {
    padding: 0.45rem 0.9rem; border-radius: 999px; font-size: 0.85rem;
    background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.tasktabs a.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.tasktabs a:hover { text-decoration: none; color: var(--text); }

.task {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 0.6rem; overflow: hidden;
}
.task .head {
    display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 1rem;
    align-items: center; padding: 0.9rem 1.15rem; cursor: pointer;
}
.task .due.last-up { border-right: 1px solid var(--border); padding-right: 1rem; }
.task-ico {
    width: 38px; height: 38px; flex: none; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--panel-2); border: 1px solid var(--border);
}
.task-ico svg { width: 20px; height: 20px; }
.task-ico.sev-high { color: var(--red); background: rgba(239,83,80,0.1); border-color: rgba(239,83,80,0.22); }
.task-ico.sev-medium { color: var(--amber); background: rgba(245,185,66,0.1); border-color: rgba(245,185,66,0.22); }
.task-ico.sev-low { color: var(--green); background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.22); }
.task .head:hover { background: var(--panel-2); }
.task .title { font-weight: 600; font-size: 0.95rem; }
.task .meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.task .due { font-family: var(--mono); font-size: 0.82rem; text-align: right; }
.task .due .lbl { color: var(--faint); font-size: 0.68rem; display: block; text-transform: uppercase; }
.task .body { display: none; padding: 0 1.15rem 1.15rem; border-top: 1px solid var(--border); }
.task.open .body { display: block; }
.task .body .fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.85rem; margin: 1rem 0; }
.task .history { margin-top: 0.85rem; }
.task .history h4 { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.task .history .h { font-size: 0.83rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--border); display: flex; gap: 0.6rem; }
.task .history .h .d { font-family: var(--mono); color: var(--muted); }

/* ---- Forms ---- */
label.field { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.3rem; }
input, select, textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border);
    color: var(--text); border-radius: var(--radius-sm); padding: 0.55rem 0.7rem;
    font-family: var(--sans); font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); }
input.mono { font-family: var(--mono); }

.btn {
    display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer;
    background: var(--purple); color: #fff; border: none;
    padding: 0.55rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.88rem; font-weight: 600; font-family: var(--sans);
}
.btn:hover { background: var(--purple-dim); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.green { background: var(--green); }
.btn.sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

/* ---- AI briefing panel ---- */
.ai-panel { border-color: rgba(123, 92, 245, 0.3); }
.ai-panel .badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--purple); border: 1px solid rgba(123,92,245,0.3);
    padding: 0.15rem 0.5rem; border-radius: 999px;
}
.ai-risk { padding: 0.75rem 0; border-bottom: 1px dashed var(--border); }
.ai-risk:last-child { border-bottom: none; }
.ai-risk .item { font-weight: 600; }
.ai-risk .why { color: var(--muted); font-size: 0.86rem; margin: 0.2rem 0; }
.ai-risk .action { font-size: 0.86rem; }
.ai-risk .action b { color: var(--green); }
.ai-disclaimer { font-size: 0.76rem; color: var(--faint); margin-top: 1rem; font-style: italic; }

/* ---- Brand row + mobile menu toggle ---- */
.brand-row { display: flex; align-items: flex-start; justify-content: space-between; }
.menu-toggle {
    display: none; background: transparent; border: 1px solid var(--border);
    color: var(--text); border-radius: 8px; width: 38px; height: 38px;
    cursor: pointer; align-items: center; justify-content: center; flex: none;
}
.menu-toggle svg { width: 20px; height: 20px; }

/* ---- Confirmation modal ---- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100; padding: 1rem;
    background: rgba(6, 7, 10, 0.72); backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 420px;
    box-shadow: var(--shadow); animation: modalpop 0.14s ease-out;
}
@keyframes modalpop { from { transform: translateY(6px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.modal .modal-msg { color: var(--muted); margin: 0 0 1.4rem; font-size: 0.92rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* ---- Flash messages ---- */
.flash { padding: 0.7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; border: 1px solid; }
.flash.success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: var(--green); }
.flash.error { background: rgba(239,83,80,0.1); border-color: rgba(239,83,80,0.3); color: var(--red); }
.flash.info { background: rgba(123,92,245,0.1); border-color: rgba(123,92,245,0.3); color: var(--purple); }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { text-align: center; padding-bottom: 1.5rem; }
.login-card .brand .logo { font-size: 1.8rem; }
.login-card .brand .brand-logo { margin: 0 auto; max-height: 64px; }

/* ---- Misc ---- */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 1.75rem 0 1rem; }
.section-title h2 { font-size: 1.05rem; margin: 0; }
.row-flex { display: flex; align-items: center; gap: 0.75rem; }
.spacer { flex: 1; }
.mt { margin-top: 1.25rem; }
.mb { margin-bottom: 1.25rem; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
table.data td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:hover td { background: var(--panel-2); }

.footer-brand { text-align: center; color: var(--faint); font-size: 0.78rem; padding: 2rem 0 1rem; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .content { padding: 1.25rem; }
    /* Stack the two-column dashboard/insights/reports panels */
    .grid-2[style*="1.4fr"], .grid-2[style*="1.5fr"], .grid-2[style*="1fr 1fr"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: sticky; top: 0; height: auto; z-index: 20;
        flex-direction: column; padding: 0.75rem 0.85rem;
    }
    .menu-toggle { display: inline-flex; }
    .brand-row { align-items: center; }
    .sidebar .nav, .sidebar .foot { display: none; }
    .sidebar.open .nav { display: flex; margin-top: 0.75rem; }
    .sidebar.open .foot { display: block; margin-top: 0.75rem; }
    .sidebar .foot { margin-top: 0; }

    .topbar { padding: 0.85rem 1.1rem; }
    .topbar h1 { font-size: 1rem; }
    .content { padding: 1rem; }

    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }

    /* Task rows: let the due column drop under, keep icon + title + pill readable */
    .task .head { grid-template-columns: auto 1fr auto; row-gap: 0.5rem; }
    .task .due { grid-column: 2 / -1; text-align: left; }
    .task .due.last-up { border-right: none; padding-right: 0; }
    .task .body .fields { grid-template-columns: 1fr; }

    /* Tables scroll horizontally instead of squashing */
    .panel > table.data, table.data { display: block; overflow-x: auto; white-space: nowrap; }

    .modal { max-width: 100%; }
}

@media (max-width: 560px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .statcard .v { font-size: 1.7rem; }
    .tasktabs { gap: 0.3rem; }
    .tasktabs a { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
    .gauge .label { display: none; }
    .section-title { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .login-wrap { padding: 1rem; }
}

/* ============================================================
   Motion & polish — loading/progress animations, hover, etc.
   ============================================================ */

/* Top progress bar (navigation / form submit feedback) */
#topProgress {
    position: fixed; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--purple), #a78bfa);
    transform: scaleX(0); transform-origin: 0 50%;
    transition: transform 0.18s ease, opacity 0.3s ease;
    z-index: 200; opacity: 0; pointer-events: none;
    box-shadow: 0 0 10px rgba(123, 92, 245, 0.6);
}
#topProgress.active { opacity: 1; }
#topProgress.done { opacity: 0; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons: press feedback + loading spinner */
.btn { transition: background 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease; }
.btn:not(.ghost):hover { box-shadow: 0 4px 16px rgba(123, 92, 245, 0.28); }
.btn:active { transform: translateY(1px); }
.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    width: 15px; height: 15px; margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
.btn.ghost.is-loading::after { border-color: rgba(230, 231, 234, 0.25); border-top-color: var(--text); }

/* Content + card entrance */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.content { animation: fadeUp 0.34s ease-out both; }
.statcard { animation: fadeUp 0.42s ease-out both; }
.grid-4 > .statcard:nth-child(1) { animation-delay: 0.03s; }
.grid-4 > .statcard:nth-child(2) { animation-delay: 0.08s; }
.grid-4 > .statcard:nth-child(3) { animation-delay: 0.13s; }
.grid-4 > .statcard:nth-child(4) { animation-delay: 0.18s; }
.grid-3 > .statcard:nth-child(2) { animation-delay: 0.07s; }
.grid-3 > .statcard:nth-child(3) { animation-delay: 0.13s; }

/* Hover lifts on cards/rows */
.statcard { transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease; }
.statcard:hover { transform: translateY(-2px); border-color: #34384a; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28); }
.panel { transition: border-color 0.16s ease, box-shadow 0.16s ease; }
.task { transition: border-color 0.14s ease, box-shadow 0.14s ease; }
.task:hover { border-color: #34384a; }
.task-ico { transition: transform 0.16s ease; }
.task:hover .task-ico { transform: scale(1.06); }
.nav a, .pill, .btn.sm { transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.06s ease; }

/* Coverage bars animate width smoothly when set by JS */
.cover .fill { transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1); }

/* Flash messages slide in */
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.flash { animation: flashIn 0.28s ease-out both; }

/* Inputs focus polish */
input, select, textarea { transition: border-color 0.14s ease, box-shadow 0.14s ease; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(123, 92, 245, 0.18); }

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    #topProgress { display: none; }
}

/* ---- Lightweight CSS donut (replaces Chart.js on Insights) ---- */
.donut-wrap { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; position: relative; flex: none; }
.donut .hole {
    position: absolute; inset: 24%; background: var(--panel); border-radius: 50%;
    display: grid; place-items: center; text-align: center;
}
.donut .hole b { font-family: var(--mono); font-size: 1.5rem; font-weight: 600; line-height: 1; }
.donut .hole small { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; }
.donut-legend { font-size: 0.88rem; }
.donut-legend .li { display: flex; align-items: center; gap: 0.55rem; margin: 0.35rem 0; }
.donut-legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.donut-legend .n { margin-left: auto; font-family: var(--mono); color: var(--muted); padding-left: 1rem; }

/* ---- Uploaded files UI ---- */
.file-block { font-size: 0.9rem; }
.file-block-h { font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.5rem; }
.file-item { display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px dashed var(--border); }
.file-item:last-of-type { border-bottom: none; }
.file-ico {
    width: 40px; height: 40px; flex: none; border-radius: 8px; display: inline-flex;
    align-items: center; justify-content: center; font-family: var(--mono); font-size: 0.62rem;
    font-weight: 600; color: var(--purple); background: rgba(123,92,245,0.1);
    border: 1px solid rgba(123,92,245,0.22); letter-spacing: 0.02em;
}
.file-meta .fn { font-weight: 600; word-break: break-word; }
.file-meta .fsub { color: var(--muted); font-size: 0.78rem; margin-top: 0.1rem; }
.file-meta .fai {
    margin-top: 0.4rem; font-size: 0.82rem; color: var(--text); background: var(--panel);
    border: 1px solid var(--border); border-left: 2px solid var(--purple);
    border-radius: 6px; padding: 0.5rem 0.65rem; line-height: 1.45;
}
.file-meta .fai span, .fai > span:first-child { color: var(--purple); font-weight: 600; font-size: 0.72rem; }
.file-act { text-align: right; }
.file-actions { display: flex; gap: 0.35rem; justify-content: flex-end; flex-wrap: wrap; }
.file-upload { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.85rem; flex-wrap: wrap; }
.file-upload input[type=file] { width: auto; flex: 1; min-width: 200px; font-size: 0.84rem; padding: 0.4rem; }

/* Reveal block (delete password, etc.) */
.reveal { display: none; }
.reveal.open { display: block; }
.del-form { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }
.del-form input[type=password] { width: auto; flex: 1; min-width: 220px; }

@media (max-width: 700px) {
    .file-item { grid-template-columns: auto 1fr; }
    .file-act { grid-column: 1 / -1; }
    .file-actions { justify-content: flex-start; }
}

/* ---- Google Drive UI ---- */
.file-ico.drive { color: var(--green); background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.25); }
.src-badge {
    display: inline-block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--green); background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.28); border-radius: 5px; padding: 0.05rem 0.35rem;
    vertical-align: middle; margin-left: 0.4rem;
}
.drive-list .file-item { padding: 0.55rem 0; }
.drive-list .file-item:first-child { padding-top: 0; }

/* ---- 360 search ---- */
.search-box { position: relative; }
.search-box .search-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; display: inline-flex; }
.search-box .search-ico svg { width: 18px; height: 18px; display: block; }
.search-box input { padding-left: 42px; }
.search-hero .search-box input { font-size: 1.05rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.search-box.compact { width: 250px; max-width: 100%; }
.search-box.compact input { padding: 0.45rem 0.7rem 0.45rem 34px; font-size: 0.86rem; }
.search-box.compact .search-ico { left: 10px; width: 15px; height: 15px; }
.search-box.compact .search-ico svg { width: 15px; height: 15px; }

#search360Results.is-searching { opacity: 0.45; transition: opacity 0.15s; }
.sr-group { margin-bottom: 1.4rem; }
.sr-head { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.55rem; }
.sr-head .sr-ico { width: 16px; height: 16px; color: var(--purple); display: inline-flex; }
.sr-head .sr-ico svg { width: 16px; height: 16px; }
.sr-item { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 0.9rem; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 0.45rem; transition: border-color 0.14s ease, transform 0.07s ease; }
.sr-item:hover { border-color: #34384a; text-decoration: none; transform: translateX(2px); }
.sr-main { flex: 1; min-width: 0; }
.sr-title { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.sr-meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.sr-snip { color: var(--faint); font-size: 0.82rem; margin-top: 0.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-go { color: var(--faint); font-size: 1.1rem; flex: none; }
.sr-item:hover .sr-go { color: var(--purple); }

@media (max-width: 560px) { .search-box.compact { width: 100%; } }

/* ---- macOS Finder-style Drive window ---- */
.finder {
    background: #ffffff; color: #1d1d1f; border-radius: 12px; overflow: hidden;
    border: 1px solid #d3d3d8; box-shadow: 0 18px 50px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.25);
    margin-bottom: 1rem;
}
.finder-titlebar {
    position: relative; height: 42px; display: flex; align-items: center; gap: 0.6rem;
    padding: 0 0.85rem; background: linear-gradient(#fbfbfd,#e9e9ed); border-bottom: 1px solid #d4d4d9;
}
.finder-traffic { display: flex; gap: 8px; align-items: center; z-index: 1; }
.finder-traffic i, .finder-traffic a { width: 12px; height: 12px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.18); }
.finder-traffic .tl-red { background: #ff5f57; }
.finder-traffic .tl-red:hover { background: #ff4036; }
.finder-traffic .tl-yellow { background: #febc2e; }
.finder-traffic .tl-green { background: #28c840; }
.finder-title {
    position: absolute; left: 0; right: 0; text-align: center; pointer-events: none;
    font-size: 0.82rem; font-weight: 600; color: #3a3a3c; padding: 0 120px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.finder-toolbar {
    display: flex; align-items: center; gap: 0.55rem; padding: 0.5rem 0.85rem;
    background: #fafafa; border-bottom: 1px solid #e4e4e8;
}
.finder-nav { display: flex; gap: 0.3rem; }
.finder-btn {
    width: 30px; height: 28px; border-radius: 7px; border: 1px solid #d7d7dc; background: #fff;
    display: inline-flex; align-items: center; justify-content: center; color: #5b5b60;
    cursor: pointer; text-decoration: none; font-size: 0.95rem; line-height: 1; padding: 0;
}
.finder-btn:hover { background: #f0f0f3; color: #1d1d1f; text-decoration: none; }
.finder-btn.disabled { opacity: 0.35; pointer-events: none; }
.finder-btn svg { width: 16px; height: 16px; }
.finder-loc { display: flex; align-items: center; gap: 0.4rem; min-width: 0; font-size: 0.84rem; color: #6e6e73; }
.finder-loc b { color: #1d1d1f; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder-loc .chev { color: #b0b0b6; }
.finder-spacer { flex: 1; }
.finder-search { position: relative; }
.finder-search input {
    width: 190px; max-width: 40vw; background: #fff; border: 1px solid #d7d7dc; color: #1d1d1f;
    border-radius: 7px; padding: 0.35rem 0.6rem 0.35rem 1.9rem; font-size: 0.82rem;
}
.finder-search .si { position: absolute; left: 0.55rem; top: 50%; transform: translateY(-50%); color: #9a9aa0; font-size: 0.85rem; }
.finder-head, .finder-row { display: grid; gap: 0.75rem; align-items: center; }
.finder.browse .finder-head, .finder.browse .finder-row { grid-template-columns: 26px 1fr 116px 84px; }
.finder.viewer .finder-head, .finder.viewer .finder-row { grid-template-columns: 1fr 116px 84px 168px; }
.finder-head {
    padding: 0.4rem 0.95rem; font-size: 0.7rem; color: #86868b; text-transform: uppercase;
    letter-spacing: 0.03em; background: #fcfcfd; border-bottom: 1px solid #ececef;
}
.finder-head .r { text-align: right; }
.finder-body { max-height: 62vh; overflow: auto; background: #fff; }
.finder-row { padding: 0.5rem 0.95rem; border-bottom: 1px solid #f2f2f4; cursor: default; -webkit-user-select: none; user-select: none; }
.finder-row[data-open] { cursor: pointer; }
.finder-row:last-child { border-bottom: none; }
.finder-row:hover { background: #f5f5f7; }
.finder.browse .finder-row.sel { background: #e6f0fe; }
.finder.browse .finder-row { cursor: pointer; }
.finder-name { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.finder-name .nm { font-size: 0.9rem; font-weight: 500; color: #1d1d1f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; }
.finder-ico svg { display: block; }
.finder-col { font-size: 0.8rem; color: #86868b; }
.finder-col.r { text-align: right; }
.finder-actions { display: flex; gap: 0.35rem; justify-content: flex-end; }
.finder-check { width: 17px; height: 17px; accent-color: #2680eb; cursor: pointer; }
.finder-foot {
    display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.95rem;
    background: #fafafa; border-top: 1px solid #e4e4e8;
}
.finder-foot .hint { font-size: 0.8rem; color: #86868b; }
.finder-empty { padding: 2.2rem 1rem; text-align: center; color: #9a9aa0; font-size: 0.9rem; }
/* Light buttons inside the Finder window so they read on white. */
.finder .btn.ghost { border-color: #d7d7dc; color: #1d1d1f; background: #fff; }
.finder .btn.ghost:hover { background: #f0f0f3; }
.finder .btn.mac { background: #2680eb; color: #fff; border: none; }
.finder .btn.mac:hover { background: #1a6fd6; }
.finder .btn.mac:disabled { background: #c7d8ef; cursor: default; }
@media (max-width: 720px) {
    .finder.browse .finder-head, .finder.browse .finder-row { grid-template-columns: 26px 1fr 84px; }
    .finder.viewer .finder-head, .finder.viewer .finder-row { grid-template-columns: 1fr 168px; }
    .finder-col.date, .finder-col.size, .finder-head .date, .finder-head .size { display: none; }
    .finder-title { padding: 0 72px; }
}

/* ---- Complaints disclosure tables (website-ready, bordered) ---- */
table.data.disc { font-size: 0.84rem; }
table.data.disc th, table.data.disc td { border: 1px solid var(--border); text-align: center; padding: 0.5rem 0.6rem; }
table.data.disc th { color: var(--muted); }
table.data.disc td:first-child, table.data.disc th:first-child { text-align: left; }

/* ---- Ad / report checker result ---- */
.review-body {
    font-size: 0.9rem; line-height: 1.6; white-space: normal;
    background: var(--bg); border: 1px solid var(--border); border-left: 2px solid var(--purple);
    border-radius: var(--radius-sm); padding: 0.9rem 1rem; max-height: 60vh; overflow: auto;
}

/* ---- 2FA setup key ---- */
.setup-key {
    background: var(--panel-2); border: 1px dashed var(--border); border-radius: var(--radius-sm);
    padding: 0.8rem 1rem; font-size: 1.05rem; letter-spacing: 0.12em; text-align: center;
    -webkit-user-select: all; user-select: all; word-break: break-all;
}

/* ---- Per-user permission matrix ---- */
.perm-matrix { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.9rem 1rem; }
.perm-group { padding: 0.5rem 0; border-bottom: 1px dashed var(--border); }
.perm-group:last-of-type { border-bottom: none; }
.perm-group-h { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.4rem; }
.perm-caps { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; }
.perm-cap { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.84rem; white-space: nowrap; }
.perm-cap input { width: auto; }

/* ---- Workspace activity matrix ---- */
table.data.ws-activity td.r, table.data.ws-activity th.r { text-align: right; }
table.data.ws-activity tr.ws-total td { border-top: 2px solid var(--border); font-weight: 700; }
table.data.ws-activity td.mono { font-family: var(--mono); }
