:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #1f2733;
    --muted: #6b7280;
    --line: #e3e6ea;
    --brand: #b23a2e;      /* Springfield First red */
    --brand-ink: #8f2c22;
    --accent: #2f4a6d;
    --ok-bg: #e7f6ec; --ok-ink: #1c7a3f;
    --err-bg: #fdeceb; --err-ink: #b3261e;
    --radius: 10px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

/* Top bar */
.topbar {
    display: flex; align-items: center; gap: 24px;
    padding: 12px 24px; background: var(--card);
    border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--brand-ink); text-decoration: none; }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--ink); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--brand); }
.signout { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.signout .who { color: var(--muted); font-size: 14px; }
.signout button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }

.container { max-width: 960px; margin: 32px auto; padding: 0 24px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 24px; margin: 20px 0;
}

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; }
.flash-success { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); color: var(--err-ink); }

/* Dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 20px 0; }
.tile {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; text-decoration: none; color: var(--ink);
}
.tile:hover { border-color: var(--brand); }
.tile-num { font-size: 34px; font-weight: 700; color: var(--accent); }
.tile-label { color: var(--muted); font-size: 14px; }
.tile-action { align-items: flex-start; justify-content: center; }
.tile-plus { font-size: 34px; font-weight: 300; color: var(--brand); }

.checklist { margin: 0; padding-left: 20px; color: var(--muted); }
.checklist li { margin: 6px 0; }

/* Auth */
body.plain { background: linear-gradient(160deg, #f4f5f7, #e9edf2); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-card h1 { color: var(--brand-ink); }
.subtitle { color: var(--muted); margin: 0 0 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.stack input {
    padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px;
}
.btn { display: inline-block; padding: 11px 16px; border-radius: 8px; border: none; font-size: 15px; cursor: pointer; text-decoration: none; text-align: center; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-google { background: #fff; color: var(--ink); border: 1px solid var(--line); width: 100%; }
.btn-google:hover { border-color: var(--accent); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 18px 0; font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Ticket intake form */
.field { margin: 0 0 18px; }
.field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field .req { color: var(--brand); }
.field .hint { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.field input[type=text], .field input[type=url], .field input[type=email],
.field input[type=date], .field input[type=time], .field input[type=datetime-local],
.field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 8px; font: inherit; background: #fff;
}
.field textarea { resize: vertical; }
.field input[type=file] { font: inherit; }
.field-error input, .field-error select, .field-error textarea { border-color: var(--err-ink); }
.err-msg { color: var(--err-ink); font-size: 13px; margin: 6px 0 0; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.btn-plain { background: none; color: var(--muted); border: 1px solid var(--line); }
.btn-plain:hover { color: var(--ink); }

/* Confirmation */
.confirm { text-align: center; max-width: 520px; margin: 40px auto; }
.confirm-check {
    width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px;
    background: var(--ok-bg); color: var(--ok-ink); font-size: 30px;
    display: grid; place-items: center;
}
.ticket-ref { font-size: 18px; margin: 10px 0; }

/* Ticket list */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: #eceef1; border-radius: 8px; padding: 3px; }
.tabs a { padding: 6px 14px; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: 14px; }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.seg-toggle { display: flex; gap: 6px; margin: 14px 0 4px; flex-wrap: wrap; }
.seg { padding: 5px 12px; border: 1px solid var(--line); border-radius: 20px; text-decoration: none; color: var(--muted); font-size: 13px; background: #fff; }
.seg.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.empty { text-align: center; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f8f9fb; }
table.list tbody tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Badges + pills */
.badge, .pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-open { background: #e3f0ff; color: #1c5aa8; }
.status-pending { background: #fff2d9; color: #a6741a; }
.status-closed { background: #e9ecef; color: #5c636a; }
.prio-low { background: #eef1f4; color: #5c636a; }
.prio-normal { background: #e7f6ec; color: #1c7a3f; }
.prio-high { background: #fff2d9; color: #a6741a; }
.prio-urgent { background: #fdeceb; color: #b3261e; }

/* Ticket detail */
.ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ticket-badges { display: flex; gap: 6px; align-items: center; }
.ticket-grid { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }
@media (max-width: 760px) { .ticket-grid { grid-template-columns: 1fr; } }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--muted); font-size: 14px; }
.details dd { margin: 0; font-size: 14px; }
.attach-list { list-style: none; margin: 0; padding: 0; }
.attach-list li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.attach-list li:last-child { border-bottom: none; }

/* Activity thread */
.thread { list-style: none; margin: 0 0 8px; padding: 0; }
.msg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.msg:last-child { border-bottom: none; }
.msg-meta { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 5px; flex-wrap: wrap; }
.msg-body { font-size: 14px; white-space: normal; }
.msg-internal { background: #fffbea; margin: 0 -12px; padding: 12px; border-radius: 8px; border-bottom: none; }
.tag { font-size: 11px; background: #eceef1; color: #5c636a; padding: 1px 7px; border-radius: 10px; }
.tag-internal { background: #fde9b8; color: #8a5a00; }
/* Reply + manage controls */
.reply-form { margin-top: 12px; }
.reply-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; resize: vertical; }
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.chk input { width: auto; }
.closed-note { font-size: 13px; background: #f3f4f6; border-radius: 8px; padding: 8px 12px; }
.inline-form { margin: 0 0 14px; }
.inline-form:last-child { margin-bottom: 0; }
.mini-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 5px; }
.inline-form .row { display: flex; gap: 8px; }
.inline-form select { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }

/* Admin */
.btn-sm { padding: 5px 10px; font-size: 13px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.allow-add { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.allow-add input[type=email] { flex: 1; min-width: 200px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.allow-add select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
