:root {
  --ink: #17202e; --muted: #687386; --line: #e8ebef; --blue: #205ed6; --deep: #103c9a;
  --nav: #101b31; --panel: #fff; --canvas: #f6f8fb; --red: #df3b45; --green: #159e75; --orange: #e87f21;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

/* ---- Auth pages ---- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--nav), #1c2b4a); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 40px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.auth-card p.sub { margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.auth-demo { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.auth-demo code { background: #f2f4f7; padding: 2px 5px; border-radius: 4px; }

/* ---- App shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 246px; flex: 0 0 auto; background: var(--nav); color: #d9e4ff; padding: 22px 14px; display: flex; flex-direction: column; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 16px; text-decoration: none; }
.sidebar .brand-mark { width: 32px; height: 32px; border-radius: 9px; background: #2967df; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; }
.sidebar .brand strong { display: block; color: #fff; font-size: 14px; }
.sidebar .brand small { color: #91a4c8; font-size: 10px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #aebbd2; text-decoration: none; font-size: 13px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: #285ac1; color: #fff; }
.sidebar .user-box { margin-top: 14px; padding: 12px; background: rgba(255,255,255,.05); border-radius: 10px; font-size: 12px; }
.sidebar .user-box strong { display: block; color: #fff; }
.sidebar .user-box small { color: #91a4c8; }
.sidebar form.logout { margin-top: 8px; }
.sidebar form.logout button { width: 100%; background: rgba(255,255,255,.06); border: 0; color: #cdd7ea; padding: 8px; border-radius: 7px; font-size: 12px; }

.content { flex: 1; min-width: 0; }
.topbar { height: 62px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; }
.topbar h1 { font-size: 16px; margin: 0; }
.page { padding: 28px; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { color: var(--blue); font-size: 10px; letter-spacing: .1em; font-weight: 800; margin: 0 0 6px; text-transform: uppercase; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600; background: #fff; color: var(--ink); text-decoration: none; }
.btn:hover { background: #f7f9fc; }
.btn-primary { background: linear-gradient(135deg, #2869df, #174db6); border-color: #164cad; color: #fff; }
.btn-primary:hover { background: #174db6; }
.btn-danger { background: #fff0f0; border-color: #ffd6d6; color: #c53434; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Cards / tables ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1000px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }

.metric { padding: 18px; }
.metric p { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric strong { display: block; font-size: 26px; }
.metric small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; padding: 10px 14px; background: #fafbfc; color: #909aab; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
table.data td { padding: 12px 14px; border-bottom: 1px solid #f0f2f5; font-size: 13px; vertical-align: middle; }
table.data tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.empty { padding: 36px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---- Pills ---- */
.pill { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.pill-critical { background: #fff0f1; color: #ce3540; } .pill-high { background: #fff5e9; color: #d2731e; }
.pill-medium { background: #eef5ff; color: #2c68cd; } .pill-low { background: #eef8f4; color: #15986f; }
.pill-new { background: #f3f0ff; color: #7359c9; } .pill-acknowledged, .pill-assigned { background: #edf4ff; color: #2767c8; }
.pill-in_progress { background: #fff6ea; color: #d4761d; } .pill-waiting_for_citizen { background: #fffbe6; color: #a17a12; }
.pill-forwarded { background: #f1efff; color: #5b4dc4; } .pill-resolved { background: #e9f8f1; color: #148e67; }
.pill-closed { background: #eef0f3; color: #5b6472; } .pill-rejected { background: #fdeeee; color: #c53434; }
.pill-active { background: #e9f8f1; color: #148e67; } .pill-inactive { background: #eef0f3; color: #5b6472; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid #d9e0e9; border-radius: 7px; font-size: 13px; background: #fff; }
.field textarea { resize: vertical; }
.field .hint { margin-top: 5px; font-size: 11px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: #c53434; font-size: 12px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters input, .filters select { padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.filters input[type="text"] { min-width: 220px; flex: 1; }

.messages { margin-bottom: 18px; }
.messages .msg { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.messages .msg-success { background: #eafaf1; color: #148e67; border: 1px solid #cdeee0; }
.messages .msg-error { background: #fdeeee; color: #c53434; border: 1px solid #f6cccc; }
.messages .msg-info { background: #eef5ff; color: #2767c8; border: 1px solid #cfe1fb; }

/* ---- Detail / timeline ---- */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline-item { display: flex; gap: 10px; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex: 0 0 auto; }
.timeline-item p { margin: 0; font-size: 13px; }
.timeline-item small { color: var(--muted); font-size: 11px; }
.msg-bubble { padding: 12px; border-radius: 9px; background: #eef5ff; margin-bottom: 10px; }
.msg-bubble.internal { background: #fffbe6; }
.msg-bubble p { margin: 0 0 6px; font-size: 13px; }
.msg-bubble small { color: var(--muted); font-size: 11px; }

/* ---- Public / citizen pages ---- */
.public-shell { min-height: 100vh; background: #f6f8fb; }
.public-header { background: #fff; border-bottom: 1px solid var(--line); padding: 26px 20px; text-align: center; }
.public-header img.logo { width: 60px; height: 60px; border-radius: 12px; object-fit: cover; margin-bottom: 10px; }
.public-logo-fallback { width: 60px; height: 60px; border-radius: 12px; background: var(--blue); color: #fff; font-size: 22px; font-weight: 800; display: grid; place-items: center; margin: 0 auto 10px; }
.public-form { max-width: 460px; margin: 0 auto; padding: 24px 18px 50px; }
.public-form h1 { font-size: 20px; margin: 0 0 4px; }
.public-form p.lead { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.public-form .field input, .public-form .field select, .public-form .field textarea { padding: 13px; font-size: 15px; border-radius: 10px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; }
.checkbox-row input { width: auto; }

.success-card { max-width: 420px; margin: 60px auto; background: #fff; border-radius: 16px; padding: 34px 28px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.success-icon { width: 56px; height: 56px; border-radius: 50%; background: #e9f8f1; color: #159e75; font-size: 28px; display: grid; place-items: center; margin: 0 auto 14px; }
.ref-box { background: #f6f8fb; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 18px 0; }
.ref-box p { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ref-box strong { font-family: ui-monospace, monospace; font-size: 20px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; align-items: center; padding: 10px 14px; }
  .sidebar .brand { border-bottom: 0; margin-bottom: 0; padding: 0 12px 0 0; }
  .sidebar nav { flex-direction: row; }
  .sidebar .user-box, .sidebar form.logout { display: none; }
  .page { padding: 18px; }
}
