:root {
    --nav: #142d50;
    --accent: #245cba;
    --accent-hover: #19478f;
    --soft: #edf4ff;
    --page: #f3f6fb;
    --text: #243349;
    --muted: #59697e;
    --line: #dce4ef;
    --surface: #fff;
    --shadow: 0 8px 30px rgb(25 46 78 / 6%);
}

.theme-minimal {
    --nav: #252930;
    --accent: #363e4b;
    --accent-hover: #171d26;
    --soft: #f0f1f3;
    --page: #f7f7f8;
    --text: #292e36;
    --muted: #626873;
    --line: #e0e2e6;
}

.theme-teal {
    --nav: #103f46;
    --accent: #087c78;
    --accent-hover: #065b58;
    --soft: #e5f5f2;
    --page: #f0f7f6;
    --text: #203d41;
    --muted: #526e72;
    --line: #d6e5e3;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font: 0.94rem/1.6 "Segoe UI", Arial, sans-serif;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
h1, h2 { line-height: 1.25; letter-spacing: -0.035em; }
h1 { margin: 0 0 0.65rem; font-size: clamp(1.65rem, 3vw, 2.1rem); }
h2 { margin: 0 0 1rem; font-size: 1.35rem; }
p { margin: 0 0 1.25rem; }
button, input, select { font: inherit; }
button, .button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.65rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-hover); color: #fff; }
:focus-visible { outline: 3px solid #d88a08; outline-offset: 3px; }
.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 100; padding: 1rem; background: #fff; }
.skip-link:focus { top: 1rem; }

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 2rem;
    background: var(--nav);
    color: #fff;
    position: relative;
    z-index: 30;
}
.navbar a { color: #fff; text-decoration: none; }
.site-name { display: flex; align-items: center; gap: 0.8rem; font-weight: 700; line-height: 1.3; }
.site-name small { display: block; color: #cfdbeb; font-size: 0.8rem; font-weight: 400; margin-top: 0.2rem; }
.brand-icon { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border: 1px solid #ffffff50; border-radius: 10px; font-size: 1.4rem; }
.nav-links { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.nav-links > a { padding: 0.55rem 0.8rem; border-radius: 7px; color: #e3eaf5; font-weight: 500; }
.nav-links > a:hover, .nav-links > a[aria-current="page"] { color: #fff; background: #ffffff20; }
.user-menu { position: relative; margin-left: 0.5rem; }
.user-menu-toggle { display: flex; align-items: center; gap: 0.65rem; padding: 0.4rem 0.8rem 0.4rem 0.4rem; border: 1px solid #ffffff80; border-radius: 30px; background: #fff; color: var(--nav); cursor: pointer; list-style: none; }
.user-menu-toggle::-webkit-details-marker, .column-filter summary::-webkit-details-marker { display: none; }
.user-icon { width: 2rem; height: 2rem; padding: 0.3rem; background: var(--soft); border-radius: 50%; flex-shrink: 0; }
.user-name { font-weight: 650; overflow-wrap: anywhere; }
.user-menu-arrow { width: 0.4rem; height: 0.4rem; border-right: 2px solid; border-bottom: 2px solid; transform: rotate(45deg); margin: 0 0.2rem; flex-shrink: 0; }
.user-menu[open] .user-menu-arrow { transform: rotate(225deg); }
.user-menu-dropdown, .column-filter-panel { position: absolute; top: calc(100% + 0.65rem); right: 0; padding: 0.6rem; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 35px rgb(20 35 60 / 16%); z-index: 40; }
.user-menu-dropdown { min-width: 14rem; }
.user-role { margin: 0; padding: 0.6rem 0.75rem; color: var(--muted); font-size: 0.8rem; }
.user-menu-dropdown a { display: block; padding: 0.65rem 0.75rem; border-radius: 6px; color: var(--text); }
.user-menu-dropdown a:hover { background: var(--soft); }
.user-menu-dropdown .logout-link { color: #a12632; }

.container { width: min(1200px, calc(100% - 3rem)); margin: 2rem auto; }
.workspace-label { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; }
.workspace-label span { letter-spacing: 0.03em; }
.card { padding: clamp(1.25rem, 3vw, 2rem); margin-bottom: 1.5rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.container:has(form:not(#ticket-filters):not(.dashboard-actions)):not(:has(.dashboard-card)):not(:has(.appearance-form)) { max-width: 850px; }
.page-intro, .field-help { color: var(--muted); }
.field-help { font-size: 0.85rem; }
footer { padding: 0.75rem 0; color: var(--muted); font-size: 0.8rem; text-align: center; }
.welcome-card { padding: clamp(2rem, 6vw, 5rem); background: linear-gradient(120deg, #fff 45%, var(--soft)); }
.welcome-card h1 { margin-top: 1rem; font-size: clamp(2rem, 4.5vw, 3.8rem); max-width: 16ch; }
.welcome-card p { color: var(--muted); max-width: 48ch; font-size: 1.1rem; }
.eyebrow { color: var(--accent); font-size: 0.75rem; font-weight: 750; letter-spacing: 0.15em; }

.messages { margin-bottom: 1.25rem; }
.messages p { margin: 0 0 0.5rem; padding: 0.85rem 1rem; border-radius: 9px; border-left: 4px solid currentColor; }
.flash-success { background: #dff3e9; color: #185b3e; }
.flash-danger { background: #fce6e8; color: #922b39; }
.flash-warning { background: #fff2d6; color: #775000; }
.flash-info { background: #e3effb; color: #245281; }

table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
th, td { padding: 0.85rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--soft); color: var(--muted); font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td { font-size: 0.87rem; }
td a { font-weight: 550; text-decoration: none; }
td a:hover { text-decoration: underline; }
td:first-child a { font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--soft); }
.status-open { background: #fce6e8; color: #922b39; }
.status-in-progress { background: #fff0d9; color: #8a4c00; }
.status-closed { background: #edf0f3; color: #505b68; }
.assigned-to-me { background: var(--soft); }
.assigned-to-me td:first-child { border-left: 4px solid var(--accent); }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.dashboard-header h1 { margin-bottom: 0.35rem; }
.dashboard-header p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.dashboard-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; max-width: none; }
.dashboard-actions button { padding: 0.55rem 0.75rem; font-size: 0.8rem; background: var(--surface); border-color: var(--line); color: var(--accent); }
.dashboard-actions button:hover { background: var(--soft); border-color: var(--accent); }

form { display: grid; gap: 0.6rem; max-width: 34rem; }
form > label { font-size: 0.88rem; font-weight: 600; margin-top: 0.6rem; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select { width: 100%; min-width: 0; padding: 0.75rem 0.85rem; border: 1px solid #aebdce; border-radius: 8px; background: #fff; color: var(--text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1rem; height: 1rem; flex-shrink: 0; }
form > button { justify-self: start; margin-top: 0.75rem; }
form > p { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.85rem; }
dl { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: 0; margin: 1.5rem 0 2rem; }
dt, dd { padding: 0.75rem 0; border-bottom: 1px solid var(--line); margin: 0; }
dt { color: var(--muted); font-size: 0.88rem; }
dd { font-weight: 550; overflow-wrap: anywhere; }
#ticket-filters { margin: 0; }
.column-filter { position: relative; }
.column-filter summary { cursor: pointer; list-style: none; white-space: nowrap; }
.column-filter summary span { color: var(--accent); }
.column-filter[open] { z-index: 20; }
.column-filter-panel { width: 15rem; max-width: 80vw; padding: 1rem; font-weight: normal; font-size: 0.9rem; white-space: normal; }
.column-filter-panel fieldset { max-height: 16rem; margin: 0 0 0.75rem; padding: 0; border: 0; overflow-y: auto; }
.column-filter-panel legend { margin-bottom: 0.5rem; font-weight: 700; }
.column-filter-panel label { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; overflow-wrap: anywhere; }
.filter-selection-actions { display: flex; gap: 0.75rem; margin-bottom: 0.5rem; }
.filter-link { padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--accent); font-size: 0.8rem; text-decoration: underline; }
.filter-link:hover { background: transparent; color: var(--accent-hover); }
.filter-reset { display: block; margin-top: 0.6rem; }
.appearance-form { max-width: 46rem; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 1rem 0; border: 0; }
.theme-options legend { font-weight: 650; }
.theme-choice { display: grid; gap: 0.75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.theme-choice:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.theme-swatch { display: block; height: 4rem; border-radius: 6px; }
.swatch-navy { background: linear-gradient(135deg, #142d50 50%, #edf4ff 50%); }
.swatch-minimal { background: linear-gradient(135deg, #252930 50%, #f0f1f3 50%); }
.swatch-teal { background: linear-gradient(135deg, #103f46 50%, #e5f5f2 50%); }

@media (min-width: 1000px) {
    .layout-sidebar { padding-left: 245px; }
    .layout-sidebar .navbar { position: fixed; inset: 0 auto 0 0; width: 245px; flex-direction: column; justify-content: flex-start; align-items: stretch; padding: 1.5rem 1rem; }
    .layout-sidebar .nav-links { flex-direction: column; align-items: stretch; flex: 1; margin-top: 2rem; }
    .layout-sidebar .user-menu { margin: auto 0 0; }
    .layout-sidebar .user-menu-toggle { border-radius: 10px; }
    .layout-sidebar .user-menu-dropdown { top: auto; bottom: calc(100% + 0.5rem); right: 0; width: 100%; }
}
@media (max-width: 800px) {
    .navbar { flex-wrap: wrap; padding: 1rem; }
    .nav-links { width: 100%; }
    .user-menu { margin-left: auto; max-width: 100%; }
    .container { width: calc(100% - 1.5rem); margin-top: 1.25rem; }
    .card { padding: 1rem; border-radius: 12px; }
    .dashboard-card, .card:has(table) { overflow-x: auto; }
    .dashboard-card { min-height: 25rem; }
    .dashboard-card table { min-width: 850px; }
    .column-filter-panel { position: fixed; top: 25%; right: 5%; width: 90%; max-width: 22rem; }
    .theme-options { grid-template-columns: 1fr; }
    dl { grid-template-columns: 7rem 1fr; gap: 0.75rem; }
}
