:root {
    --ink: #1c1915;
    --sidebar: #1a1814;
    --paper: #efe6d8;
    --card: #fffaf3;
    --line: #e3d8c8;
    --accent: #c4622d;
    --accent-dark: #9a4318;
    --muted: #6f655b;
    --shadow: 0 16px 40px rgba(48, 32, 16, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: Outfit, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 2rem; line-height: 1.15; margin-bottom: 0.35rem; }
h2 { font-size: 1.05rem; margin-bottom: 0.8rem; }
a { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; color: inherit; }

.shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    color: #f6efe4;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    font-family: Fraunces, Georgia, serif;
    font-size: 2rem;
    letter-spacing: -0.03em;
    text-decoration: none;
    color: inherit;
}

.brand-light { margin: 0 0 1.5rem; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
    color: #efe4d4;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
}
.nav a:hover, .nav a.is-active { background: rgba(255, 250, 243, 0.1); }
.nav a.is-active { color: #fff; }

.who { margin-top: auto; display: grid; gap: 8px; justify-items: start; }
.who strong { font-weight: 600; }

.text-button {
    background: none;
    border: 0;
    padding: 0;
    color: #e7c2a8;
    cursor: pointer;
    text-decoration: underline;
}

.main { padding: 32px; max-width: 1120px; }

.page-head, .panel-head, .row-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.page-head { margin-bottom: 22px; }
.muted, .fine { color: var(--muted); }
.sidebar .fine { color: #cbbba6; }
.fine { margin: 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.stat, .panel, .auth-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.stat {
    text-decoration: none;
    color: inherit;
    padding: 16px;
    display: grid;
    gap: 4px;
}
.stat:hover { border-color: #d7b89a; }
.stat-num { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.04em; }
.stat-label { color: var(--muted); font-size: 0.92rem; }

.panel { padding: 18px 18px 8px; margin-bottom: 18px; }
.panel-head { margin-bottom: 8px; }
.prose-panel { padding-bottom: 18px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}
tr:last-child td { border-bottom: 0; }
.ticket-link { font-weight: 600; text-decoration: none; }
.ticket-link:hover { text-decoration: underline; }
.mono, .crumb { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.crumb { margin-bottom: 0.2rem; color: var(--muted); }

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 650;
    white-space: nowrap;
}
.pill-open, .pill-admin { background: #f6e2cc; color: #7a3e09; }
.pill-in_progress, .pill-agent { background: #d9e6f5; color: #1d4e89; }
.pill-waiting { background: #efe6c8; color: #6b5408; }
.pill-resolved { background: #d7eee3; color: #1e5c40; }
.pill-closed, .pill-requester, .pill-low { background: #ece7df; color: #5c564e; }
.pill-normal { background: #e7efe8; color: #245c45; }
.pill-high { background: #f8e1d4; color: #8a3412; }
.pill-urgent { background: #f4d4d4; color: #8d1d1d; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}
.filters label, .stack label { display: grid; gap: 6px; font-size: 0.92rem; font-weight: 600; }
.stack { display: grid; gap: 14px; }
.form-narrow { max-width: 640px; padding-bottom: 18px; }

input, select, textarea {
    width: 100%;
    background: #fff;
    border: 1px solid #ddcfc0;
    border-radius: 10px;
    padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid #e7b08a;
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary {
    background: transparent;
    color: var(--ink);
    border-color: #d9cbb8;
}
.btn.secondary:hover { background: #f6efe6; }
.row-actions { justify-content: flex-start; }

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
}
.flash-ok { background: #d7eee3; color: #1e5c40; }
.flash-error { background: #f8d9d4; color: #8d1d1d; }
.error-list { margin: 0; padding-left: 1.1rem; }
.empty { color: var(--muted); padding-bottom: 12px; }
.prose { white-space: pre-wrap; margin-bottom: 0; }

.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
    align-items: start;
}
.ticket-side { padding-bottom: 18px; }
.props { margin: 0; display: grid; gap: 12px; }
.props div { display: grid; gap: 4px; }
.props dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.props dd { margin: 0; }

.comments { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 14px; }
.comments li { border-top: 1px solid var(--line); padding-top: 12px; }
.comment-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
}
.auth-brand {
    background:
        radial-gradient(circle at 20% 20%, rgba(196, 98, 45, 0.35), transparent 28%),
        var(--sidebar);
    color: #f6efe4;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-brand h1 {
    font-family: Fraunces, Georgia, serif;
    font-weight: 560;
    font-size: clamp(2.4rem, 4vw, 4.2rem);
    max-width: 11ch;
}
.lede { max-width: 34rem; font-size: 1.15rem; color: #eadfce; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card { width: min(440px, 100%); padding: 28px; }
.demo {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.92rem;
}
.demo ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.demo span { display: inline-block; min-width: 5.5rem; color: var(--ink); font-weight: 650; }

@media (max-width: 980px) {
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { gap: 16px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .who { margin-top: 0; }
    .main { padding: 20px; }
    .stats, .ticket-layout, .auth { grid-template-columns: 1fr; }
    .ticket-side { order: -1; }
    .auth-brand { padding: 28px; min-height: auto; }
    .page-head { flex-direction: column; }
    table { display: block; overflow-x: auto; }
}
