/* ==========================================================================
   Shahani Group Support Desk
   ========================================================================== */

:root {
    color-scheme: light;

    --bg: #f2f5f9;
    --surface: #ffffff;
    --surface-2: #eef3f9;
    --surface-3: #e5ecf5;
    --ink: #142132;
    --muted: #5c6c80;
    --line: #d9e1eb;
    --line-strong: #c5d1df;

    --brand: #17375e;
    --brand-strong: #102a47;
    --brand-soft: #e8eff8;
    --accent: #d98e04;
    --accent-strong: #b97703;
    --accent-ink: #241a00;
    --accent-soft: #fdf3da;

    --success: #157347;
    --success-soft: #e2f4ea;
    --warning: #a15c00;
    --warning-soft: #fdf0d5;
    --danger: #b42318;
    --danger-soft: #fde9e7;
    --info: #1d4ed8;
    --info-soft: #e4ecff;

    --shadow-sm: 0 1px 2px rgba(15, 31, 51, .05);
    --shadow-md: 0 10px 30px rgba(15, 31, 51, .08);
    --radius: 16px;
    --radius-sm: 10px;
    --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #0d1520;
        --surface: #162232;
        --surface-2: #1b293b;
        --surface-3: #223348;
        --ink: #e8eef6;
        --muted: #9cabbd;
        --line: #2a3a4f;
        --line-strong: #3a4d65;

        --brand: #7fb2ec;
        --brand-strong: #a9cbf4;
        --brand-soft: #172a41;
        --accent: #f2b84b;
        --accent-strong: #ffcb70;
        --accent-ink: #241a00;
        --accent-soft: #3b2d10;

        --success: #6fd596;
        --success-soft: #17361f;
        --warning: #f5b85a;
        --warning-soft: #3a2c10;
        --danger: #f28b8b;
        --danger-soft: #3d1d1d;
        --info: #8db4ff;
        --info-soft: #1c2c4d;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
        --shadow-md: 0 14px 34px rgba(0, 0, 0, .35);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d1520;
    --surface: #162232;
    --surface-2: #1b293b;
    --surface-3: #223348;
    --ink: #e8eef6;
    --muted: #9cabbd;
    --line: #2a3a4f;
    --line-strong: #3a4d65;

    --brand: #7fb2ec;
    --brand-strong: #a9cbf4;
    --brand-soft: #172a41;
    --accent: #f2b84b;
    --accent-strong: #ffcb70;
    --accent-ink: #241a00;
    --accent-soft: #3b2d10;

    --success: #6fd596;
    --success-soft: #17361f;
    --warning: #f5b85a;
    --warning-soft: #3a2c10;
    --danger: #f28b8b;
    --danger-soft: #3d1d1d;
    --info: #8db4ff;
    --info-soft: #1c2c4d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow-md: 0 14px 34px rgba(0, 0, 0, .35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, dl, dd, figure {
    margin-top: 0;
}

h1, h2, h3 {
    line-height: 1.2;
    letter-spacing: -.015em;
}

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

a:hover {
    color: var(--brand-strong);
}

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

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: -100px;
    left: 16px;
    z-index: 100;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    top: 12px;
}

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

/* ---------- Header ---------- */

.app-header {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 50;
    background: linear-gradient(120deg, var(--brand-strong), var(--brand) 60%, #1d4673);
    color: #fff;
    box-shadow: 0 2px 18px rgba(10, 25, 45, .18);
    padding-top: env(safe-area-inset-top, 0px);
}

.app-header__inner {
    display: flex;
    align-items: center;
    gap: 18px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
}

.brand:hover {
    color: #fff;
}

.brand__mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .04em;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
}

.brand__mark--large {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 16px;
}

.brand__text {
    font-size: 17px;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.brand__text strong {
    font-weight: 750;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    background: rgba(255, 255, 255, .06);
}

.user-chip__text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-chip__text strong {
    font-size: 12.5px;
    font-weight: 650;
}

.user-chip__text small {
    font-size: 10.5px;
    color: rgba(255, 255, 255, .64);
}

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .02em;
    flex-shrink: 0;
}

.app-header .avatar {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .18);
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 9px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.icon-button:hover {
    background: rgba(255, 255, 255, .12);
}

.icon-button--dark {
    position: absolute;
    top: 20px;
    right: 20px;
    border-color: var(--line);
    color: var(--ink);
}

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

.icon-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sun {
    display: none;
}

.icon-moon {
    display: block;
}

:root[data-theme="dark"] .icon-sun {
    display: block;
}

:root[data-theme="dark"] .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun {
        display: block;
    }

    :root:not([data-theme="light"]) .icon-moon {
        display: none;
    }
}

/* ---------- Page shell ---------- */

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 20px 48px;
}

.page-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 22px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    scrollbar-width: thin;
}

.tab {
    position: relative;
    padding: 10px 14px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color .15s ease, background .15s ease;
}

.tab:hover {
    color: var(--ink);
    background: var(--surface-2);
}

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

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.page-heading h1 {
    margin: 2px 0 4px;
    font-size: clamp(27px, 3.6vw, 36px);
    letter-spacing: -.035em;
}

.page-heading p:not(.eyebrow) {
    max-width: 68ch;
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    margin: 0;
    color: var(--accent-strong);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--brand);
}

/* ---------- Buttons ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease, background .12s ease, color .12s ease;
}

.button:hover {
    border-color: var(--brand);
    color: var(--brand);
    text-decoration: none;
}

.button:active {
    transform: translateY(1px);
}

.button--primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 5px 16px rgba(217, 142, 4, .22);
}

.button--primary:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: var(--accent-ink);
}

.button--quiet {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}

.button--quiet:hover {
    background: var(--surface-2);
    border-color: var(--line);
    color: var(--ink);
}

.button--danger {
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    background: transparent;
    color: var(--danger);
}

.button--danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.button--header {
    padding: 7px 12px;
    border-color: rgba(255, 255, 255, .32);
    background: transparent;
    color: #fff;
    font-size: 13px;
}

.button--header:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .55);
    color: #fff;
}

.button--wide {
    width: 100%;
}

/* ---------- Cards ---------- */

.card {
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card--tint {
    background: var(--surface-2);
}

.card--success {
    border-left: 4px solid var(--success);
}

.card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.card__header h2,
.card > h2 {
    margin: 0;
    font-size: 17px;
}

.card__header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.card > h2 {
    margin-bottom: 16px;
}

.card__header .badge-row {
    justify-content: flex-end;
}

.prose {
    margin: 0;
    white-space: pre-line;
    line-height: 1.7;
}

/* ---------- Stats ---------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat--open { border-left-color: var(--warning); }
.stat--progress { border-left-color: var(--info); }
.stat--closed { border-left-color: var(--success); }
.stat--overdue { border-left-color: var(--danger); }

.stat__label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.stat strong {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.03em;
}

.stat__hint {
    color: var(--muted);
    font-size: 12px;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 750;
    line-height: 1.45;
    white-space: nowrap;
}

.badge--open {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 20%, transparent);
}

.badge--in-progress {
    background: var(--info-soft);
    color: var(--info);
    border-color: color-mix(in srgb, var(--info) 18%, transparent);
}

.badge--closed {
    background: var(--success-soft);
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 18%, transparent);
}

.badge--low {
    background: var(--surface-2);
    color: var(--muted);
    border-color: var(--line);
}

.badge--medium {
    background: var(--info-soft);
    color: var(--info);
    border-color: color-mix(in srgb, var(--info) 18%, transparent);
}

.badge--high {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 20%, transparent);
}

.badge--critical {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 20%, transparent);
}

.badge--neutral {
    background: var(--surface-2);
    color: var(--muted);
    border-color: var(--line);
}

.badge-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

/* ---------- Forms ---------- */

.form-stack {
    display: grid;
    gap: 16px;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.field label {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 650;
}

.label-hint {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field textarea {
    min-height: 90px;
    resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
    color: color-mix(in srgb, var(--muted) 68%, transparent);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.field select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

.field__hint {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.field__error {
    margin: 5px 0 0;
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
}

.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-size: 13.5px;
    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand);
}

.field--small {
    max-width: 110px;
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.filter-bar .field {
    flex: 1 1 135px;
}

.filter-bar .field--search {
    flex: 2 1 210px;
}

.filter-bar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

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

.inline-form .field {
    flex: 1 1 180px;
}

/* ---------- Tables ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    scrollbar-width: thin;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.data-table th {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
    vertical-align: top;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr {
    transition: background .12s ease;
}

.data-table tbody tr:hover {
    background: var(--surface-2);
}

.data-table tr.is-overdue td:first-child {
    box-shadow: inset 3px 0 0 var(--danger);
}

.ticket-ref {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 750;
    text-decoration: none;
    letter-spacing: .02em;
}

.ticket-ref:hover {
    color: var(--brand);
}

.ticket-subject {
    color: var(--ink);
    font-weight: 650;
    text-decoration: none;
}

.ticket-subject:hover {
    color: var(--brand);
}

.ticket-subline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 400;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.pagination__link {
    padding: 7px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.pagination__link:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.pagination__link.is-disabled {
    opacity: .4;
    pointer-events: none;
}

.pagination__status {
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Flash / empty states ---------- */

.flash {
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-left: 4px solid;
    border-radius: 10px;
    font-size: 13.5px;
}

.flash strong {
    display: block;
    margin-bottom: 2px;
}

.flash ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.flash--success {
    border-color: color-mix(in srgb, var(--success) 24%, transparent);
    border-left-color: var(--success);
    background: var(--success-soft);
    color: var(--success);
}

.flash--error {
    border-color: color-mix(in srgb, var(--danger) 24%, transparent);
    border-left-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.empty-state {
    padding: 34px 20px;
    text-align: center;
}

.empty-state__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .04em;
}

.empty-state h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

.empty-state p {
    margin: 0 auto;
    max-width: 46ch;
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Auth ---------- */

.auth-body {
    min-height: 100vh;
    background: var(--bg);
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(340px, 1fr) minmax(420px, 540px);
    min-height: 100vh;
}

.auth-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: clamp(28px, 5vw, 60px);
    background:
        radial-gradient(circle at 85% 18%, rgba(242, 184, 75, .17), transparent 34%),
        radial-gradient(circle at 10% 92%, rgba(127, 178, 236, .16), transparent 40%),
        linear-gradient(145deg, #0c2138, #17375e 58%, #1d4673);
    color: #fff;
}

.auth-hero::after {
    position: absolute;
    right: -120px;
    bottom: -160px;
    width: 420px;
    height: 420px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 50%;
    box-shadow: 0 0 0 48px rgba(255, 255, 255, .025), 0 0 0 96px rgba(255, 255, 255, .02);
    content: "";
    pointer-events: none;
}

.auth-hero__top {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
}

.auth-hero__brand strong {
    font-weight: 750;
}

.auth-hero__body {
    max-width: 540px;
    margin: auto 0;
    padding: 44px 0;
}

.auth-hero__body .eyebrow {
    color: #f2b84b;
}

.auth-hero__body h1 {
    margin: 8px 0 14px;
    font-size: clamp(40px, 5.2vw, 62px);
    font-weight: 800;
    line-height: .98;
    letter-spacing: -.055em;
}

.auth-hero__body > p:not(.eyebrow) {
    max-width: 44ch;
    margin-bottom: 26px;
    color: rgba(255, 255, 255, .74);
    font-size: 16px;
}

.feature-list {
    display: grid;
    gap: 13px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: rgba(255, 255, 255, .86);
    font-size: 14px;
}

.feature-list span {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid rgba(242, 184, 75, .42);
    border-radius: 50%;
    color: #f2b84b;
    font-size: 9.5px;
    font-weight: 800;
    flex-shrink: 0;
}

.auth-hero__foot {
    margin: 0;
    color: rgba(255, 255, 255, .46);
    font-size: 12px;
}

.auth-panel {
    position: relative;
    display: grid;
    place-items: center;
    padding: 44px 32px;
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.auth-card h2 {
    margin: 4px 0 6px;
    font-size: 30px;
    letter-spacing: -.035em;
}

.auth-card__lead {
    margin-bottom: 22px;
    color: var(--muted);
    font-size: 13.5px;
}

.auth-card .flash {
    margin-bottom: 16px;
}

.demo-accounts {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.demo-accounts > p {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 750;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.demo-accounts > p span {
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.demo-accounts__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.demo-account {
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.demo-account:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.demo-account strong {
    display: block;
    font-size: 12px;
}

.demo-account small {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 10.5px;
    text-overflow: ellipsis;
}

.demo-accounts__note {
    display: block;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

/* ---------- Ticket detail ---------- */

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(290px, 1fr);
    align-items: start;
    gap: 18px;
}

.detail-main,
.detail-aside {
    min-width: 0;
}

.detail-aside {
    display: grid;
    gap: 18px;
}

.detail-aside .card {
    margin-bottom: 0;
}

.detail-list {
    display: grid;
    gap: 11px;
    margin: 0;
}

.detail-list > div {
    display: grid;
    gap: 1px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.detail-list > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.detail-list dt {
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.detail-list dd {
    margin: 0;
    font-size: 13.5px;
    font-weight: 550;
    overflow-wrap: anywhere;
}

.detail-list__flag {
    display: inline-block;
    margin-left: 5px;
    color: var(--danger);
    font-size: 11px;
    font-weight: 750;
}

.detail-list__flag--warning {
    color: var(--warning);
}

.sla-big {
    margin: 2px 0 4px;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -.04em;
}

.timeline {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline__item {
    position: relative;
    margin-left: 6px;
    padding: 0 0 20px 24px;
    border-left: 1px solid var(--line);
}

.timeline__item:last-child {
    padding-bottom: 0;
    border-left-color: transparent;
}

.timeline__dot {
    position: absolute;
    top: 5px;
    left: -5px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.timeline__head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    font-size: 13px;
}

.timeline__type {
    color: var(--muted);
    font-size: 11.5px;
}

.timeline__head time {
    margin-left: auto;
    color: var(--muted);
    font-size: 11.5px;
}

.timeline__body p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13.5px;
    white-space: pre-line;
}

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    align-items: start;
    gap: 18px;
}

.form-aside {
    display: grid;
    gap: 18px;
}

.form-aside .card {
    margin-bottom: 0;
}

.step-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.step-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
}

.step-list span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 750;
    flex-shrink: 0;
}

.priority-guide {
    display: grid;
    gap: 11px;
    margin: 0;
}

.priority-guide div {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.priority-guide div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.priority-guide dt {
    font-size: 13px;
    font-weight: 750;
}

.priority-guide dd {
    margin: 1px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.reminder-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.reminder-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.reminder-card__time {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.reminder-card__hint {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
}

/* ---------- Reports ---------- */

.sla-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.sla-card__copy h2 {
    margin: 4px 0;
    font-size: 20px;
}

.sla-card__copy p:last-child {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.sla-card__meter {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 240px;
}

.sla-card__meter strong {
    font-size: 24px;
    letter-spacing: -.03em;
}

.meter {
    width: 190px;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--line);
}

.meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--success), color-mix(in srgb, var(--success) 65%, var(--accent)));
}

/* ---------- Outbox ---------- */

.mail-list {
    display: grid;
}

.mail {
    padding: 15px 0;
    border-top: 1px solid var(--line);
}

.mail:first-child {
    border-top: 0;
    padding-top: 0;
}

.mail__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.mail__head h3 {
    margin: 0;
    font-size: 14.5px;
}

.mail__head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.mail__head time {
    color: var(--muted);
    font-size: 11.5px;
    white-space: nowrap;
}

.mail pre {
    margin: 10px 0 0;
    padding: 12px;
    overflow-x: auto;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--muted);
    font: 12.5px/1.6 var(--font);
    white-space: pre-wrap;
}

/* ---------- Admin ---------- */

.category-card {
    scroll-margin-top: 80px;
}

.disclosure {
    margin-top: 14px;
    border-top: 1px solid var(--line);
}

.disclosure summary {
    padding: 11px 0;
    color: var(--brand);
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.disclosure[open] summary {
    margin-bottom: 10px;
}

.disclosure .form-stack {
    padding-bottom: 6px;
}

.items-panel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.items-panel__head h3 {
    margin: 0;
    font-size: 14px;
}

.items-panel__head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.item-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.item-chips li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 5px 4px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 12.5px;
}

.item-chips li form {
    display: inline-flex;
}

.item-chips li button {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.item-chips li button:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.danger-zone {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.danger-zone p {
    margin: 0;
    font-size: 12px;
}

.team-list {
    display: grid;
    gap: 12px;
}

.team-member {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.team-member__summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.team-member .avatar {
    background: var(--brand);
    color: #fff;
}

.team-member__identity {
    flex: 1 1 220px;
    min-width: 0;
    line-height: 1.35;
}

.team-member__identity strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.team-member__identity span {
    color: var(--muted);
    font-size: 12px;
}

.team-member .disclosure {
    margin-top: 12px;
}

/* ---------- Utilities ---------- */

.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
    .detail-layout,
    .form-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .detail-aside {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 880px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-hero {
        padding: 30px 24px 34px;
    }

    .auth-hero__body {
        padding: 36px 0 24px;
    }

    .auth-hero__body h1 {
        font-size: clamp(38px, 10vw, 52px);
    }

    .auth-hero__foot {
        display: none;
    }

    .auth-panel {
        padding: 30px 20px 44px;
    }

    .auth-card {
        max-width: 520px;
    }
}

@media (max-width: 720px) {
    .app-header__inner {
        gap: 10px;
        padding: 9px 14px;
    }

    .brand__text {
        font-size: 15px;
    }

    .user-chip__text {
        display: none;
    }

    .user-chip {
        padding: 3px;
        border: 0;
        background: transparent;
    }

    .button--header {
        padding: 7px 9px;
    }

    .page {
        padding: 18px 14px 40px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-heading .button {
        width: 100%;
    }

    .form-grid--2,
    .form-grid--3 {
        grid-template-columns: minmax(0, 1fr);
    }

    .filter-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-bar .field,
    .filter-bar .field--search {
        flex-basis: auto;
    }

    .filter-bar__actions {
        margin-left: 0;
    }

    .filter-bar__actions .button {
        flex: 1;
    }

    .detail-aside {
        grid-template-columns: minmax(0, 1fr);
    }

    .reminder-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .sla-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .sla-card__meter {
        width: 100%;
        min-width: 0;
    }

    .meter {
        width: 100%;
    }

    .timeline__head time {
        width: 100%;
        margin-left: 0;
    }

    .mail__head {
        flex-direction: column;
        gap: 4px;
    }

    .page-footer {
        flex-direction: column;
    }

    .demo-accounts__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .team-member__summary .badge {
        align-self: flex-start;
    }
}

@media (max-width: 460px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat strong {
        font-size: 27px;
    }

    .brand__text strong {
        display: block;
    }

    .auth-card {
        padding: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
