/* ===================== NCCMR Tracker — Brand Theme ===================== */
:root {
  --navy: #1F3D7A;
  --navy-dark: #162d5a;
  --navy-light: #2f55a3;
  --orange: #F2941D;
  --orange-dark: #d97e0c;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e3e8f0;
  --green: #1f9d57;
  --red: #d64545;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(31, 61, 122, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ----------------------- Buttons ----------------------- */
.btn {
  border: none; border-radius: 9px; padding: 10px 16px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: .15s; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-outline { background: #fff; color: var(--navy); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-ghost:hover { background: rgba(31,61,122,.08); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ----------------------- Login ----------------------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
}
.login-card {
  background: #fff; border-radius: 18px; padding: 36px 32px; width: 360px;
  max-width: 90vw; box-shadow: 0 12px 40px rgba(0,0,0,.25); text-align: center;
}
.login-logo { width: 92px; height: 92px; object-fit: contain; }
.login-card h1 { margin: 8px 0 2px; color: var(--navy); font-size: 22px; }
.login-card form { margin-top: 20px; text-align: left; }
.login-card label, .modal-body label {
  display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 14px;
}
.login-card input, .modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; margin-top: 6px; padding: 11px 12px; border: 1.5px solid var(--border);
  border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff;
}
.login-card input:focus,
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 148, 29, .18);
}
.modal-body input:invalid:not(:placeholder-shown),
.modal-body select:invalid:not(:placeholder-shown) {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(214, 69, 69, .12);
}
.login-foot { color: rgba(255,255,255,.7); font-size: 12px; }
.error-msg { color: #ffd2d2; background: var(--red); border-radius: 8px; padding: 0; margin-top: 8px;
  font-size: 13px; text-align: center; overflow: hidden; max-height: 0; transition: .2s; }
.error-msg.show { padding: 9px; max-height: 60px; }

/* ----------------------- App shell ----------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--navy); color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; font-weight: 800; font-size: 18px; }
.brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  color: rgba(255,255,255,.82); text-decoration: none; padding: 11px 14px;
  border-radius: 9px; font-weight: 600; font-size: 14px; transition: .15s;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: var(--orange); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.15); padding-top: 14px; display: flex;
  flex-direction: column; gap: 8px; }
.sidebar-foot .muted { color: rgba(255,255,255,.7); font-size: 13px; }
.sidebar-foot .btn-ghost { color: #fff; border: 1px solid rgba(255,255,255,.25); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px 24px;
  background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar h2 { margin: 0; color: var(--navy); font-size: 19px; flex: 1; }
.status-pill { font-size: 12px; color: var(--muted); }
.view { padding: 24px; }

/* ----------------------- Cards ----------------------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card h3 { margin: 0 0 12px; color: var(--navy); font-size: 16px; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-val { font-size: 26px; font-weight: 800; color: var(--navy); }
.stat.highlight { background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%); }
.stat.highlight .stat-label, .stat.highlight .stat-val { color: #fff; }
.stat.stat-over { background: linear-gradient(135deg, var(--red) 0%, #b83535 100%); }
.cards .card { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.progress { height: 14px; background: #eef1f7; border-radius: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--green); width: 0; transition: width .4s; }
.progress-bar.warn { background: var(--orange); }
.progress-bar.over { background: var(--red); }

.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mini-row:last-child { border-bottom: none; }
.mini-row .amt { font-weight: 700; color: var(--navy); }

/* ----------------------- Toolbar + tables ----------------------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search { flex: 1; min-width: 180px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 14px; }
.filter { padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 14px; background: #fff; }
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 13px 14px; background: #f7f9fc; color: var(--navy);
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tr:hover td { background: #fafbfe; }
.data-table .row-actions { display: flex; gap: 6px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #eef1f7; color: var(--muted); }
.badge.pending { background: #fff4e0; color: var(--orange-dark); }
.badge.approved { background: #e3f0ff; color: var(--navy); }
.badge.reimbursed { background: #e4f6ec; color: var(--green); }
.badge-cat { background: #eef1f7; color: var(--navy); }
.usd { font-weight: 700; color: var(--navy); }
.cell-desc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .num { text-align: right; }

/* ----------------------- Modal ----------------------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex;
  align-items: flex-start; justify-content: center; padding: 30px 16px; z-index: 50; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 16px; width: 540px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px;
  border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; color: var(--navy); }
.modal-close { border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-body textarea { resize: vertical; min-height: 60px; }
.rate-row { display: flex; gap: 8px; align-items: flex-end; }
.rate-row .grow { flex: 1; }
.usd-preview { background: #f1f5ff; border-radius: 9px; padding: 10px 12px; margin-bottom: 14px;
  font-weight: 700; color: var(--navy); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 100; font-weight: 600;
  display: flex; align-items: center; gap: 10px; }
.toast-icon { font-size: 15px; font-weight: 900; flex-shrink: 0; line-height: 1; }
.toast.err { background: var(--red); }
.toast.ok  { background: var(--green); }
.toast:not(.hidden) { animation: toast-in .18s ease-out; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%); }
}

.only-mobile { display: none; }

/* ----------------------- Responsive ----------------------- */
@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; z-index: 40; transition: left .25s; height: 100%; }
  .sidebar.open { left: 0; }
  .only-mobile { display: inline-flex; }
  .cards { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-val { font-size: 22px; }
  .toolbar .search  { flex: 1 1 100%; min-width: 0; }
  .toolbar .filter  { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .toolbar .btn-primary { flex: 1 1 100%; }
  .modal { padding: 12px 10px; }
  .modal-body { padding: 16px; }
}

/* ----------------------- Print ----------------------- */
@media print {
  .sidebar, .topbar, .toolbar, .row-actions, .btn { display: none !important; }
  .content, .view { padding: 0; }
  body { background: #fff; }
}
