/* tantua-odrive — faithful port of svelte-erp (apps/web/src).
   Sources: routes/layout.css (tokens), (app)/+layout.svelte (shell),
   lib/components/{Sidebar,Icon,ui.ts,DocList,StatusBadge,CommandPalette}.svelte,
   lib/forms/SchemaForm.svelte. Plain CSS, same computed styles. */

:root {
    --radius: 0.375rem;
    --background: oklch(0.985 0.003 250);
    --foreground: oklch(0.19 0.02 255);
    --card: oklch(1 0.002 250);
    --card-foreground: oklch(0.185 0.005 90);
    --popover: oklch(1 0 0);
    --popover-foreground: oklch(0.185 0.005 90);
    --primary: oklch(0.48 0.17 262);
    --primary-foreground: oklch(0.99 0.002 250);
    --secondary: oklch(0.96 0.006 250);
    --secondary-foreground: oklch(0.19 0.02 255);
    --muted: oklch(0.96 0.006 250);
    --muted-foreground: oklch(0.52 0.02 255);
    --accent: oklch(0.955 0.012 250);
    --accent-foreground: oklch(0.19 0.02 255);
    --destructive: oklch(0.577 0.245 27.325);
    --destructive-foreground: oklch(0.985 0.002 90);
    --success: oklch(0.62 0.15 155);
    --warning: oklch(0.75 0.15 85);
    --info: oklch(0.62 0.14 235);
    --border: oklch(0.91 0.008 250);
    --input: oklch(0.91 0.008 250);
    --ring: oklch(0.65 0.1 255);
    --sidebar: oklch(0.978 0.005 250);
    --sidebar-foreground: oklch(0.19 0.02 255);
    --sidebar-border: oklch(0.91 0.008 250);
}
.dark {
    --background: oklch(0.145 0.015 255);
    --foreground: oklch(0.932 0.02 255);
    --card: oklch(0.185 0.018 255);
    --card-foreground: oklch(0.932 0.02 255);
    --popover: oklch(0.2 0.02 255);
    --popover-foreground: oklch(0.932 0.02 255);
    --primary: oklch(0.68 0.14 262);
    --primary-foreground: oklch(0.14 0.02 260);
    --secondary: oklch(0.235 0.02 255);
    --secondary-foreground: oklch(0.932 0.02 255);
    --muted: oklch(0.235 0.02 255);
    --muted-foreground: oklch(0.65 0.02 258);
    --accent: oklch(0.27 0.025 255);
    --accent-foreground: oklch(0.932 0.02 255);
    --destructive: oklch(0.62 0.2 25);
    --destructive-foreground: oklch(0.985 0.002 90);
    --success: oklch(0.66 0.14 155);
    --warning: oklch(0.78 0.14 85);
    --info: oklch(0.66 0.13 235);
    --border: oklch(0.29 0.02 255);
    --input: oklch(0.29 0.02 255);
    --ring: oklch(0.5 0.08 262);
    --sidebar: oklch(0.165 0.015 255);
    --sidebar-foreground: oklch(0.932 0.02 255);
    --sidebar-border: oklch(0.28 0.02 255);
}

@layer base {
    * { box-sizing: border-box; border-color: var(--border); }
    html { height: 100%; }
    body {
        margin: 0; height: 100%;
        background: var(--background);
        color: var(--foreground);
        font-size: 13px;
        line-height: 1.45;
        font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    }
    a { color: inherit; text-decoration: none; }
    kbd {
        font-family: inherit; font-size: 10px;
        border: 1px solid var(--border); border-radius: 4px; padding: 0 4px;
        color: var(--muted-foreground);
    }
    ::placeholder { color: var(--muted-foreground); }
}
.muted { color: var(--muted-foreground); }

/* ============ app shell — (app)/+layout.svelte ============ */
.shell { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* aside: flex shrink-0 flex-col border-r bg-sidebar, w-60 ⇄ w-14 (transition-[width] 150ms) */
.sidebar {
    display: flex; flex-shrink: 0; flex-direction: column;
    width: 15rem; transition: width 150ms;
    border-right: 1px solid var(--sidebar-border); background: var(--sidebar);
}
.sidebar.collapsed { width: 3.5rem; }
.sidebar.collapsed .brand span { display: none; }
.sidebar.collapsed .brand { justify-content: center; }
.sidebar.collapsed .snav-label { display: none; } /* was visibility:hidden — kept label text width → horizontal scrollbar */
.sidebar.collapsed .snav-group { margin-bottom: 0; }
.sidebar.collapsed .snav-items { display: block !important; } /* groups stay open when collapsed */
.sidebar.collapsed .snav-items a {
    display: flex; justify-content: center; align-items: center; padding: 0.45rem; border-radius: 6px;
}
.sidebar.collapsed .snav-items a .ico { display: block; }
.sidebar.collapsed .snav-items a span { display: none; }
.sidebar.collapsed .side-dots { display: none; }

/* brand row: flex h-10 items-center gap-2 border-b px-3 */
.brand {
    display: flex; height: 2.5rem; align-items: center; gap: 0.5rem; padding: 0 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
    font-size: 13px; font-weight: 600; color: var(--sidebar-foreground);
    white-space: nowrap; overflow: hidden;
}
.side-dots { display: none; padding: 0.75rem; font-size: 11px; color: var(--muted-foreground); }
.snav-items a .ico { display: none; width: 16px; height: 16px; flex-shrink: 0; } /* icon-only rail when collapsed */

/* nav — Sidebar.svelte: flex min-h-0 flex-1 flex-col overflow-y-auto px-2 py-3 text-[13px] */
.snav {
    display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding: 0.5rem 0.5rem 0.75rem; font-size: 13px;
}
.snav-group { margin-bottom: 0.25rem; }
.snav-label {
    display: flex; width: 100%; align-items: center; gap: 0.25rem;
    padding: 0.25rem 0.5rem 0.25rem;
    font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.025em;
    color: var(--muted-foreground); background: none; border: none; cursor: pointer;
    font-family: inherit; text-align: left;
}
.snav-label:hover { color: var(--foreground); }
.snav-label .chev { width: 12px; height: 12px; flex-shrink: 0; transition: transform 150ms; }
.snav-group.open .chev { transform: rotate(90deg); }
.snav-group:not(.open) .snav-items { display: none; }
.snav-items a {
    display: block; padding: 0.375rem 0.5rem 0.375rem 1.5rem; border-radius: 6px;
    color: var(--foreground); white-space: nowrap;
}
.snav-items a:hover { background: var(--accent); }
.snav-items a.active { background: var(--accent); font-weight: 500; }

/* collapse button — mx-2 mb-3 mt-auto, p-1.5 rounded-md hover:bg-accent */
.side-collapse {
    margin: auto 0.5rem 0.75rem; display: flex; align-items: center; justify-content: center;
    padding: 6px; border-radius: 6px; background: none; border: none; cursor: pointer;
    color: var(--muted-foreground);
}
.side-collapse:hover { background: var(--accent); }

/* main col: flex min-w-0 flex-1 flex-col */
.main { display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* topbar — h-10 shrink-0 items-center gap-3 border-b px-3 */
.topbar {
    display: flex; height: 2.5rem; flex-shrink: 0; align-items: center; gap: 0.75rem;
    border-bottom: 1px solid var(--border); padding: 0 0.75rem;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
/* search slot button — h-7 w-72 rounded-md border bg-card px-2 text-[12px] */
.palette-btn {
    display: flex; height: 1.75rem; width: 18rem; align-items: center; gap: 0.5rem;
    border: 1px solid var(--border); border-radius: 6px; background: var(--card);
    padding: 0 0.5rem; font-size: 12px; color: var(--muted-foreground); cursor: pointer;
}
.palette-btn:hover { background: var(--accent); }
.palette-btn .flex1 { flex: 1; text-align: left; }
/* tenant pill — rounded-md border px-1.5 py-0.5 text-[11px] */
.tenant-pill {
    border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
    font-size: 11px; color: var(--muted-foreground); max-width: 220px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-user { font-size: 12px; color: var(--muted-foreground); }

/* content — min-h-0 flex-1 overflow-auto px-4 py-3 */
.content { min-height: 0; flex: 1; overflow: auto; padding: 0.75rem 1rem; }

/* ============ ui.ts primitives ============ */
/* button base: inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-transparent px-3 text-[13px] font-medium transition-colors 100ms */
.btn {
    display: inline-flex; height: 2rem; align-items: center; justify-content: center;
    gap: 6px; border: 1px solid transparent; border-radius: 6px; padding: 0 0.75rem;
    font-size: 13px; font-weight: 500; font-family: inherit;
    transition: background-color 100ms, opacity 100ms; cursor: pointer;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.btn:disabled { pointer-events: none; opacity: 0.5; }
.btn, .btn:hover { text-decoration: none; }
.btn-default { background: var(--primary); color: var(--primary-foreground); }
.btn-default:hover { opacity: 0.9; }
.btn-outline { background: transparent; color: var(--foreground); }
.btn-outline:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--accent); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive:hover { opacity: 0.9; }
.btn-sm { height: 1.75rem; padding: 0 0.5rem; }
.btn-icon { height: 1.75rem; width: 1.75rem; padding: 0; }

/* input: flex h-8 w-full rounded-md border border-(--input) bg-transparent px-2.5 py-1 text-[13px] */
.input {
    display: flex; height: 2rem; width: 100%; border: 1px solid var(--input);
    border-radius: 6px; background: transparent; padding: 4px 10px;
    font-size: 13px; font-family: inherit; color: var(--foreground);
}
.input:focus { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.input:disabled { opacity: 0.5; }
.input.max-xs { max-width: 20rem; }
.input.w-64 { width: 16rem; }

/* badge: inline-flex items-center gap-1.5 rounded-md border px-1.5 py-0.5 text-[11px] font-medium leading-none */
/* admin users: per-column cells + drives popup */
.cell-center { text-align: center; }
#drives-popup { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 200; }
#drives-popup[hidden] { display: none; }
.dp-inner { background: var(--card, var(--bg, #fff)); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; min-width: 320px; max-width: 480px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.dp-list { display: flex; flex-direction: column; gap: 6px; }
.dp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* admin users: per-user drive chips */
.drive-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border: 1px solid var(--border);
         border-radius: 999px; font-size: 11px; background: var(--bg, transparent); max-width: 220px; overflow: hidden;
         text-overflow: ellipsis; white-space: nowrap; }
.chip-own { border-style: dashed; }
.chip a { color: var(--destructive, #b00); text-decoration: none; font-weight: 700; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
    font-size: 11px; font-weight: 500; line-height: 1.1; color: var(--muted-foreground);
}
.badge .dot { display: inline-block; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; opacity: 0.9; }
.badge-success { border-color: transparent; color: var(--success); }
.badge-destructive { border-color: transparent; color: var(--destructive); }
.badge-info { border-color: transparent; color: var(--info); }
.badge-warning { border-color: transparent; color: var(--warning); }

/* lucide svg sizing helper */
.lucide { flex-shrink: 0; }

/* ============ DocList ============ */
/* wrapper: overflow-hidden rounded-lg border bg-card */
.doclist { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.doclist table { width: 100%; font-size: 13px; border-collapse: collapse; }
.doclist thead tr {
    border-bottom: 1px solid var(--border);
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.025em;
    color: var(--muted-foreground);
}
.doclist th { padding: 8px 0.75rem; font-weight: 500; }
.doclist tbody tr { height: 2rem; border-bottom: 1px solid var(--border); }
.doclist tbody tr:last-child { border-bottom: none; }
.doclist tbody tr:hover { background: color-mix(in oklab, var(--accent) 50%, transparent); }
.doclist tbody tr.clickable { cursor: pointer; }
.doclist td { padding: 4px 0.75rem; }
.doclist td.actions { text-align: right; padding: 4px 6px; }
.doclist .empty { padding: 24px 0.75rem; text-align: center; color: var(--muted-foreground); }
.doclist .loading { padding: 24px 0.75rem; text-align: center; color: var(--muted-foreground); }
/* DocList action buttons: ml-1 rounded-md border px-2 py-0.5 text-[11px] hover:bg-accent */
.rowbtn {
    margin-left: 4px; border: 1px solid var(--border); border-radius: 6px;
    padding: 2px 8px; font-size: 11px; background: none; cursor: pointer; color: var(--foreground);
    display: inline-block; font-family: inherit;
}
.rowbtn:hover { background: var(--accent); }
.rowbtn-danger { color: var(--destructive); }

/* ============ page patterns ============ */
/* list page: flex flex-col gap-3; head row flex items-center justify-between */
.page-col { display: flex; flex-direction: column; gap: 0.75rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
h1.page-title { font-size: 15px; font-weight: 600; margin: 0; }
/* "+ New" primary link — rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium */
.btn-new {
    display: inline-flex; align-items: center; border-radius: 6px;
    background: var(--primary); color: var(--primary-foreground);
    padding: 6px 12px; font-size: 12px; font-weight: 500; cursor: pointer; border: none;
    font-family: inherit;
}
.btn-new:hover { opacity: 0.9; }
.list-count { font-size: 11px; color: var(--muted-foreground); }

/* workspace link cards — rounded-md border bg-card px-3 py-2 text-[13px] hover:bg-accent */
.link-card {
    display: inline-flex; border: 1px solid var(--border); border-radius: 6px;
    background: var(--card); padding: 8px 12px; font-size: 13px;
}
.link-card:hover { background: var(--accent); }

/* error text — text-[12px] text-destructive */
.err { font-size: 12px; color: var(--destructive); }

/* ============ drives page (cards) ============ */
.drive-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.drive-card {
    width: 340px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); padding: 12px;
}
.drive-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.drive-head strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-email { font-size: 11px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
.quota-bar { height: 8px; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.quota-fill { height: 100%; border-radius: 9999px; background: var(--primary); transition: width 150ms; }
.quota-text { font-size: 11px; color: var(--muted-foreground); margin-top: 4px; }
.drive-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ============ auth (login card — exact svelte pattern) ============ */
.auth-wrap { display: flex; height: 100vh; width: 100vw; align-items: center; justify-content: center; background: var(--background); }
.auth-card {
    width: 360px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); padding: 20px;
}
.auth-card h1 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.auth-card .sub { font-size: 12px; color: var(--muted-foreground); margin: 0 0 16px; }
.auth-card .errbox {
    margin-top: 12px; border: 1px solid var(--destructive); border-radius: 6px;
    padding: 6px 8px; font-size: 12px; color: var(--destructive);
}

/* ============ CommandPalette ============ */
.palette-overlay {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start;
    justify-content: center; background: rgba(0, 0, 0, 0.4); padding-top: 15vh;
}
.palette-panel {
    width: 480px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px;
    background: var(--popover); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
.palette-head { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 0 0.75rem; }
.palette-head input {
    height: 2.5rem; flex: 1; background: transparent; border: none; outline: none;
    font-size: 13px; font-family: inherit; color: var(--foreground);
}
.palette-list { max-height: 320px; overflow: auto; padding: 4px 0; }
.palette-item {
    display: flex; width: 100%; align-items: center; justify-content: space-between;
    padding: 6px 12px; text-align: left; font-size: 13px; background: none; border: none;
    color: var(--foreground); cursor: pointer; font-family: inherit;
}
.palette-item.active { background: var(--accent); }
.palette-item .grp { font-size: 11px; color: var(--muted-foreground); }
.palette-empty { padding: 24px 12px; text-align: center; font-size: 12px; color: var(--muted-foreground); }

/* ============ SchemaForm ============ */
/* form card: w-[560px] rounded-lg border bg-card p-4 */
.schema-form {
    width: 560px; max-width: 100%; border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); padding: 16px;
}
.sf-section { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.sf-section:last-child { margin-bottom: 0; }
/* row: grid grid-cols-[120px_1fr] items-center gap-2 */
.sf-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 8px; }
.sf-row.sf-full { grid-column: 1 / -1; }
.sf-label { color: var(--muted-foreground); font-size: 13px; }
.sf-star { color: var(--destructive); }
.sf-ctrl { min-width: 0; }
.sf-input {
    height: 2rem; width: 100%; border: 1px solid var(--input); border-radius: 6px;
    background: var(--card); padding: 0 8px; font-size: 13px; font-family: inherit;
    color: var(--foreground);
}
textarea.sf-input { height: auto; padding: 4px 8px; }
.sf-input:focus { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.sf-input:disabled { opacity: 0.5; }
.sf-input.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.sf-hint { margin: 2px 0 0; font-size: 11px; color: var(--muted-foreground); }
.sf-check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sf-cbgroup {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; max-height: 288px;
    overflow-y: auto; border: 1px solid var(--border); border-radius: 6px;
    background: var(--card); padding: 8px;
}
.sf-trunc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* issues list — mt-2 gap-0.5 text-[12px] text-destructive */
.sf-issues { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--destructive); }
/* submit row — mt-4 flex items-center gap-2 */
.sf-submit { margin-top: 16px; display: flex; align-items: center; gap: 8px; }
/* table editor */
.sf-table { display: flex; flex-direction: column; gap: 4px; grid-column: 1 / -1; }
.sf-rowcard {
    display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 8px;
    border: 1px solid var(--border); border-radius: 6px; padding: 8px;
}
.sf-rowcol { display: flex; flex-direction: column; gap: 4px; }
.sf-remove { font-size: 11px; color: var(--destructive); cursor: pointer; }

/* ============ DocList ============ */
.doclist { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.doclist table { width: 100%; font-size: 13px; border-collapse: collapse; }
.doclist thead tr {
    border-bottom: 1px solid var(--border);
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.025em;
    color: var(--muted-foreground);
}
.doclist th { padding: 8px 0.75rem; font-weight: 500; }
.doclist tbody tr { height: 2rem; border-bottom: 1px solid var(--border); }
.doclist tbody tr:last-child { border-bottom: none; }
.doclist tbody tr:hover { background: color-mix(in oklab, var(--accent) 50%, transparent); }
.doclist tbody tr.clickable { cursor: pointer; }
.doclist td { padding: 4px 0.75rem; }
.doclist td.actions { text-align: right; padding: 4px 6px; }
.doclist .empty { padding: 24px 0.75rem; text-align: center; color: var(--muted-foreground); }
.doclist .loading { padding: 24px 0.75rem; text-align: center; color: var(--muted-foreground); }
.rowbtn {
    margin-left: 4px; border: 1px solid var(--border); border-radius: 6px;
    padding: 2px 8px; font-size: 11px; background: none; cursor: pointer; color: var(--foreground);
    display: inline-block; font-family: inherit;
}
.rowbtn:hover { background: var(--accent); }
.rowbtn-danger { color: var(--destructive); }

/* ============ page patterns ============ */
.page-col { display: flex; flex-direction: column; gap: 0.75rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
h1.page-title { font-size: 15px; font-weight: 600; margin: 0; }
.btn-new {
    display: inline-flex; align-items: center; border-radius: 6px;
    background: var(--primary); color: var(--primary-foreground);
    padding: 6px 12px; font-size: 12px; font-weight: 500; cursor: pointer; border: none;
    font-family: inherit;
}
.btn-new:hover { opacity: 0.9; }
.list-count { font-size: 11px; color: var(--muted-foreground); }

/* workspace link cards */
.link-card {
    display: inline-flex; border: 1px solid var(--border); border-radius: 6px;
    background: var(--card); padding: 8px 12px; font-size: 13px;
}
.link-card:hover { background: var(--accent); }

.err { font-size: 12px; color: var(--destructive); }

/* ============ drives page (cards) ============ */
.drive-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.drive-card {
    width: 340px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); padding: 12px;
}
.drive-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.drive-head strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-email { font-size: 11px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
.quota-bar { height: 8px; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.quota-fill { height: 100%; border-radius: 9999px; background: var(--primary); transition: width 150ms; }
.quota-text { font-size: 11px; color: var(--muted-foreground); margin-top: 4px; }
.drive-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ============ auth (login card) ============ */
.auth-wrap { display: flex; height: 100vh; width: 100vw; align-items: center; justify-content: center; background: var(--background); }
.auth-card { width: 360px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); padding: 20px; }
.auth-card h1 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.auth-card .sub { font-size: 12px; color: var(--muted-foreground); margin: 0 0 16px; }
.auth-card .errbox {
    margin-top: 12px; border: 1px solid var(--destructive); border-radius: 6px;
    padding: 6px 8px; font-size: 12px; color: var(--destructive);
}

/* ============ CommandPalette ============ */
.palette-overlay {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start;
    justify-content: center; background: rgba(0, 0, 0, 0.4); padding-top: 15vh;
}
.palette-panel {
    width: 480px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px;
    background: var(--popover); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
.palette-head { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 0 0.75rem; }
.palette-head input {
    height: 2.5rem; flex: 1; background: transparent; border: none; outline: none;
    font-size: 13px; font-family: inherit; color: var(--foreground);
}
.palette-list { max-height: 320px; overflow: auto; padding: 4px 0; }
.palette-item {
    display: flex; width: 100%; align-items: center; justify-content: space-between;
    padding: 6px 12px; text-align: left; font-size: 13px; background: none; border: none;
    color: var(--foreground); cursor: pointer; font-family: inherit;
}
.palette-item.active { background: var(--accent); }
.palette-item .grp { font-size: 11px; color: var(--muted-foreground); }
.palette-empty { padding: 24px 12px; text-align: center; font-size: 12px; color: var(--muted-foreground); }

/* ============ SchemaForm ============ */
.schema-form {
    width: 560px; max-width: 100%; border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); padding: 16px;
}
.sf-section { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.sf-section:last-child { margin-bottom: 0; }
.sf-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 8px; }
.sf-row.sf-full { grid-column: 1 / -1; }
.sf-label { color: var(--muted-foreground); font-size: 13px; }
.sf-star { color: var(--destructive); }
.sf-ctrl { min-width: 0; }
.sf-input {
    height: 2rem; width: 100%; border: 1px solid var(--input); border-radius: 6px;
    background: var(--card); padding: 0 8px; font-size: 13px; font-family: inherit;
    color: var(--foreground);
}
textarea.sf-input { height: auto; padding: 4px 8px; }
.sf-input:focus { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.sf-input:disabled { opacity: 0.5; }
.sf-input.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.sf-hint { margin: 2px 0 0; font-size: 11px; color: var(--muted-foreground); }
.sf-check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sf-cbgroup {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; max-height: 288px;
    overflow-y: auto; border: 1px solid var(--border); border-radius: 6px;
    background: var(--card); padding: 8px;
}
.sf-trunc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-issues { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--destructive); }
.sf-submit { margin-top: 16px; display: flex; align-items: center; gap: 8px; }
.sf-table { display: flex; flex-direction: column; gap: 4px; grid-column: 1 / -1; }
.sf-rowcard {
    display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 8px;
    border: 1px solid var(--border); border-radius: 6px; padding: 8px;
}
.sf-rowcol { display: flex; flex-direction: column; gap: 4px; }
.sf-remove { font-size: 11px; color: var(--destructive); cursor: pointer; }
.sf-remove:hover { text-decoration: underline; }
.sf-add { align-self: flex-start; font-size: 12px; color: var(--primary); background: none; border: none; cursor: pointer; font-family: inherit; padding: 0; }
.sf-add:hover { text-decoration: underline; }

/* ============ upload queue (odrive-specific, same tokens) ============ */
/* upload panel — fixed right rail (left panel = organizer) */
.files-organizer { min-width: 0; }
.upanel[hidden] { display: none; }
.upanel {
    position: fixed; top: 12px; right: 12px; bottom: 12px; width: 300px; z-index: 40;
    display: flex; flex-direction: column; gap: 8px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--card);
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%); padding: 12px;
}
.upanel-head { display: flex; align-items: center; justify-content: space-between; }
.upanel-head strong { font-size: 13px; }
.upanel-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; flex: 1; }
.upanel-list:empty::after { content: 'All done.'; color: var(--muted-foreground); font-size: 12px; }
.queue-item { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.queue-item .q-top { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.queue-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.queue-item .qsize { color: var(--muted-foreground); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.queue-item .q-mid { display: flex; gap: 8px; align-items: center; }
.queue-item .pct { width: 84px; text-align: right; color: var(--muted-foreground); flex-shrink: 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.queue-item .bar { flex: 1; height: 3px; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.queue-item .bar > div { height: 100%; width: 0; background: var(--primary); border-radius: 9999px; transition: width 200ms; }
.queue-item .q-msg { white-space: normal; word-break: break-word; color: var(--muted-foreground); font-size: 11px; line-height: 1.4; }
.queue-item.error .q-msg { color: var(--destructive); }
.queue-item.error .name { color: var(--destructive); }
.queue-item.done .pct { color: var(--foreground); }
@media (max-width: 900px) {
    .upanel { position: static; width: auto; margin-top: 8px; max-height: 40vh; box-shadow: none; }
}
#upanel-pill {
    position: fixed; right: 14px; bottom: 14px; z-index: 50;
    display: flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    border-radius: 9999px; border: 1px solid var(--border); background: var(--card); color: var(--foreground);
    cursor: pointer; box-shadow: 0 4px 10px rgb(0 0 0 / 20%);
}
#upanel-pill:hover { background: var(--accent); }
#upanel-pill .pill-badge {
    position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 9999px; background: var(--primary); color: var(--primary-foreground);
    font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
#upanel-pill[hidden] { display: none; }
.upanel-btns { display: flex; gap: 6px; }
.queue-item.activity .pct { width: auto; }
.queue-item.activity.done .name { color: var(--success); }

/* ============ toast (SPA feedback) ============ */
#toast-wrap { position: fixed; bottom: 58px; right: 12px; z-index: 60; display: flex; flex-direction: column; gap: 8px; } /* above the upanel pill */
.toast {
    border: 1px solid var(--border); border-radius: 8px; background: var(--popover);
    padding: 8px 12px; font-size: 12px; color: var(--popover-foreground);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); max-width: 380px;
}
.toast.ok { border-color: color-mix(in oklab, var(--success) 45%, transparent); }
.toast.err { border-color: color-mix(in oklab, var(--destructive) 45%, transparent); color: var(--destructive); }

/* ============ drive toggle switch (no svelte-erp precedent — token-derived pill) ============ */
.switch {
    position: relative; display: inline-block; width: 36px; height: 20px;
    flex-shrink: 0; background: none; padding: 0; border: none; cursor: pointer;
}
.switch .track {
    position: absolute; inset: 0; border-radius: 9999px;
    background: var(--muted); transition: background-color 150ms;
}
.switch .knob {
    position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 9999px; background: var(--card); transition: transform 150ms;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
}
.switch.on .track { background: var(--primary); }
.switch.on .knob { transform: translateX(16px); }
.switch:focus-visible { outline: none; }
.switch:focus-visible .track { box-shadow: 0 0 0 2px var(--ring); }
.badge-inactive { border-color: transparent; color: var(--muted-foreground); }

/* capacity editor */
.cap-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; color: var(--muted-foreground); }
.cap-input { width: 72px; height: 24px; border: 1px solid var(--input); border-radius: 6px; background: var(--card); padding: 0 6px; font-size: 12px; font-family: inherit; color: var(--foreground); }
.cap-input:focus { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.cap-hint { font-size: 10px; }
.drive-meta { font-size: 11px; color: var(--muted-foreground); margin-top: 4px; }

/* ============ dropzone (files table card) ============ */
.dropzone-active { outline: 2px dashed var(--primary); outline-offset: -6px; }
.dropzone-active .doclist { opacity: 0.5; }
.dz-hint { font-size: 12px; color: var(--muted-foreground); padding: 4px 0; }

/* ============ file explorer (crumbs, folders, thumbs, moves) ============ */
.crumbs-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.file-crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-height: 28px; padding: 2px 6px; border-radius: 6px; }
.file-crumbs.drop-target { outline: 2px dashed var(--primary); }
.crumb { background: none; border: none; font: inherit; color: var(--muted-foreground); cursor: pointer; padding: 2px 6px; border-radius: 5px; }
.crumb:hover { background: var(--accent); color: var(--foreground); }
.crumb.cur { color: var(--foreground); font-weight: 500; }
.crumb-sep { color: var(--muted-foreground); font-size: 11px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.doclist th.num, .doclist td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.folder-row { cursor: pointer; }
tr.folder-row .fname { color: var(--foreground); }
tr.folder-row.drop-target { outline: 2px dashed var(--primary); outline-offset: -2px; }
tr.folder-row:hover { background: var(--accent); }
.thumb { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: 2px; }
.ficon { display: inline-block; width: 26px; text-align: center; font-size: 13px; line-height: 26px; }
.drag-over { outline: 2px dashed var(--primary); outline-offset: -6px; }

/* ============ settings page ============ */
.card { border: 1px solid var(--border); border-radius: 8px; background: var(--card); padding: 16px; margin-bottom: 14px; }
.section-title { font-size: 14px; margin: 0 0 10px; }
.key-create { display: flex; gap: 8px; margin: 10px 0; }
.key-once { margin: 8px 0; padding: 10px; border: 1px solid var(--primary); border-radius: 6px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.key-plain { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; user-select: all; padding: 4px 6px; background: var(--muted); border-radius: 4px; }

/* ============ admin limits cell ============ */
.limits-cell { display: flex; gap: 8px; align-items: center; }
span.switch { display: inline-flex; }
.limits-col { white-space: nowrap; }

/* multi-select rows */
tr[data-id].sel { background: color-mix(in oklab, var(--primary) 14%, transparent); }
tr[data-id].sel .fname { color: var(--foreground); }
tr[data-id].sel:hover { background: color-mix(in oklab, var(--primary) 20%, transparent); }

/* multi-select delete btn + preview overlay */
.btn-danger-outline { color: var(--destructive); border-color: var(--destructive); }
tr.folder-row.sel { background: color-mix(in oklab, var(--primary) 14%, transparent); }
tr.folder-row.sel .fname { color: var(--foreground); }
tr.folder-row.sel:hover { background: color-mix(in oklab, var(--primary) 20%, transparent); }
.preview-ov { position: fixed; inset: 0; z-index: 220; background: rgba(8, 12, 20, 0.82); display: flex; align-items: center; justify-content: center; }
.preview-box { position: relative; max-width: min(92vw, 1100px); max-height: 88vh; display: flex; flex-direction: column; gap: 8px; }
.preview-box img, .preview-box video { max-width: 100%; max-height: 80vh; border-radius: 10px; background: #000; }
.preview-close { position: absolute; top: -14px; right: -14px; width: 32px; height: 32px; border-radius: 50%; border: none; background: #fff; color: #111; font-size: 15px; cursor: pointer; z-index: 2; }
.preview-name { color: #e8eef7; text-align: center; font-size: 13px; padding: 4px 10px; background: rgba(0,0,0,0.5); border-radius: 6px; align-self: center; }

/* drag-n-drop page-wide hint + centered search in page head */
#drop-hint { position: fixed; inset: 0; z-index: 200; pointer-events: none; outline: 3px dashed var(--primary); outline-offset: -10px; background: color-mix(in oklab, var(--primary) 6%, transparent); display: flex; align-items: center; justify-content: center; }
#drop-hint[hidden] { display: none; }
.drop-hint-card { pointer-events: none; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 26px; font-size: 14px; color: var(--foreground); box-shadow: 0 10px 30px rgba(0,0,0,0.25); display: flex; gap: 10px; align-items: center; }
.drop-hint-ico { font-size: 18px; color: var(--primary); }
.page-head #file-search { flex: 1; max-width: 560px; margin: 0 auto; }

/* always-visible drop area (Files page) */
.drop-area { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--border); border-radius: 10px; padding: 26px 16px; margin: 14px 0 14px; cursor: pointer; background: color-mix(in oklab, var(--primary) 3%, var(--card)); transition: border-color 120ms, background 120ms; text-align: center; }
.drop-area:hover, .drop-area:focus-visible { border-color: var(--primary); background: color-mix(in oklab, var(--primary) 7%, var(--card)); outline: none; }
.drop-area .drop-ico { font-size: 22px; color: var(--primary); }
.drop-area .drop-txt { font-size: 14px; font-weight: 600; color: var(--foreground); }
.drop-area .drop-sub { font-size: 12px; color: var(--muted-foreground); }
.drop-area .drop-browse { color: var(--primary); font-weight: 500; }

/* automation.tantua.com — run status badges */
.badge.run-success{background:#1f6f43;color:#fff}
.badge.run-failed{background:#b3362c;color:#fff}
.badge.run-running{background:#b58a2c;color:#fff}
.badge.run-queued{background:#4a6fa5;color:#fff}
.badge.run-abandoned{background:#777;color:#fff}
