:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e6ed;
  --text: #1c2530;
  --text-dim: #667085;
  --primary: #2857c9;
  --primary-dim: #eef2fd;
  --green: #16794f;
  --green-bg: #e7f7ef;
  --red: #b3261e;
  --red-bg: #fdeceb;
  --amber: #a5590a;
  --amber-bg: #fdf1e2;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#app { min-height: 100vh; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1c3b8f 0%, #2857c9 55%, #4d78e0 100%);
}
.login-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(20, 30, 60, 0.35);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-dim); margin: 0 0 24px; font-size: 13px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; margin: 14px 0 6px; color: var(--text-dim); }
.login-card input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 14px;
}
.login-card button.primary { width: 100%; margin-top: 22px; }
.login-error { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 16px; }
.demo-hint { margin-top: 20px; font-size: 12px; color: var(--text-dim); background: #f7f8fb; border-radius: 8px; padding: 10px 12px; line-height: 1.6; }
.demo-hint code { background: #eceff5; padding: 1px 5px; border-radius: 4px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: #121a2e; color: #cfd6e6;
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar .brand { font-weight: 700; font-size: 15px; color: #fff; padding: 0 8px 20px; }
.sidebar .brand small { display: block; font-weight: 400; color: #8b95ad; font-size: 11px; margin-top: 2px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #cfd6e6; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
}
.sidebar nav a:hover { background: #1c273f; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .who { padding: 12px 8px; border-top: 1px solid #232f4b; margin-top: 10px; }
.sidebar .who .name { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar .who .role { color: #8b95ad; font-size: 11.5px; margin-top: 2px; text-transform: capitalize; }
.sidebar .logout { margin-top: 10px; background: transparent; border: 1px solid #2a3653; color: #cfd6e6; width: 100%; padding: 7px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.sidebar .logout:hover { background: #1c273f; }

.main { flex: 1; padding: 28px 34px; max-width: 1100px; }
.main h1 { font-size: 21px; margin: 0 0 4px; }
.main .page-sub { color: var(--text-dim); margin: 0 0 22px; font-size: 13px; }

/* ---------- Common bits ---------- */
button { font-family: inherit; cursor: pointer; }
button.primary {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 600;
}
button.primary:hover { background: #1f47ab; }
button.secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font-size: 13.5px; font-weight: 600;
}
button.secondary:hover { background: #f4f6fa; }
button.danger { background: var(--red-bg); color: var(--red); border: 1px solid #f3c9c5; border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13.5px; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .label { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.stat-card.warn .num { color: var(--amber); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f7f9fc; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge.pending { background: var(--amber-bg); color: var(--amber); }
.badge.approved { background: var(--green-bg); color: var(--green); }
.badge.rejected { background: var(--red-bg); color: var(--red); }
.badge.urgent { background: var(--red-bg); color: var(--red); margin-left: 6px; }
.badge.delayed { background: var(--red-bg); color: var(--red); margin-left: 6px; }

.filters { display: flex; gap: 10px; margin-bottom: 14px; }
.filters select, .filters input { padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); font-size: 13px; }

.form-grid { display: grid; gap: 14px; max-width: 560px; }
.form-grid label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 13.5px; font-family: inherit; margin-top: 5px;
}
.form-grid textarea { min-height: 90px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.detail-header h1 { margin-bottom: 6px; }
.detail-meta { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }
.detail-meta span { margin-right: 14px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.timeline li:last-child { border-bottom: none; }
.timeline .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink: 0; }
.timeline .dot.approved { background: var(--green); }
.timeline .dot.rejected { background: var(--red); }
.timeline .tl-body { flex: 1; }
.timeline .tl-title { font-weight: 600; font-size: 13.5px; }
.timeline .tl-meta { color: var(--text-dim); font-size: 12px; margin-top: 1px; }
.timeline .tl-comment { margin-top: 5px; font-size: 13.5px; background: #f7f9fc; padding: 8px 10px; border-radius: 7px; }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-dim); margin: 0 0 12px; }

.attachment-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.attachment-item:last-child { border-bottom: none; }
.attachment-item a { color: var(--primary); text-decoration: none; font-weight: 600; }

.empty-state { color: var(--text-dim); font-size: 13.5px; padding: 20px 0; text-align: center; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1c2530; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 50; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .stat-grid { grid-template-columns: repeat(2, 1fr); } }
