:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #eef2f7;
    --text: #1c2430;
    --muted: #5b6b7c;
    --primary: #2b5a95;
    --primary-dark: #1e3e6a;
    --border: #d5dee9;
    --radius: 14px;
    --shadow: 0 14px 30px rgba(16, 24, 40, 0.08);
    --max-width: 1100px;
    --space-xs: 6px;
    --space-sm: 12px;
    --space-md: 18px;
    --space-lg: 28px;
    --space-xl: 40px;
    --sidebar-width: 220px;
    --button-radius: 8px;
    --form-control-max: 520px;
    --header-bg: linear-gradient(120deg, #1b2432, #28364a);
    --header-text: #f7f9fc;
    --header-link: #dfe6f3;
    --header-link-hover: #ffffff;
    --header-muted: #c6d1e6;
    --brand-mark: var(--primary-dark);
    font-family: "Inter", "Avenir Next", "Noto Sans", sans-serif;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #101622;
    --surface: #1a2232;
    --surface-muted: #222b3d;
    --text: #eef3ff;
    --muted: #b4c0d2;
    --primary: #6ea3ff;
    --primary-dark: #8bb4ff;
    --border: #2c3a52;
    --shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    --header-bg: linear-gradient(120deg, #0f1622, #1a2536);
    --header-text: #eef3ff;
    --header-link: #cdd8eb;
    --header-link-hover: #ffffff;
    --header-muted: #cdd8eb;
    --brand-mark: #8bb4ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.page {
    min-height: 100vh;
}

.page.has-sidebar {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.page.has-sidebar.sidebar-collapsed {
    grid-template-columns: 76px minmax(0, 1fr);
}



.content-area {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content-inner {
    width: 100%;
    margin: 0 auto;
    padding: 0 28px;
}

.main-content {
    min-width: 0;
    flex: 1;
}

.site-header,
.site-footer {
    border-bottom: 1px solid var(--border);
}

.site-header {
    background: var(--header-bg);
    color: var(--header-text);
}

.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: none;
    margin-top: auto;
}

.site-header .content-inner,
.site-footer .content-inner {
    display: flex;
    align-items: center;
    height: 56px;
}

.site-header .content-inner {
    justify-content: space-between;
}

.site-footer .content-inner {
    justify-content: space-between;
}

.footer-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--muted);
}

.footer-links {
    display: inline-flex;
    gap: 16px;
}

.footer-links a {
    color: var(--muted);
}

.footer-links a:hover {
    color: var(--text);
    text-decoration: none;
}

.footer-build {
    font-size: 0.85rem;
    color: var(--muted);
    letter-spacing: 0.01em;
}

.brand {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: inline-block;
    color: var(--brand-mark);
    fill: currentColor;
}

.brand-text {
    white-space: nowrap;
    font-weight: 800;
}

.nav a {
    margin-left: 16px;
    font-weight: 500;
    color: var(--header-link);
    line-height: 1.2;
}

.nav a:hover {
    color: var(--header-link-hover);
    text-decoration: none;
}

.nav-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-left: 12px;
    color: var(--header-link);
}

.nav-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--header-link-hover);
    text-decoration: none;
}

.nav-icon-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5f57;
    border: 2px solid #1b2432;
}

[data-theme="dark"] .nav-icon-dot {
    border-color: #0f1622;
}

.nav form {
    display: inline-block;
    margin-left: 12px;
}

.nav details {
    display: inline-block;
    margin-left: 12px;
    position: relative;
}

.nav summary {
    list-style: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--header-link);
    line-height: 1.2;
}

.nav summary::-webkit-details-marker {
    display: none;
}

.nav-menu-panel {
    position: absolute;
    right: 0;
    top: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    min-width: 180px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 6px;
    z-index: 10;
}

.nav-menu-panel a {
    color: var(--text);
    padding: 6px 8px;
    border-radius: 8px;
    margin-left: 0;
    font-weight: 500;
    line-height: 1.2;
    display: block;
}

.nav-menu-panel a:hover {
    background: var(--surface-muted);
    color: var(--text);
    text-decoration: none;
}

.nav-menu-form button {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--text);
    padding: 6px 8px;
    border-radius: var(--button-radius);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.nav .nav-menu-form {
    margin-left: 0;
}

.nav-menu-form button:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.nav-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}

.nav-user {
    margin-left: 16px;
    color: var(--header-muted);
    font-weight: 600;
}

.nav-user-menu summary {
    list-style: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--header-link);
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 5px 8px;
    border-radius: 20px;
    border: 1px solid transparent;
}

.nav-user-menu summary::-webkit-details-marker {
    display: none;
}

.nav-user-menu[open] summary {
    background: rgba(223, 230, 243, 0.12);
    border-color: rgba(223, 230, 243, 0.35);
}

.nav-user-name {
    color: var(--header-muted);
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dfe6f3;
    color: #1f2e45;
    border: 1px solid rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.nav-chevron {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--header-muted);
}

.nav-user-menu[open] .nav-chevron {
    border-top-color: var(--header-link-hover);
}

.nav-user-menu .nav-menu-panel {
    top: calc(100% + 8px);
}

.hero {
    padding: 48px 0 0;
}

.hero h1 {
    font-size: clamp(1.9rem, 2.2vw, 2.6rem);
    margin-bottom: 12px;
}

h1 {
    font-weight: 600;
}

h2 {
    margin: 0;
}

.card {
    margin-top: 28px;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-muted {
    margin-top: 16px;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    min-height: 44px;
    max-width: var(--form-control-max);
    border-radius: var(--button-radius);
    background: var(--primary);
    color: #fff;
    font-weight: 400;
    border: none;
    cursor: pointer;
}

.button:hover {
    text-decoration: none;
    filter: brightness(0.96);
}

.button-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.button-ghost:hover {
    color: var(--text);
    border-color: var(--primary);
    background: var(--surface-muted);
}

.button-ghost:disabled,
.button-ghost[disabled] {
    color: var(--muted);
    border-color: var(--border);
    background: transparent;
    opacity: 0.6;
    cursor: not-allowed;
}

[data-theme="dark"] .button-ghost {
    color: #dfe6f3;
    border-color: rgba(223, 230, 243, 0.4);
}

[data-theme="dark"] .button-ghost:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .button-ghost:disabled,
[data-theme="dark"] .button-ghost[disabled] {
    color: rgba(223, 230, 243, 0.6);
    border-color: rgba(223, 230, 243, 0.3);
    background: transparent;
    opacity: 0.6;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.badge-primary {
    background: #e0ecfb;
    color: var(--primary-dark);
}

.badge-muted {
    background: rgba(110, 128, 157, 0.12);
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

ul {
    padding-left: 20px;
}

.form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.form label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.form label.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.form label.checkbox input {
    margin: 0;
    width: 18px;
    height: 18px;
    max-width: none;
}

.form input,
.form select {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
    background: #fff;
    width: 100%;
    max-width: var(--form-control-max);
}

.form input[type="date"],
input[type="date"] {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
    height: 44px;
    line-height: 1.4;
}

.form input[type="date"]:focus,
input[type="date"]:focus {
    outline: 2px solid rgba(43, 90, 149, 0.3);
    border-color: rgba(43, 90, 149, 0.6);
}

.form select,
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #5b6b7c 50%),
        linear-gradient(135deg, #5b6b7c 50%, transparent 50%),
        linear-gradient(to right, #d5dee9, #d5dee9);
    background-position: calc(100% - 18px) 50%,
        calc(100% - 13px) 50%,
        calc(100% - 2.5rem) 50%;
    background-size: 6px 6px, 6px 6px, 1px 1.4em;
    background-repeat: no-repeat;
    padding-right: 44px;
    padding-left: 16px;
    min-width: 140px;
    height: 44px;
    line-height: 1.4;
    color: var(--text);
    background-color: var(--surface);
    width: 100%;
    max-width: var(--form-control-max);
}

.form input:focus,
.form select:focus {
    outline: 2px solid rgba(43, 90, 149, 0.3);
    border-color: rgba(43, 90, 149, 0.6);
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.field-inline {
    display: grid;
    gap: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
}

.form-inline select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #5b6b7c 50%),
        linear-gradient(135deg, #5b6b7c 50%, transparent 50%),
        linear-gradient(to right, #d5dee9, #d5dee9);
    background-position: calc(100% - 18px) 50%,
        calc(100% - 13px) 50%,
        calc(100% - 2.5rem) 50%;
    background-size: 6px 6px, 6px 6px, 1px 1.4em;
    background-repeat: no-repeat;
    background-color: var(--surface);
    padding-right: 44px;
    padding-left: 16px;
    height: 44px;
    line-height: 1.4;
    color: var(--text);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.form input[type="file"] {
    padding: 10px;
    background: #fff;
}

input[type="file"] {
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text);
}

input[type="file"]::file-selector-button {
    margin-right: 12px;
    border: 1px solid var(--border);
    border-radius: var(--button-radius);
    padding: 6px 12px;
    background: var(--surface-muted);
    color: var(--text);
    font-weight: 400;
    cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
    margin-right: 12px;
    border: 1px solid var(--border);
    border-radius: var(--button-radius);
    padding: 6px 12px;
    background: var(--surface-muted);
    color: var(--text);
    font-weight: 400;
    cursor: pointer;
}

input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover {
    background: var(--surface);
}

.auth {
    max-width: 520px;
    margin: 0 auto;
    padding: 48px 0;
}

.auth-links {
    display: flex;
    gap: 16px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-top: 16px;
    border: 1px solid var(--border);
}

.flash {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.flash.is-hidden {
    opacity: 0;
    transform: translateY(-6px);
}

.alert-error {
    background: #fdecec;
    color: #7a1c1c;
}

.alert-success {
    background: #e7f6ee;
    color: #1f5132;
}

.banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
    margin: 12px 0 16px;
}

.banner-warning {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.12);
    color: #8a5a00;
}

[data-theme="dark"] .banner-warning {
    color: #f7c676;
}

.page-section {
    padding: 48px 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.table tr.is-inactive td {
    opacity: 0.6;
}

.table-toolbar {
    margin-bottom: 16px;
    position: relative;
}

.date-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.date-presets .button {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.comparison-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: var(--surface);
}

.comparison-title {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.comparison-values {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-weight: 600;
}

.comparison-delta {
    margin-top: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.comparison-delta.up {
    color: #1f7a3f;
}

.comparison-delta.down {
    color: #b23b3b;
}

.comparison-delta.flat {
    color: var(--muted);
}

.heatmap {
    overflow-x: auto;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: 60px repeat(24, minmax(28px, 1fr));
    gap: 4px;
    align-items: center;
}

.heatmap-header {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}

.heatmap-day {
    font-size: 0.8rem;
    color: var(--muted);
}

.heatmap-cell {
    min-height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--surface);
}

.anomaly-list {
    display: grid;
    gap: 10px;
}

.anomaly-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #8a5a00;
}

[data-theme="dark"] .badge-warning {
    color: #f7c676;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.table-search-status {
    font-size: 0.85rem;
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.table-search-status.is-visible {
    opacity: 1;
}

.helper {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--surface-muted);
}

.helper summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    list-style: none;
}

.helper summary::-webkit-details-marker {
    display: none;
}

.helper summary::after {
    content: '+';
    float: right;
    color: var(--muted);
}

.helper[open] summary::after {
    content: '−';
}

.helper-body {
    margin-top: 12px;
    color: var(--muted);
}

.helper-body ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.helper-copy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.helper-copy .icon-button {
    width: 34px;
    height: 34px;
}

.helper-copy .icon-button.is-copied {
    color: var(--primary);
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--muted);
}

.table-pagination-links {
    display: inline-flex;
    gap: 12px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: var(--button-radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
}

.pagination-link:hover {
    text-decoration: none;
    color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.pagination-link[disabled] {
    background: var(--surface-muted);
    color: var(--muted);
    cursor: not-allowed;
    border-color: var(--border);
}

.pagination-link.is-disabled {
    pointer-events: none;
    background: var(--surface-muted);
    color: var(--muted);
    border-color: var(--border);
}

.table-pagination-links a:hover {
    text-decoration: none;
    color: var(--primary-dark);
}

.modal {
    border: none;
    padding: 0;
    border-radius: var(--radius);
    width: min(520px, 90vw);
    box-shadow: var(--shadow);
}

.modal::backdrop {
    background: rgba(10, 18, 30, 0.5);
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-header .icon-button {
    margin-top: -6px;
    margin-right: -6px;
}

.modal-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

.table th,
.table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    background: var(--surface-muted);
    color: var(--muted);
    font-weight: 700;
}

.table tr.is-muted td {
    background: rgba(123, 139, 162, 0.12);
    color: var(--muted);
}

[data-theme="dark"] .table tr.is-muted td {
    background: rgba(123, 139, 162, 0.2);
}

.table tr.is-muted td.is-italic {
    font-style: italic;
}

.tabs {
    display: inline-flex;
    gap: 10px;
    padding: 6px;
    border-radius: 999px;
    background: var(--surface-muted);
    margin: 16px 0 24px;
}

.analytics-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 16px 0 24px;
}

.kpi-card {
    display: grid;
    gap: 8px;
}

.kpi-label {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

.kpi-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.analytics-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    display: grid;
    gap: 12px;
}

.chart-subtitle {
    color: var(--muted);
    margin: 0;
}

.chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 180px;
    border-radius: 12px;
    border: 1px dashed var(--border);
    background: var(--surface-muted);
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.plan-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    background: var(--surface);
    display: grid;
    gap: 8px;
}

.plan-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.plan-card h3 {
    margin: 0;
}

.plan-price {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

.plan-interval {
    margin: 0;
    color: var(--muted);
}

.plan-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-muted);
    border-radius: 999px;
}

.plan-toggle-button {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.plan-toggle-button.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.plan-option {
    display: none;
    gap: 8px;
}

.plan-option.is-active {
    display: grid;
}

.tab-button {
    border: none;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
}

.tab-button.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.workspace-name-cell {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.workspace-name-cell.is-hidden {
    display: none;
}

.workspace-edit {
    width: 32px;
    height: 32px;
}

.workspace-edit-form {
    display: none;
    margin: 0;
}

.workspace-edit-form.is-editing {
    display: block;
}

.workspace-name-input {
    width: 100%;
    max-width: 260px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px 16px;
    margin: 8px 0 16px;
}

.checkbox {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    font-weight: 500;
}

.checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    max-width: none;
}

.feature-flag {
    display: grid;
    gap: 4px;
}

.feature-flag .muted {
    margin: 0;
}

.admin-nav {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    border-radius: 999px;
    background: var(--surface-muted);
    margin: 16px 0 24px;
}

.admin-nav a {
    padding: 8px 18px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
}

.admin-nav a.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.admin-nav a:hover {
    text-decoration: none;
    color: var(--text);
}

.sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 20px;
    width: var(--sidebar-width);
    align-self: start;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: visible;
    z-index: 10;
}

.sidebar-overlay {
    display: none;
}

.sidebar-brand {
    color: var(--brand-mark);
    margin-bottom: 12px;
    padding: 12px 12px 8px;
    height: 56px;
}

.sidebar-workspace {
    margin: 8px 0 16px;
    display: grid;
    gap: 8px;
}

.sidebar-workspace .form-inline {
    gap: 8px;
}

.sidebar-workspace select {
    min-width: 0;
    flex: 1;
}

.sidebar .sidebar-workspace-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 auto 16px;
    border-radius: 10px;
    color: var(--muted);
}

.sidebar-workspace-toggle:hover {
    color: var(--text);
    text-decoration: none;
}

.sidebar-workspace-link {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0 2px;
}

.sidebar-workspace-link:hover {
    color: var(--text);
    text-decoration: none;
}

.sidebar-scroll {
    height: calc(100vh - 92px);
    overflow-y: auto;
    overflow-x: visible;
    padding-right: 4px;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 500;
    line-height: 1.2;
}

.sidebar a.sidebar-brand {
    color: var(--brand-mark);
}

.sidebar a:hover {
    background: var(--surface-muted);
    color: var(--primary-dark);
    text-decoration: none;
}

.sidebar a.sidebar-brand:hover {
    background: transparent;
    color: var(--brand-mark);
}


.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 6px;
}


.sidebar-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.95rem;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--button-radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.icon-button:hover {
    background: var(--surface-muted);
}

.modal-header .icon-button {
    border: none;
    background: transparent;
}

.modal-header .icon-button:hover {
    background: var(--surface-muted);
}

.icon-button .icon-collapse {
    display: inline-block;
}

.icon-button .icon-expand {
    display: none;
}

.theme-toggle {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--button-radius);
    border: none;
    background: transparent;
    color: var(--muted);
    font-weight: 400;
    line-height: 1.2;
    cursor: pointer;
    text-align: left;
    min-height: 40px;
}


.toggle-switch {
    width: 54px;
    height: 26px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    display: inline-block;
    transition: background 0.2s ease;
    position: relative;
}

.toggle-knob {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease, background 0.2s ease;
    z-index: 2;
}

.toggle-icon {
    position: absolute;
    font-size: 0.65rem;
    color: var(--muted);
    opacity: 0.7;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

.toggle-icon-left {
    left: 7px;
}

.toggle-icon-right {
    right: 7px;
}

[data-theme="dark"] .toggle-icon-right,
[data-theme="light"] .toggle-icon-left {
    color: var(--primary);
    opacity: 1;
}

[data-theme="dark"] .toggle-switch {
    background: rgba(110, 163, 255, 0.25);
    border-color: rgba(110, 163, 255, 0.6);
}

[data-theme="dark"] .toggle-knob {
    background: #dbe7ff;
}

[data-theme="dark"] .toggle-knob {
    transform: translateX(28px);
}

.theme-toggle:hover {
    background: var(--surface-muted);
    color: var(--primary-dark);
}

.sidebar-tooltip {
    position: fixed;
    transform: translateY(-50%);
    background: var(--text);
    color: var(--surface);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: var(--shadow);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.sidebar-tooltip.is-visible {
    opacity: 1;
}

.page.sidebar-collapsed .sidebar {
    width: 76px;
    padding: 16px 8px;
}

.page.sidebar-collapsed .sidebar-workspace {
    display: none;
}

.page.sidebar-collapsed .sidebar .sidebar-workspace-toggle {
    display: flex;
}

.page.sidebar-collapsed .sidebar .sidebar-label,
.page.sidebar-collapsed .sidebar .brand-text {
    display: none;
}

.page.sidebar-collapsed .sidebar .toggle-switch {
    display: inline-flex;
}

.page.sidebar-collapsed .sidebar-divider {
    margin: 10px auto;
    width: 28px;
}


.page.sidebar-collapsed .sidebar a {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
    width: 44px;
}

.page.sidebar-collapsed .sidebar .sidebar-workspace-toggle {
    justify-content: center;
    padding: 10px 0;
    width: 44px;
}

.page.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    width: 44px;
    margin-left: auto;
    margin-right: auto;
}

.page.sidebar-collapsed .sidebar-nav {
    justify-items: center;
}

.page.sidebar-collapsed .theme-toggle {
    justify-content: center;
    gap: 0;
    width: 44px;
    padding: 10px 0;
}

.page.sidebar-collapsed .icon-button .icon-collapse {
    display: none;
}

.page.sidebar-collapsed .icon-button .icon-expand {
    display: inline-block;
}

.icon-button .icon-collapse,
.icon-button .icon-expand {
    line-height: 1;
}

@media (max-width: 768px) {
    .page.has-sidebar {
        grid-template-columns: 1fr;
    }

    .page.has-sidebar.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(84vw, 320px);
        border-left: none;
        border-right: 1px solid var(--border);
        border-radius: 0;
        transform: translateX(-110%);
        transition: transform 0.25s ease;
        z-index: 20;
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
    }

    .page.has-sidebar.sidebar-collapsed .sidebar {
        transform: translateX(-110%);
    }

    .page.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .page.sidebar-open {
        overflow: hidden;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(12, 18, 28, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 10;
    }

    .page.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }


    .site-header .content-inner,
    .site-footer .content-inner {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        height: auto;
        padding: 12px 0;
    }

    .nav {
        display: flex;
        justify-content: flex-end;
        gap: 12px;
        padding-right: 8px;
        margin-left: auto;
    }

    .nav a,
    .nav details,
    .nav form {
        margin-left: 0;
    }

    .footer-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .content-inner {
        padding: 0 20px;
    }
}

@media (min-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
}
.table-toolbar input[type="search"] {
    min-width: 240px;
    appearance: none;
    -webkit-appearance: none;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
    height: 44px;
    line-height: 1.4;
}

.table-toolbar select {
    min-width: 200px;
    padding: 10px 44px 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
    height: 44px;
    line-height: 1.4;
}
