@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Brand ── */
:root {
  --brand-blue:    #1B5EAE;
  --brand-blue-dk: #0D3A72;
  --brand-navy:    #09243F;
  --brand-yellow:  #F5C300;
  --brand-yellow2: #FFD740;

  --bg:        #EEF2F7;
  --card:      #FFFFFF;
  --border:    #DDE4EE;
  --border-xs: #EDF0F5;

  --txt:       #0D1E31;
  --txt-2:     #4E637A;
  --txt-3:     #8FA0B3;

  --sw: 232px;   /* sidebar width  */
  --th: 56px;    /* topbar height  */
  --r:  10px;    /* border-radius  */
  --rs: 7px;

  --sh0: 0 1px 3px rgba(13,36,63,.06);
  --sh1: 0 4px 16px rgba(13,36,63,.10);
}

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

html { font-size: 14px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-blue); text-decoration: none; }
a:hover { color: #2472CC; }

/* ════════════════════════════
   LAYOUT
════════════════════════════ */
#app { display: flex; min-height: 100vh; }

/* ════════════════════════════
   SIDEBAR
════════════════════════════ */
#sb {
  width: var(--sw);
  background: var(--brand-navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 300;
  transition: transform .22s ease;
  overflow-y: auto;
}

/* Logo bar */
.sb-logo {
  display: flex;
  align-items: center;
  height: var(--th);
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  gap: 10px;
  text-decoration: none;
}
.sb-logo img {
  height: 30px;
  width: auto;
  flex-shrink: 0;
}
.sb-logo-txt {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -.1px;
}
.sb-logo-sub {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255,255,255,.35);
  letter-spacing: .4px;
  text-transform: uppercase;
  display: block;
}

/* Nav */
.sb-nav { flex: 1; padding: 8px 10px; }
.sb-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 14px 8px 4px;
  display: block;
}
.sb-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--rs);
  color: rgba(255,255,255,.58);
  font-size: 13px;
  font-weight: 500;
  transition: background .14s, color .14s;
  margin-bottom: 1px;
  border: none;
  width: 100%;
  background: none;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.sb-link i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.sb-link:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); text-decoration: none; }
.sb-link.active { background: var(--brand-yellow); color: var(--brand-navy); font-weight: 700; }
.sb-link.active:hover { background: var(--brand-yellow2); color: var(--brand-navy); }
.sb-toggle .sb-chev { margin-left: auto; font-size: 10px; transition: transform .2s; }
.sb-toggle[aria-expanded="true"] .sb-chev { transform: rotate(180deg); }
.sb-toggle[aria-expanded="true"] { color: rgba(255,255,255,.9); }
.sb-sub { padding-left: 36px; font-size: 12.5px; }

/* Footer */
.sb-foot {
  padding: 10px 10px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 8px 10px;
}
.sb-avatar {
  width: 32px; height: 32px;
  background: var(--brand-yellow);
  color: var(--brand-navy);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  flex-shrink: 0;
}
.sb-uname { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.82); line-height: 1.2; }
.sb-urole { font-size: 10.5px; color: rgba(255,255,255,.35); }

/* ════════════════════════════
   PAGE SHELL
════════════════════════════ */
#shell {
  margin-left: var(--sw);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ════════════════════════════
   TOPBAR
════════════════════════════ */
.topbar {
  height: var(--th);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--sh0);
}
.tb-toggle {
  display: none;
  background: none; border: none;
  font-size: 20px; color: var(--txt-2);
  cursor: pointer; padding: 2px; flex-shrink: 0;
}
.tb-search {
  flex: 1; max-width: 360px;
}
.tb-search form {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.tb-search input {
  flex: 1; border: none; background: transparent;
  padding: 7px 13px; font-size: 13px; font-family: inherit;
  color: var(--txt); outline: none;
}
.tb-search input::placeholder { color: var(--txt-3); }
.tb-search button {
  border: none; background: transparent;
  padding: 0 12px; color: var(--txt-3); cursor: pointer;
  transition: color .14s; font-size: 14px;
}
.tb-search button:hover { color: var(--brand-blue); }
.tb-gap { flex: 1; }
.btn-cta {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-blue); color: #fff;
  padding: 7px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; border: none;
  cursor: pointer; white-space: nowrap;
  transition: background .14s; text-decoration: none;
}
.btn-cta:hover { background: #2472CC; color: #fff; text-decoration: none; }

/* ════════════════════════════
   MAIN
════════════════════════════ */
.main { flex: 1; padding: 26px 26px 48px; }

/* ════════════════════════════
   PAGE HEADER
════════════════════════════ */
.ph {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 14px;
}
.ph-title { font-size: 20px; font-weight: 700; color: var(--txt); }
.ph-sub { font-size: 12.5px; color: var(--txt-2); margin-top: 1px; }
.ph-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.back {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--txt-2); margin-bottom: 8px;
  transition: color .14s;
}
.back:hover { color: var(--brand-blue); text-decoration: none; }

/* ════════════════════════════
   CARDS
════════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh0);
}
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-xs);
  font-size: 13px; font-weight: 700; color: var(--txt);
}
.card-h-ico {
  width: 26px; height: 26px;
  background: rgba(27,94,174,.1); color: var(--brand-blue);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; margin-right: 8px;
}
.card-b { padding: 18px; }

/* ════════════════════════════
   STAT CARDS
════════════════════════════ */
.sc {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--sh0);
  transition: box-shadow .18s, transform .18s;
}
.sc:hover { box-shadow: var(--sh1); transform: translateY(-2px); }
.sc-ico {
  width: 46px; height: 46px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.sc-ico.y { background: rgba(245,195,0,.14); color: #9A7800; }
.sc-ico.b { background: rgba(27,94,174,.12); color: var(--brand-blue); }
.sc-ico.g { background: rgba(22,163,74,.11);  color: #16A34A; }
.sc-ico.s { background: rgba(100,116,139,.1); color: #64748B; }
.sc-n { font-size: 28px; font-weight: 800; color: var(--txt); line-height: 1; }
.sc-l { font-size: 12px; color: var(--txt-2); font-weight: 500; margin-top: 2px; }

/* ════════════════════════════
   BUTTONS
════════════════════════════ */
.btn { font-family: inherit; font-weight: 500; font-size: 13px; border-radius: var(--rs); transition: all .14s; }
.btn-primary   { background: var(--brand-blue);   border-color: var(--brand-blue);   color: #fff; }
.btn-primary:hover  { background: #2472CC; border-color: #2472CC; color: #fff; }
.btn-warning   { background: var(--brand-yellow);  border-color: #C9A000; color: var(--brand-navy); font-weight: 600; }
.btn-warning:hover  { background: var(--brand-yellow2); color: var(--brand-navy); }
.btn-outline-primary  { color: var(--brand-blue); border-color: var(--brand-blue); }
.btn-outline-primary:hover  { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.btn-outline-secondary { color: var(--txt-2); border-color: var(--border); background: #fff; }
.btn-outline-secondary:hover { background: var(--bg); color: var(--txt); }
.btn-outline-danger { color: #DC2626; border-color: #DC2626; }
.btn-outline-danger:hover { background: #DC2626; color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-ico { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ════════════════════════════
   TABLE
════════════════════════════ */
.tcard {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh0); overflow: hidden;
}
.table { margin: 0; font-size: 13px; }
.table thead th {
  background: #F3F6FA;
  border-bottom: 1px solid var(--border); border-top: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: .55px;
  text-transform: uppercase; color: var(--txt-2);
  padding: 9px 15px; white-space: nowrap;
}
.table tbody td {
  padding: 11px 15px;
  border-bottom: 1px solid var(--border-xs);
  vertical-align: middle; color: var(--txt);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #F8FAFD; }
.onum {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 500;
  background: rgba(27,94,174,.08); color: var(--brand-blue);
  padding: 3px 8px; border-radius: 5px; white-space: nowrap;
}
.amt { font-family: 'JetBrains Mono', monospace; font-size: 13px; }

/* ════════════════════════════
   STATUS BADGES
════════════════════════════ */
.sb {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.sb::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: .65; flex-shrink: 0;
}
.s-neu      { background: #1E2D3D; color: #fff; }
.s-prog     { background: var(--brand-yellow); color: #5A3C00; }
.s-wait     { background: #EA580C; color: #fff; }
.s-done     { background: #16A34A; color: #fff; }
.s-cancel   { background: #DC2626; color: #fff; }
.s-inv-draft   { background: #1E2D3D; color: #fff; }
.s-inv-sent    { background: var(--brand-yellow); color: #5A3C00; }
.s-inv-paid    { background: #16A34A; color: #fff; }
.s-inv-cancel  { background: #DC2626; color: #fff; }

/* ════════════════════════════
   FORMS
════════════════════════════ */
.form-label {
  font-size: 11.5px; font-weight: 600; color: var(--txt-2);
  margin-bottom: 4px; letter-spacing: .2px; text-transform: uppercase;
}
.form-control, .form-select {
  font-size: 13px; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--rs);
  padding: 8px 11px; color: var(--txt); background: #FDFDFF;
  transition: border-color .14s, box-shadow .14s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(27,94,174,.11);
  background: #fff; outline: none;
}
textarea.form-control { min-height: 88px; resize: vertical; }
.fsec {
  font-size: 10.5px; font-weight: 700; letter-spacing: .7px;
  text-transform: uppercase; color: var(--txt-2);
  padding-bottom: 8px; border-bottom: 1px solid var(--border-xs);
  margin-bottom: 14px; margin-top: 6px;
}

/* ════════════════════════════
   DETAIL VIEW
════════════════════════════ */
.dl { margin: 0; }
.dl dt { font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--txt-2); margin-bottom: 2px; margin-top: 13px; }
.dl dt:first-child { margin-top: 0; }
.dl dd { font-size: 13.5px; font-weight: 500; color: var(--txt); margin: 0; }

/* ════════════════════════════
   NOTES
════════════════════════════ */
.note {
  padding: 11px 13px;
  background: #F6F9FD;
  border-left: 3px solid var(--brand-yellow);
  border-radius: 0 var(--rs) var(--rs) 0;
  margin-bottom: 8px;
}
.note-m { font-size: 11px; color: var(--txt-2); font-weight: 600; margin-bottom: 3px; }
.note-t { font-size: 13.5px; color: var(--txt); line-height: 1.55; }

/* ════════════════════════════
   ITEM ROWS (docs / invoices)
════════════════════════════ */
.irow {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-xs);
  transition: background .12s;
}
.irow:last-child { border-bottom: none; }
.irow:hover { background: #F8FAFD; }
.iico {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.iico.pdf   { background: rgba(220,38,38,.1);   color: #DC2626; }
.iico.inv   { background: rgba(27,94,174,.1);   color: var(--brand-blue); }
.iico.co    { background: rgba(27,94,174,.08);  color: var(--brand-blue); }
.iico.map   { background: rgba(100,116,139,.1); color: #64748B; }
.ititle { font-size: 13px; font-weight: 600; color: var(--txt); }
.isub   { font-size: 11.5px; color: var(--txt-2); margin-top: 1px; }
.iend   { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ════════════════════════════
   ALERTS
════════════════════════════ */
.alert {
  border: none; border-radius: var(--rs);
  font-size: 13px; padding: 11px 15px;
  border-left: 3px solid transparent;
}
.alert-success { background: #ECFDF5; color: #065F46; border-left-color: #16A34A; }
.alert-danger  { background: #FEF2F2; color: #7F1D1D; border-left-color: #DC2626; }
.alert-warning { background: #FFFBEA; color: #713F12; border-left-color: #D97706; }
.alert-info    { background: #EFF6FF; color: #1E3A5F; border-left-color: var(--brand-blue); }

/* ════════════════════════════
   FILTER BAR
════════════════════════════ */
.fbar {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 13px 18px;
  margin-bottom: 14px; box-shadow: var(--sh0);
}
.fbar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.fg { display: flex; flex-direction: column; gap: 4px; }
.fg-grow { flex: 1; min-width: 180px; }
.flabel { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--txt-2); }

/* ════════════════════════════
   EMPTY STATE
════════════════════════════ */
.empty { text-align: center; padding: 48px 20px; color: var(--txt-2); }
.empty i { font-size: 36px; opacity: .2; display: block; margin-bottom: 10px; }
.empty p { font-size: 13px; }

/* ════════════════════════════
   LOGIN
════════════════════════════ */
.lw {
  min-height: 100vh;
  background: linear-gradient(140deg, var(--brand-navy) 0%, #0D3A72 60%, #0A2A54 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative; overflow: hidden;
}
.lw::before {
  content: ''; position: absolute;
  top: -20%; right: -10%;
  width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(245,195,0,.16) 0%, transparent 60%);
  pointer-events: none;
}
.lcard {
  background: #fff; border-radius: 14px; padding: 38px;
  width: 100%; max-width: 400px;
  box-shadow: 0 28px 64px rgba(0,0,0,.28);
  position: relative; z-index: 1;
}
.llogo { text-align: center; margin-bottom: 26px; }
.llogo img { height: 44px; width: auto; }
.ltitle { font-size: 19px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.lsub   { font-size: 13px; color: var(--txt-2); text-align: center; margin-bottom: 24px; }
.ldemo {
  margin-top: 18px; padding: 13px 15px;
  background: var(--bg); border-radius: var(--rs);
  border: 1px solid var(--border); font-size: 12px; color: var(--txt-2);
}
.ldemo strong { display: block; margin-bottom: 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--txt); }
.ldemo code {
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--brand-blue-dk);
}

/* ════════════════════════════
   FOOTER
════════════════════════════ */
.foot { padding: 13px 26px; font-size: 11.5px; color: var(--txt-3); text-align: center; border-top: 1px solid var(--border); }

/* ════════════════════════════
   RESPONSIVE
════════════════════════════ */
@media (max-width: 991px) {
  #sb { transform: translateX(-100%); }
  #sb.open { transform: translateX(0); box-shadow: 6px 0 28px rgba(0,0,0,.22); }
  #shell { margin-left: 0; }
  .tb-toggle { display: block; }
  .main { padding: 18px 14px 36px; }
  .ph { flex-direction: column; align-items: stretch; }
}

/* ════════════════════════════
   UTILS
════════════════════════════ */
.fw5 { font-weight: 500; }
.fw6 { font-weight: 600; }
.fw7 { font-weight: 700; }
.mono { font-family: 'JetBrains Mono', monospace; }
.muted { color: var(--txt-2) !important; }
.small13 { font-size: 13px; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C8D4E0; border-radius: 3px; }

/* ════════════════════════════
   VIEW TRANSITIONS
   Cross-document fade so tab switching never shows a white flash.
   Supported in Chrome 126+, Edge 126+, Safari 18.2+.
   Falls back gracefully (instant nav) in unsupported browsers.
════════════════════════════ */
@view-transition {
  navigation: auto;
}
/* Keep the fade snappy — 120 ms feels instant, 300 ms feels sluggish */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 120ms;
  animation-timing-function: ease-out;
}
