/* Municipality Monitoring System - Tacurong City
   Palette taken from the proposal deck: slate blue, powder blue and cream. */
:root {
  --navy: #243457;
  --navy-2: #2f4470;
  --slate: #6683b0;
  --powder: #a9c3e8;
  --powder-2: #dbe6f5;
  --cream: #f6f0ef;
  --paper: #ffffff;
  --ink: #1c2540;
  --muted: #5f6b86;
  --line: #e2dcdc;
  --ok: #2c8a68;
  --warn: #c98a1b;
  --bad: #c4513a;
  --urgent: #a8321f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(36, 52, 87, .08), 0 4px 14px rgba(36, 52, 87, .06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--cream); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
.muted { color: var(--muted); }
small { color: var(--muted); }

/* ---------- Buttons & fields ---------- */
.btn {
  border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 8px 14px;
  cursor: pointer; font-weight: 600; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--powder-2); border-color: var(--powder); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.btn.primary:hover { background: var(--navy); }
.btn.danger { color: var(--bad); border-color: #e7c3bb; }
.btn.danger:hover { background: #fbeae6; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: .55; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--powder); cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: #fff; }
.icon-btn { background: none; border: 0; font-size: 22px; cursor: pointer; color: #fff; }
:focus-visible { outline: 3px solid var(--powder); outline-offset: 2px; }

label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid #cfc8c8; border-radius: 9px; padding: 9px 11px; background: #fff; font-weight: 400; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--powder-2); border-color: var(--slate); }
textarea { resize: vertical; min-height: 84px; }
input[type=checkbox] { width: auto; }
.form-error { color: var(--bad); font-size: 14px; margin: 0; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; background: var(--slate); color: #fff; display: flex; align-items: flex-end; padding: 56px; }
.stripes { position: absolute; border-radius: 50%; background: repeating-linear-gradient(135deg, #f6f0ef 0 12px, transparent 12px 26px); opacity: .9; }
.stripes.s1 { width: 340px; height: 340px; top: -150px; left: -130px; }
.stripes.s2 { width: 300px; height: 300px; right: -120px; bottom: -120px; opacity: .55; }
.login-art-text { position: relative; max-width: 460px; }
.login-art h1 { font-size: clamp(30px, 4vw, 46px); font-weight: 700; letter-spacing: -.01em; margin: 6px 0 14px; text-transform: uppercase; }
.login-art p { margin: 0; font-size: 17px; color: #eef3fb; }
.login-art .eyebrow { letter-spacing: .2em; text-transform: uppercase; font-size: 13px; font-weight: 700; color: var(--powder-2); }
.login-panel { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; background: var(--paper); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); }
.login-card h2 { font-size: 26px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.topbar { display: none; }
.sidebar { background: var(--navy); color: #dfe7f6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 14px; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand strong { display: block; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: #fff; line-height: 1.25; }
.brand small { color: var(--powder); }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: var(--slate); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .02em; flex: none; }
.nav { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 3px; overflow-y: auto; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 9px; color: #dfe7f6; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: var(--slate); color: #fff; font-weight: 700; }
.nav .count { background: var(--bad); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.user-box { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.user-name { font-weight: 700; color: #fff; }
.user-role { font-size: 13px; color: var(--powder); margin-bottom: 8px; }
.user-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.content { padding: 28px 32px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards / stats ---------- */
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border-left: 5px solid var(--slate); text-decoration: none; color: inherit; display: block; }
.stat:hover { box-shadow: 0 2px 4px rgba(36,52,87,.12), 0 8px 20px rgba(36,52,87,.1); }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .num { font-size: 32px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat.ok { border-color: var(--ok); } .stat.bad { border-color: var(--bad); } .stat.warn { border-color: var(--warn); }
.two-col { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* segmented status bars */
.seg-row { margin-bottom: 18px; }
.seg-row h3 { font-size: 14px; display: flex; justify-content: space-between; margin-bottom: 8px; }
.seg { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--powder-2); }
.seg span { display: block; min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* status colours */
.c-pending, .c-received, .c-reported { --c: #8d9ab5; }
.c-ongoing, .c-in_progress, .c-in_review, .c-responding { --c: #4f78c0; }
.c-completed, .c-resolved { --c: #2c8a68; }
.c-delayed { --c: #c4513a; }
.c-closed { --c: #6b7385; }
.c-low { --c: #8d9ab5; } .c-medium { --c: #4f78c0; } .c-high { --c: #c98a1b; } .c-urgent { --c: #a8321f; }
.seg .c, .legend .c { background: var(--c); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, white); }
.badge.overdue { --c: #c4513a; }

/* progress */
.bar { height: 8px; background: var(--powder-2); border-radius: 4px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--slate); border-radius: 4px; }
.bar.done > i { background: var(--ok); }
.prog { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.prog .bar { flex: 1; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list li { padding: 11px 0; border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.list li:last-child { border-bottom: 0; }
.list a.row-link { text-decoration: none; color: inherit; display: grid; gap: 3px; }
.list a.row-link:hover strong { text-decoration: underline; }
.row-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ---------- Tables ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.toolbar > * { flex: 0 1 170px; }
.toolbar .grow { flex: 1 1 240px; }
.toolbar .check { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding-bottom: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 5px 13px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip b { margin-left: 4px; color: var(--muted); }
.chip.on { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.chip.on b { color: var(--powder-2); }
.table-wrap { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: #faf7f7; white-space: nowrap; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f3f7fd; }
td small { display: block; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.date-over { color: var(--bad); font-weight: 700; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(28, 37, 64, .5); display: grid; place-items: start center; padding: 4vh 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--paper); border-radius: 16px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 20px 24px 12px; }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 4px 24px 24px; }
.x { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; margin: 14px 0; }
.detail-grid dt { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.detail-grid dd { margin: 2px 0 0; }
.sect { margin-top: 22px; }
.sect h3 { font-size: 15px; margin-bottom: 10px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--powder); display: grid; gap: 14px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--slate); border: 2px solid #fff; }
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline p { margin: 3px 0 0; white-space: pre-wrap; }
.update-box { background: var(--cream); border-radius: 12px; padding: 16px; }

/* ---------- Alerts ---------- */
.alert-item { display: grid; grid-template-columns: 6px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; background: var(--paper); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 10px; text-decoration: none; color: inherit; }
.alert-item:hover { background: #f3f7fd; }
.alert-item .sev { align-self: stretch; border-radius: 3px; background: var(--warn); }
.alert-item.high .sev { background: var(--bad); }
.alert-item strong { display: block; }

/* ---------- Reports ---------- */
.report { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.report h2 { font-size: 20px; }
.report h3 { margin: 24px 0 10px; font-size: 15px; }
.report table th { position: static; }
.kv { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 12px; }
.kv div { min-width: 120px; } .kv b { display: block; font-size: 24px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 340px; }
.toast.error { background: var(--bad); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 220px; padding: 28px; }
  .app { grid-template-columns: 1fr; }
  .topbar { display: flex; align-items: center; gap: 12px; background: var(--navy); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 20; }
  .topbar-title { font-weight: 700; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(28,37,64,.45); }
  .content { padding: 18px 14px 50px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .report { box-shadow: none; padding: 0; }
  .card, .table-wrap { box-shadow: none; }
}
