:root {
    --bg: #f3efe6;
    --ink: #1c2430;
    --muted: #5e6876;
    --line: #e3dacb;
    --card: #fffdf8;
    --teal: #0e6b67;
    --teal-dark: #0a4e4b;
    --sand: #f7f1e6;
    --amber: #f6e7c8;
    --danger: #8d2f2f;
    --shadow: 0 12px 40px rgba(40, 32, 20, 0.08);
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--teal-dark); }
button, .button {
    background: var(--teal);
    color: white;
    border: 0;
    border-radius: 999px;
    padding: 0.7rem 1.1rem;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.button.ghost, button.ghost { background: transparent; color: var(--teal-dark); border: 1px solid var(--line); }
button:hover, .button:hover { background: var(--teal-dark); }
.guest { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.guest-card, .narrow { width: min(440px, 100%); }
.guest-card { background: var(--card); padding: 2rem; border-radius: 24px; box-shadow: var(--shadow); }
.brand, .brand-block strong { letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #143633; color: #f4efe6; padding: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.side a { color: #f4efe6; text-decoration: none; display: block; padding: 0.55rem 0.7rem; border-radius: 10px; }
.side a:hover { background: rgba(255,255,255,.08); }
.brand-block { display: flex; flex-direction: column; gap: 0.2rem; }
.brand-block span, .logout small { color: #d5c7ae; }
.nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav em { background: #e37b45; color: white; border-radius: 999px; padding: 0 0.4rem; font-style: normal; }
.logout { margin-top: auto; }
.logout button { width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.2); }
.main { padding: 1.2rem; }
.stack, .home-grid { display: flex; flex-direction: column; gap: 1rem; }
.home-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1rem; }
.hero, .panel, .guest-card, .meta { background: var(--card); border-radius: 20px; padding: 1.2rem; box-shadow: var(--shadow); }
.eyebrow { margin: 0; color: var(--teal); font-size: .85rem; }
h1 { margin: 0.2rem 0 0.6rem; font-size: 1.8rem; }
h2 { margin: 0 0 .6rem; font-size: 1.1rem; }
.muted, small { color: var(--muted); }
.actions, .page-head, .composer-bar, .filters, .form.inline { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.page-head { justify-content: space-between; }
.cards { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.cards a, .cards li { display: flex; flex-direction: column; gap: .15rem; background: var(--sand); border-radius: 14px; padding: .8rem; text-decoration: none; color: inherit; }
.form, .filters { display: flex; flex-direction: column; gap: .7rem; }
.form.inline, .filters { flex-direction: row; align-items: end; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .92rem; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 12px; padding: .65rem .75rem; background: white; color: var(--ink); }
textarea { resize: vertical; }
.error { color: var(--danger); margin: 0; }
.flash, .warn, .notice { background: var(--amber); border-radius: 12px; padding: .8rem 1rem; }
.metrics, .report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; }
.metric { background: var(--card); border-radius: 16px; padding: 1rem; text-decoration: none; color: inherit; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.metric strong { font-size: 1.8rem; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.chat { display: flex; flex-direction: column; min-height: calc(100vh - 2.4rem); background: var(--card); border-radius: 20px; overflow: hidden; }
.chat-head, .composer, .quick, .notice { padding: .9rem 1rem; }
.chat-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; border-bottom: 1px solid var(--line); }
.pill { background: var(--sand); border-radius: 999px; padding: .3rem .7rem; }
.log { flex: 1; overflow: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; background: linear-gradient(#f7f4ee, #fff); }
.msg { max-width: min(680px, 90%); background: white; border: 1px solid var(--line); border-radius: 16px; padding: .7rem .85rem; }
.msg header { display: flex; gap: .5rem; align-items: baseline; color: var(--muted); font-size: .8rem; }
.msg p { margin: .35rem 0 0; white-space: pre-wrap; word-break: break-word; }
.msg-user { margin-left: auto; background: #e7f3f2; }
.msg-assistant, .msg-system { background: var(--sand); }
.vis-internal { background: var(--amber); }
.files { margin: .4rem 0 0; padding-left: 1rem; }
.quick { display: flex; gap: .4rem; flex-wrap: wrap; }
.quick form { margin: 0; }
.composer { border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .5rem; }
.composer.note textarea { background: #fff8ea; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .8fr); gap: .8rem; align-items: start; }
.meta { display: flex; flex-direction: column; gap: .7rem; }
.meta dl { display: grid; grid-template-columns: 110px 1fr; gap: .35rem .5rem; margin: 0; }
.history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.history li, .report-grid li { display: flex; flex-direction: column; gap: .1rem; }
.report-grid ul { list-style: none; padding: 0; margin: 0; }
.report-grid li { flex-direction: row; justify-content: space-between; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.prose { white-space: pre-wrap; }
.check { flex-direction: row; align-items: center; }
@media (max-width: 900px) {
    .shell, .home-grid, .ticket-layout { grid-template-columns: 1fr; }
    .side { position: sticky; top: 0; z-index: 2; }
    .nav { flex-direction: row; overflow: auto; }
    .logout { margin-top: 0; }
    .chat { min-height: 70vh; }
}
