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

:root {
  --brand:  #1a3c5e;
  --brand2: #2563eb;
  --sb:     220px;
  --hh:     56px;
  --bg:     #f1f5f9;
  --card:   #fff;
  --bdr:    #e2e8f0;
  --txt:    #1e293b;
  --mut:    #64748b;
  --err:    #ef4444;
  --ok:     #22c55e;
  --r:      8px;
  --sh:     0 1px 3px rgba(0,0,0,.1);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--txt);
  background: var(--bg);
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */

#app { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sb);
  background: var(--brand);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .2s;
}

#sidebar .logo {
  padding: 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .3px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar nav a {
  display: block;
  padding: 9px 16px;
  color: rgba(255,255,255,.78);
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: background .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar nav a:hover,
#sidebar nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: #60a5fa;
}

#sidebar .sb-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.12);
}

#main-wrap {
  margin-left: var(--sb);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#topbar {
  height: var(--hh);
  background: #fff;
  border-bottom: 1px solid var(--bdr);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 12px;
}

#topbar .page-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

#content { padding: 20px; flex: 1; min-width: 0; }

/* ── Cards & Grids ───────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--sh);
  border: 1px solid var(--bdr);
  padding: 18px;
  margin-bottom: 16px;
}

.ct { font-size: 14px; font-weight: 600; margin-bottom: 14px; }

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  background: var(--card);
  border-radius: var(--r);
  border: 1px solid var(--bdr);
  padding: 16px;
  box-shadow: var(--sh);
  min-width: 0;
}

.stat-l {
  font-size: 11px;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-v {
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Tables ──────────────────────────────────────────────────────────────────── */

.tw { overflow-x: auto; width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--bdr);
  font-weight: 600;
  color: var(--mut);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  background: #fafafa;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--bdr);
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */

.b {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.b-draft             { background: #f1f5f9; color: #64748b; }
.b-submitted         { background: #dbeafe; color: #1d4ed8; }
.b-am_approved,
.b-clm_approved      { background: #fef9c3; color: #854d0e; }
.b-finance_approved,
.b-locked            { background: #dcfce7; color: #15803d; }
.b-rejected          { background: #fee2e2; color: #b91c1c; }
.b-active,
.b-approved,
.b-completed         { background: #dcfce7; color: #15803d; }
.b-inactive,
.b-cancelled         { background: #fee2e2; color: #b91c1c; }
.b-pending,
.b-in_progress       { background: #fef9c3; color: #854d0e; }
.b-invoiced          { background: #e0e7ff; color: #4338ca; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s;
}

.btn:hover  { opacity: .85; }
.btn-p      { background: var(--brand2); color: #fff; }
.btn-ok     { background: #16a34a; color: #fff; }
.btn-err    { background: var(--err); color: #fff; }
.btn-g      { background: #f1f5f9; color: var(--txt); border: 1px solid var(--bdr); }
.btn-sm     { padding: 4px 10px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */

.fg { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }

.fg label {
  font-size: 11px;
  font-weight: 600;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .4px;
}

input, select, textarea {
  border: 1px solid var(--bdr);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--txt);
  width: 100%;
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand2);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

textarea { resize: vertical; min-height: 72px; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */

.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-bg.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.mh {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}

.mh h3 {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mc {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--mut);
  flex-shrink: 0;
  line-height: 1;
}

/* ── Login ───────────────────────────────────────────────────────────────────── */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand) 0%, #2563eb 100%);
  padding: 16px;
}

#login-box {
  background: #fff;
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 25px 60px rgba(0,0,0,.3);
}

#login-box h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: var(--brand); }
#login-box .sub { font-size: 13px; color: var(--mut); margin-bottom: 24px; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */

.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.ae    { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.as    { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }

/* ── Utilities ───────────────────────────────────────────────────────────────── */

.row    { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tr     { text-align: right; }
.ok     { color: #16a34a; }
.er     { color: var(--err); }
.mu     { color: var(--mut); }
.sm     { font-size: 12px; }
.w100   { width: 100%; justify-content: center; }
.mb3    { margin-bottom: 12px; }
.mt3    { margin-top: 12px; }
.hidden { display: none; }

code {
  font-family: monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  :root { --sb: 0px; }
  #sidebar { transform: translateX(-220px); }
  #main-wrap { margin-left: 0; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  #content { padding: 12px; }
}
