/* ThinSweep -- "v2" theme: warm editorial/paper dashboard.
   Deliberately not a dark-mode recolor of the classic theme: different
   nav pattern (icon-only rail instead of a labeled sidebar), different
   page composition (a two-column card grid instead of one long stack),
   different type pairing (serif headings / sans body), different palette
   (warm paper + ink + terracotta instead of cool neutrals + teal). Same
   markup/classes as theme-classic.css throughout. */

:root {
    --bg: #f7f3ec;
    --surface: #fbf8f2;
    --surface-alt: #efe7d8;
    --border: #ddd2b8;
    --text: #211d17;
    --muted-text: #7d7361;
    --accent: #b5502f;
    --accent-hover: #9c4327;
    --accent-soft: #f3e1d5;
    --danger: #a4202a;
    --danger-soft: #f5e1df;
    --success: #3f7d4f;
    --success-soft: #e7ede1;
    --warn: #b8860b;
    --warn-soft: #f5ecd4;
    --radius: 2px;
    --radius-sm: 3px;
    --radius-pill: 999px;
    --shadow: none;

    --sidebar-bg: #211d17;
    --sidebar-text: #f7f3ec;
    --sidebar-muted: #93897a;
    --sidebar-hover: rgba(247, 243, 236, 0.08);
    --sidebar-active-bg: var(--accent);
    --sidebar-border: transparent;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 0.6rem;
}

h1 { font-size: 1.9rem; }

h2 {
    font-size: 1.1rem;
    padding-bottom: 0.55rem;
    margin-bottom: 0.9rem;
    border-bottom: 1px solid var(--border);
}

h3 { font-size: 0.95rem; margin-top: 1.25rem; color: var(--muted-text); font-weight: 700; }

p { line-height: 1.55; }

a { color: var(--accent); }

/* -- Shell: icon rail + topbar + content -------------------------------- */

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

.sidebar {
    width: 68px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0 1.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
}

.brand-icon { height: 1.6em; width: 1.6em; }
.brand-name { display: none; }

.side-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
}

.side-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-pill);
    color: var(--sidebar-muted);
    text-decoration: none;
    border-left: none;
}

.side-nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.side-nav a span { display: none; }

.side-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.side-nav a.active {
    background: var(--sidebar-active-bg);
    color: #fff;
}

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

.topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 2rem;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.topbar-user { font-size: 0.83rem; color: var(--muted-text); }

.theme-toggle, .logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    color: var(--muted-text);
    border: 1px solid transparent;
    padding: 0.4rem 0.85rem;
    margin: 0;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 500;
}

.theme-toggle svg, .logout-btn svg { width: 15px; height: 15px; }

.theme-toggle:hover, .logout-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.logout-form { margin: 0; }

main {
    max-width: 1040px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 2rem 3rem;
}

.unauth-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
}

.unauth-main .card { width: 100%; max-width: 380px; }

/* -- Page grid: device/group detail become a two-column dashboard --------
   CSS multi-column, not CSS Grid -- a real grid pairs cards into fixed
   rows sized to the tallest cell in that row, so a short card next to a
   long one (e.g. "Group" next to "Session config") gets stranded at the
   top of an oversized row with a big empty gap below it. Multi-column
   flows each card into whichever column is shortest so far, so a long
   card just makes its own column taller instead of warping its row
   partner's layout. */

.page-grid {
    column-count: 2;
    column-gap: 1.5rem;
}

.page-grid > .card {
    break-inside: avoid;
}

.page-grid > .card:first-child {
    column-span: all;
}

@media (max-width: 780px) {
    .page-grid { column-count: 1; }
}

/* -- Cards / tables / forms -------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

th, td {
    text-align: left;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.87rem;
}

th {
    background: var(--surface-alt);
    font-weight: 700;
    color: var(--muted-text);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

th a { color: var(--text); text-decoration: none; font-weight: 700; }
th a:hover { color: var(--accent); }

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-alt); }

a.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
a.row-link:hover { color: var(--accent); }

label {
    display: block;
    margin: 0.85rem 0 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted-text);
}

input[type="text"], input[type="url"], input[type="email"], input[type="password"], input[type="file"],
select, textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

textarea {
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    min-height: 100px;
    font-size: 0.83rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.checkbox-row label { margin: 0; }

.actions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.actions-row form { margin: 0; }
.actions-row button { margin: 0; }

.filter-bar { margin-bottom: 1.25rem; }
.filter-bar select { width: auto; }

button, .button {
    background: var(--accent);
    color: #fdfbf7;
    border: 1px solid var(--accent);
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-pill);
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    margin-right: 0.5rem;
}

button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }

.status-ok { color: var(--success); font-weight: 700; }
.status-stale { color: var(--danger); font-weight: 700; }

.muted { color: var(--muted-text); font-size: 0.85rem; }

.error {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.pill {
    display: inline-block;
    padding: 0.15rem 0.65rem;
    border-radius: var(--radius-pill);
    background: var(--surface-alt);
    color: var(--muted-text);
    font-size: 0.75rem;
    font-weight: 600;
}

.pill-success { background: var(--success-soft); color: var(--success); }
.pill-failed { background: var(--danger-soft); color: var(--danger); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }

/* -- Policy example widget --------------------------------------------- */

.policy-examples { margin-top: 0.5rem; }
.policy-examples select { margin-bottom: 0.35rem; }

/* -- Tabs (Releases / Artifacts) ---------------------------------------- */

.tab-buttons {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.tab-button {
    background: transparent;
    color: var(--muted-text);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    margin: 0 0 -1px;
    padding: 0.6rem 0.25rem;
    margin-right: 1.5rem;
    font-weight: 600;
    font-size: 0.92rem;
    font-family: Georgia, "Iowan Old Style", serif;
}

.tab-button:hover { background: transparent; color: var(--text); }

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-panel[hidden] { display: none; }
