/*
 * Bento Rail theme: Bento tiles with a dark navigation rail on the left that collapses to icons
 * (default) or expands to icons with labels. <html data-theme="rail" data-rail="collapsed|expanded">.
 * Loaded after themes.css.
 */
html[data-theme="rail"] {
    --bg: #edf1ee; --surface: #ffffff; --text: #10231a; --muted: #4f6559; --border: #dfe7e2;
    --accent: #047857; --accent-text: #ffffff; --accent-soft: #d1fae5; --danger: #b91c3c;
    --ok: #047857; --ok-soft: #d1fae5; --warn: #92400e; --warn-soft: #fef3c7; --radius: 24px;
    --rail-bg: #10231a; --rail-text: #b7cdc1; --rail-active: #10b981; --rail-active-text: #052e1f; --primary-bg: #10231a; --primary-text: #ffffff;
    --font: "Manrope", system-ui, sans-serif; color-scheme: light;
}
html[data-theme="rail"][data-mode="dark"] {
    --bg: #111315; --surface: #1a1d21; --text: #e8eaed; --muted: #9aa1a9; --border: #2a2f35;
    --accent: #34d399; --accent-text: #052e1f; --accent-soft: #163328; --danger: #fb7185;
    --ok: #34d399; --ok-soft: #163328; --warn: #fbbf24; --warn-soft: #3a2c10;
    --rail-bg: #0b0c0e; --rail-text: #9aa1a9; --rail-active: #34d399; --rail-active-text: #052e1f; --primary-bg: #34d399; --primary-text: #052e1f; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="rail"][data-mode="auto"] {
        --bg: #111315; --surface: #1a1d21; --text: #e8eaed; --muted: #9aa1a9; --border: #2a2f35;
        --accent: #34d399; --accent-text: #052e1f; --accent-soft: #163328; --danger: #fb7185;
        --ok: #34d399; --ok-soft: #163328; --warn: #fbbf24; --warn-soft: #3a2c10;
        --rail-bg: #0b0c0e; --rail-text: #9aa1a9; --rail-active: #34d399; --rail-active-text: #052e1f; --primary-bg: #34d399; --primary-text: #052e1f; color-scheme: dark;
    }
}

/* Icons and the toggle exist in every theme's markup; only Bento Rail shows the toggle. */
.nav-icon { width: 20px; height: 20px; flex: none; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; }
.rail-toggle { display: none; }
html:not([data-theme="rail"]) .nav-icon { display: none; }

/* ===== Shell ===== */
html[data-theme="rail"] .shell { grid-template-columns: 96px minmax(0, 1fr); gap: 18px; padding: 18px; min-height: calc(100vh - 36px); }
html[data-theme="rail"][data-rail="expanded"] .shell { grid-template-columns: 236px minmax(0, 1fr); }
html[data-theme="rail"] .sidebar {
    background: var(--rail-bg); color: var(--rail-text); border: 0; border-radius: 28px; padding: 18px 8px;
    top: 18px; height: calc(100vh - 36px); align-items: stretch; gap: 10px; transition: width .2s;
}
html[data-theme="rail"] .brand { color: #ffffff; justify-content: center; font-size: 1rem; }
html[data-theme="rail"] .brand-mark { color: #ffffff; }
html[data-theme="rail"] .brand-name { display: none; }
/* The rail's white logo is for the dark sidebar; error pages show it on a light card. */
html[data-theme="rail"] .error-card .brand { color: var(--text); justify-content: flex-start; font-size: 1.15rem; display: flex; }
html[data-theme="rail"] .error-card .brand-mark { color: var(--accent); }
/* Twelve grouped items fit a laptop screen; on a very short window the list scrolls and rail.js fades the edge that has more. */
html[data-theme="rail"] .sidebar nav { gap: 2px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .2) transparent; }
html[data-theme="rail"] .sidebar nav a {
    color: var(--rail-text); border-radius: 16px; padding: 6px 2px; flex-direction: column; gap: 3px;
    font-size: .7rem; font-weight: 700; text-align: center; line-height: 1.15;
}
/* Collapsed: labels wrap at spaces ("Landing / pages"); a single word longer than the rail (Dutch
   "Automatiseringen") breaks inside the word, so every label stays readable in full. */
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar nav { min-width: 0; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar nav a { min-width: 0; max-width: 100%; padding: 4px 2px; gap: 2px; font-size: .66rem; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .nav-icon { width: 18px; height: 18px; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar nav .nav-label { display: block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; hyphens: auto; }
html[data-theme="rail"] .sidebar nav a.active { background: var(--rail-active); color: var(--rail-active-text); }
html[data-theme="rail"] .sidebar nav a:not(.active):hover { background: rgb(255 255 255 / .08); color: #ffffff; }
/* Groups: a thin divider in the collapsed rail, a small heading when expanded. */
html[data-theme="rail"] .sidebar .nav-main { gap: 4px; flex: 0 1 auto; }
html[data-theme="rail"] .nav-group { gap: 2px; }
html[data-theme="rail"] .nav-group + .nav-group { border-top: 1px solid rgb(255 255 255 / .1); padding-top: 4px; }
html[data-theme="rail"] .nav-group-label { display: none; color: var(--rail-text); opacity: .75; }
html[data-theme="rail"] .sidebar .nav-footer { overflow: visible; flex: none; margin-top: auto; }
/* Collapsed: Help and Support side by side, and the expand button next to the profile menu, so every item fits a laptop screen. */
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .nav-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .nav-footer a { padding: 4px 0; font-size: .6rem; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .nav-footer .nav-label { white-space: nowrap; overflow-wrap: normal; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar { gap: 6px; }
/* Expanded: Help and Support share a row, and the collapse button sits next to the profile menu. */
html[data-theme="rail"][data-rail="expanded"] .sidebar .nav-footer { display: flex; flex-direction: row; gap: 2px; }
html[data-theme="rail"][data-rail="expanded"] .sidebar .nav-footer a { gap: 8px; padding-left: 10px; padding-right: 10px; }
html[data-theme="rail"][data-rail="expanded"] .sidebar-foot { flex-direction: row-reverse; align-items: center; gap: 6px; }
html[data-theme="rail"][data-rail="expanded"] .sidebar-foot .profile-menu { flex: 1; }
html[data-theme="rail"][data-rail="expanded"] .sidebar-foot .rail-toggle-label { display: none; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .nav-footer .nav-dot { position: absolute; margin: 0 0 0 14px; }
html[data-theme="rail"] .sidebar .nav-footer a { position: relative; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar-foot { flex-direction: row; justify-content: center; align-items: center; gap: 4px; }
html[data-theme="rail"]:not([data-rail="expanded"]) .rail-toggle { min-width: 36px; padding: 8px 6px; }
/* The profile menu: the initial in the collapsed rail, the name next to it when expanded. */
html[data-theme="rail"] .profile-menu summary { justify-content: center; color: var(--rail-text); }
html[data-theme="rail"] .profile-menu summary:hover, html[data-theme="rail"] .profile-menu[open] summary { background: rgb(255 255 255 / .1); color: #ffffff; }
html[data-theme="rail"] .profile-menu[data-active] summary { background: var(--rail-active); color: var(--rail-active-text); }
html[data-theme="rail"] .profile-initial { background: rgb(255 255 255 / .9); color: var(--rail-bg); }
html[data-theme="rail"]:not([data-rail="expanded"]) .profile-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[data-theme="rail"] .sidebar .profile-panel nav a { flex-direction: row; font-size: .9rem; font-weight: 600; text-align: left; padding: 8px 10px; border-radius: 10px; color: var(--text); }
html[data-theme="rail"] .sidebar .profile-panel nav a.active { background: var(--accent-soft); color: var(--accent); }
html[data-theme="rail"] .sidebar .profile-panel nav a:not(.active):hover { background: var(--accent-soft); color: var(--accent); }
html[data-theme="rail"] .profile-panel .nav-icon { display: block; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .profile-panel nav a { gap: 10px; font-size: .9rem; padding: 8px 10px; }
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .profile-panel .nav-icon { width: 20px; height: 20px; }
html[data-theme="rail"] .rail-toggle {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; align-self: center;
    font: inherit; font-size: .75rem; font-weight: 700; color: var(--rail-text); background: rgb(255 255 255 / .06);
    border: 0; border-radius: 12px; padding: 8px 10px; cursor: pointer; min-height: 40px; min-width: 44px;
}
html[data-theme="rail"] .rail-toggle:hover { color: #ffffff; background: rgb(255 255 255 / .12); }
html[data-theme="rail"] .rail-toggle svg { transition: transform .2s; }
html[data-theme="rail"] .rail-toggle-label { display: none; }

/* Expanded: icons with labels in a row, brand name visible. */
html[data-theme="rail"][data-rail="expanded"] .sidebar { padding: 18px 14px; }
html[data-theme="rail"][data-rail="expanded"] .brand { justify-content: flex-start; padding: 0 6px; }
html[data-theme="rail"][data-rail="expanded"] .brand-name { display: inline; }
html[data-theme="rail"][data-rail="expanded"] .sidebar nav a { flex-direction: row; gap: 12px; font-size: .92rem; font-weight: 600; text-align: left; padding: 8px 12px; }
html[data-theme="rail"][data-rail="expanded"] .rail-toggle { padding: 8px 10px; }
html[data-theme="rail"][data-rail="expanded"] .rail-toggle svg { transform: rotate(180deg); }
html[data-theme="rail"][data-rail="expanded"] .rail-toggle-label { display: inline; }
html[data-theme="rail"][data-rail="expanded"] .nav-group-label { display: block; padding: 2px 12px 0; }
html[data-theme="rail"][data-rail="expanded"] .nav-group + .nav-group { border-top: 0; padding-top: 0; }
html[data-theme="rail"][data-rail="expanded"] .profile-menu summary { justify-content: flex-start; }

/* ===== Content: Bento tiles ===== */
/* The shell already pads the page; the content column is centred on wide screens like every theme. */
html[data-theme="rail"] .main { padding: 6px clamp(4px, 1.6vw, 24px) 48px; max-width: calc(var(--page-max) + 48px); }
html[data-theme="rail"] .main[data-page="mid"] { max-width: calc(var(--page-mid) + 48px); }
html[data-theme="rail"] .main[data-page="form"] { max-width: calc(var(--page-form) + 48px); }
html[data-theme="rail"] .main[data-page="read"] { max-width: calc(var(--page-read) + 48px); }
html[data-theme="rail"] .card, html[data-theme="rail"] .stat { border: 0; box-shadow: 0 1px 2px rgb(16 35 26 / .05); }
html[data-theme="rail"] .stat { padding: 22px; border-radius: var(--radius); }
html[data-theme="rail"] .stat strong { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; }
/* Emphasis follows meaning, not position: views mark the one headline metric with .stat-key (never a bounce or exit rate). */
html[data-theme="rail"] .stats .stat-key { background: var(--rail-bg); color: #ffffff; }
html[data-theme="rail"] .stats .stat-key span, html[data-theme="rail"] .stats .stat-key small { color: var(--rail-text); }
html[data-theme="rail"] .btn { border-radius: 999px; }
html[data-theme="rail"] input[type=file]::file-selector-button { border-radius: 999px; }
html[data-theme="rail"] .btn-primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-text); }
html[data-theme="rail"] input:not([type=checkbox]):not([type=radio]), html[data-theme="rail"] select, html[data-theme="rail"] textarea { border-radius: 14px; }
html[data-theme="rail"] h1 { font-weight: 800; letter-spacing: -.02em; }
html[data-theme="rail"] .tabs { border-bottom: 0; gap: 6px; }
html[data-theme="rail"] .tabs a { border: 0; border-radius: 999px; background: var(--surface); }
html[data-theme="rail"] .tabs a.active { background: var(--rail-bg); color: #ffffff; }
html[data-theme="rail"] .tabs a.active .muted { color: inherit; } /* a count in the filled active tab: --muted is 2.6:1 there */

/* Short laptop windows: the logo repeats Dashboard, so it makes room for the menu. */
@media (max-height: 760px) and (min-width: 821px) {
    html[data-theme="rail"] .brand { display: none; }
    html[data-theme="rail"][data-rail="expanded"] .sidebar nav a { padding-top: 5px; padding-bottom: 5px; }
}

/* Phones: the rail becomes a horizontal bar that scrolls; the toggle is hidden. */
@media (max-width: 820px) {
    html[data-theme="rail"] .shell, html[data-theme="rail"][data-rail="expanded"] .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; padding: 10px; gap: 12px; }
    html[data-theme="rail"] .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-radius: 22px; padding: 10px; }
    html[data-theme="rail"] .sidebar nav { flex-direction: row; display: flex; flex-wrap: nowrap; overflow-x: auto; flex: 1 1 100%; order: 3; }
    html[data-theme="rail"] .sidebar nav a { min-width: 64px; padding: 6px 8px; }
    html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar nav .nav-label { white-space: nowrap; overflow: visible; }
    html[data-theme="rail"] .rail-toggle { display: none; }
    html[data-theme="rail"] .logout { flex-direction: row; margin-left: auto; }
    html[data-theme="rail"] .nav-group + .nav-group { border-top: 0; padding-top: 0; }
    html[data-theme="rail"] .sidebar .nav-footer, html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar .nav-footer, html[data-theme="rail"][data-rail="expanded"] .sidebar .nav-footer { display: none; }
    html[data-theme="rail"] .sidebar .profile-panel nav { display: grid; flex: none; order: 0; overflow: visible; }
    html[data-theme="rail"] .sidebar-foot { flex-direction: row; gap: 6px; }
    html[data-theme="rail"]:not([data-rail="expanded"]) .profile-name { position: static; width: auto; height: auto; clip: auto; }
    html[data-theme="rail"] .main, html[data-theme="rail"] .main[data-page] { padding: 4px clamp(6px, 2vw, 16px) 40px; }
    /* The collapsed rail's narrow items get room for their label again in the top bar. */
    html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar nav a { min-width: 64px; padding: 6px 8px; }
}

/* Theme picker swatch */
.swatch-rail { background: #edf1ee; grid-template-columns: 1fr 3fr; } .swatch-rail i:first-child { background: #10231a; } .swatch-rail i:last-child { background: #ffffff; }
html[data-theme="rail"] .profile-panel .logout { flex-direction: row; justify-content: flex-start; margin: 0; padding: 4px 10px 2px; font-size: .9rem; text-align: left; }
html[data-theme="rail"] .profile-panel .logout .link { color: var(--text); }

/* The light/dark switch sits on the dark rail beside the collapse button. */
html[data-theme="rail"] .sidebar .mode-toggle { color: var(--rail-text); background: rgb(255 255 255 / .06); border-color: transparent; align-self: center; }
html[data-theme="rail"] .sidebar .mode-toggle:hover { color: #ffffff; background: rgb(255 255 255 / .12); }
/* Collapsed rail: the switch and the collapse button share a row, the profile button goes below. */
html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar-foot { flex-wrap: wrap; }
@media (max-width: 820px) {
    html[data-theme="rail"]:not([data-rail="expanded"]) .sidebar-foot { flex-wrap: nowrap; }
}
