:root {
  --bg: #f1f4f9;
  --card: #ffffff;
  --border: #dfe4ec;
  --text: #1c2434;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --blue-bg: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- layout ---------- */
.topbar {
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .logo { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.topbar .logo span { color: #60a5fa; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: #cbd5e1; text-decoration: none; padding: 8px 14px;
  border-radius: 8px; font-size: 14px;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar nav a.active { background: var(--primary); color: #fff; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #e2e8f0; }
.userchip .dept { background: rgba(96,165,250,.2); color: #93c5fd; padding: 3px 9px; border-radius: 999px; font-size: 12px; }
.btn-link { background: none; border: none; color: #94a3b8; font-size: 13px; text-decoration: underline; }
.btn-link:hover { color: #fff; }

.bell { position: relative; background: none; border: none; font-size: 19px; color: #cbd5e1; padding: 4px 6px; }
.bell .badge {
  position: absolute; top: -3px; right: -5px; background: #ef4444; color: #fff;
  font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 5.5px;
}

.container { max-width: 1180px; margin: 0 auto; padding: 26px 24px 60px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* ---------- cards / stats ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; }
.stat .num { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.red .num { color: var(--red); }
.stat.green .num { color: var(--green); }

.dept-loads { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.dept-load { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--muted); }
.dept-load b { color: var(--text); }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; font-size: 13.5px; }
thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); background: #f8fafc; }
tbody tr { border-bottom: 1px solid #eef1f6; cursor: pointer; }
tbody tr:hover { background: #f5f8ff; }
tbody tr:last-child { border-bottom: none; }
td .jobnum { font-weight: 600; color: var(--primary); }
td .jobtitle { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

.badge-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-status { background: var(--blue-bg); color: var(--primary-dark); }
.b-done { background: var(--green-bg); color: var(--green); }
.b-overdue { background: var(--red-bg); color: var(--red); }
.b-dept { background: #ede9fe; color: #6d28d9; }
.b-prio-Low { background: #e2e8f0; color: #475569; }
.b-prio-Medium { background: var(--blue-bg); color: var(--primary-dark); }
.b-prio-High { background: var(--amber-bg); color: var(--amber); }
.b-prio-Urgent { background: var(--red-bg); color: var(--red); }

.progressbar { background: #e2e8f0; border-radius: 999px; height: 6px; width: 90px; overflow: hidden; }
.progressbar > div { background: var(--primary); height: 100%; border-radius: 999px; }
.progressbar.done > div { background: var(--green); }

.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select, .filters input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--primary); color: #fff; border: none;
  padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f8fafc; }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: block; }
label.field .lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
label.field input, label.field select, label.field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
label.field textarea { min-height: 90px; resize: vertical; }
.form-card { padding: 24px; max-width: 720px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }
.error-msg { background: var(--red-bg); color: var(--red); padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 400px; padding: 34px; }
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }

/* ---------- detail page ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }

.detail-head { padding: 20px 24px; margin-bottom: 20px; }
.detail-head .row1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head h1 { font-size: 20px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 16px; }
.meta-grid .m .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.meta-grid .m .v { font-size: 14px; font-weight: 600; margin-top: 3px; }

.section-title { font-size: 15px; font-weight: 700; padding: 16px 20px; border-bottom: 1px solid var(--border); }

/* timeline */
.timeline { padding: 20px 24px; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-item::before {
  content: ""; position: absolute; left: 7px; top: 20px; bottom: 0; width: 2px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 2px; border: 3px solid var(--blue-bg); }
.tl-body .tl-status { font-weight: 600; font-size: 14px; }
.tl-body .tl-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tl-body .tl-note { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; font-size: 13px; margin-top: 7px; color: #334155; }

/* action panel */
.action-panel { padding: 20px; }
.action-panel .owner-line { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }
.action-panel textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; min-height: 70px; resize: vertical; margin-bottom: 12px; }
.hint { font-size: 13px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 12px 14px; }
.overdue-banner { background: var(--red-bg); color: var(--red); font-weight: 600; font-size: 13.5px; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }

/* workflow steps preview */
.steps { padding: 14px 20px 20px; max-height: 420px; overflow-y: auto; }
.step { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; color: var(--muted); }
.step .n { width: 22px; height: 22px; border-radius: 50%; background: #e2e8f0; color: #475569; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step.donestep { color: #94a3b8; text-decoration: line-through; }
.step.donestep .n { background: var(--green-bg); color: var(--green); }
.step.current { color: var(--text); font-weight: 700; }
.step.current .n { background: var(--primary); color: #fff; }

/* notifications dropdown */
.notif-panel {
  position: absolute; right: 24px; top: 60px; width: 380px; max-height: 440px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(16,24,40,.16); z-index: 50; color: var(--text);
}
.notif-panel .np-head { padding: 12px 16px; font-weight: 700; font-size: 14px; border-bottom: 1px solid var(--border); }
.notif-item { padding: 11px 16px; border-bottom: 1px solid #eef1f6; font-size: 13px; }
.notif-item.unread { background: #eff6ff; }
.notif-item .t { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.notif-empty { padding: 24px 16px; color: var(--muted); font-size: 13.5px; text-align: center; }

.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
.modal-card { width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 26px; }
.modal-card h2 { font-size: 18px; margin-bottom: 16px; }
.modal-card .error-msg { margin-bottom: 14px; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-bg); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 100;
}
