/* ============================================================
   Travel Claims Management System — shared styles
   Professional light internal-tool interface. No purple gradients,
   no glassmorphism, minimal motion.
   ============================================================ */

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

:root {
  --ink:        #16202B;
  --ink-soft:   #4B5A6B;
  --ink-faint:  #8493A3;

  --navy:       #16324F;
  --navy-dark:  #0F2338;
  --navy-tint:  #E9EFF5;

  --border:     #DFE5EB;
  --bg:         #F4F6F8;
  --surface:    #FFFFFF;

  --success:    #1E7A46;
  --success-bg: #E7F4EC;
  --warning:    #9A6B12;
  --warning-bg: #FBF1DC;
  --danger:     #B3261E;
  --danger-bg:  #FBEAE9;
  --info:       #1D5F8A;
  --info-bg:    #E7F1F8;

  --radius-sm:  4px;
  --radius:     6px;
  --radius-lg:  10px;

  --shadow-1:   0 1px 2px rgba(16, 32, 48, 0.06);
  --shadow-2:   0 4px 16px rgba(16, 32, 48, 0.10);

  --sidebar-w:  232px;
  --topbar-h:   56px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* ---------------- Layout: auth screens ---------------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 36px 32px 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-brand .mark {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}

.auth-brand .name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--navy-dark);
}
.auth-brand .name small {
  display: block;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.auth-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; }
.auth-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 24px; }

/* ---------------- Form elements ---------------- */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field .req { color: var(--danger); }

.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=number],
.field input[type=date],
.field input[type=file],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  font-family: inherit;
}

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

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 50, 79, 0.12);
}

.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 5px; display:none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field.has-error .error { display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-dark); }

.btn-outline { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: var(--navy); color: var(--navy); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16613A; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #922019; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

.form-error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #F1C6C3;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.form-error-banner.show { display: block; }

/* ---------------- App shell ---------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
}

.sidebar {
  grid-area: sidebar;
  background: var(--navy-dark);
  color: #D8E2EC;
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 10px;
}
.sidebar .brand .mark {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: #fff; color: var(--navy-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.sidebar .brand .name { font-weight: 700; font-size: 13.5px; color: #fff; }
.sidebar .brand .role { font-size: 11px; color: #9FB3C8; letter-spacing: 0.04em; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: #C3D2E0;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.nav-link.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-left-color: #fff;
}
.nav-link .dot { width: 6px; }
.nav-spacer { flex: 1; }
.nav-link.logout { margin-top: 6px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px; }

.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar .page-title { font-weight: 700; font-size: 15px; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); }
.topbar .who .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy-tint); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}

.main {
  grid-area: main;
  padding: 24px;
  overflow-y: auto;
}

.view { display: none; }
.view.active { display: block; }

/* ---------------- Cards / grid ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card + .card { margin-top: 16px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--navy);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .label {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--ink-faint); text-transform: uppercase; margin-bottom: 8px;
}
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--ink); }
.stat-card.pending { border-left-color: var(--warning); }
.stat-card.approved { border-left-color: var(--success); }
.stat-card.rejected { border-left-color: var(--danger); }
.stat-card.transferred { border-left-color: var(--info); }

.section-title {
  font-size: 15px; font-weight: 700; margin: 0 0 14px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.3px;
}
table.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  white-space: nowrap;
}
table.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
table.data-table tbody tr:hover { background: var(--navy-tint); }
table.data-table .empty-row td { text-align: center; color: var(--ink-faint); padding: 32px; white-space: normal; }

/* ---------------- Status badges ---------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-pending   { background: var(--warning-bg); color: var(--warning); }
.badge-transferred { background: var(--info-bg); color: var(--info); }
.badge-approved  { background: var(--success-bg); color: var(--success); }
.badge-rejected  { background: var(--danger-bg); color: var(--danger); }

/* ---------------- Filters / toolbar ---------------- */

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin-bottom: 16px;
}
.toolbar .field { margin-bottom: 0; min-width: 150px; }
.toolbar-spacer { flex: 1; }

.search-input { position: relative; min-width: 220px; }
.search-input input { padding-left: 30px; }
.search-input svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); opacity: 0.45; }

/* ---------------- Modal ---------------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 24, 35, 0.5);
  display: none;
  align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 620px;
  box-shadow: var(--shadow-2);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
}
.modal.modal-wide { max-width: 880px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 15.5px; }
.modal-header .close { cursor: pointer; color: var(--ink-faint); font-size: 20px; line-height: 1; background:none; border:none; }
.modal-header .close:hover { color: var(--ink); }

.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ---------------- Claim detail view ---------------- */

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 20px;
  margin-bottom: 4px;
}
.kv-grid .kv-label { font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 3px; }
.kv-grid .kv-value { font-size: 14px; font-weight: 600; }

.remarks-box {
  background: var(--navy-tint);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--ink);
  margin-top: 6px;
}
.remarks-box .who { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

.file-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.proof-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.proof-preview-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.proof-preview-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.proof-preview-media {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6f7f9;
  color: var(--muted, #6b7280);
  font-size: 12px;
  text-align: center;
  overflow: hidden;
}
.proof-preview-media img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.proof-preview-media iframe {
  display: block;
  width: 100%;
  height: 220px;
  border: 0;
  background: #fff;
}
.proof-preview-icon {
  font-weight: 700;
  letter-spacing: .08em;
}
.proof-preview-name {
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .proof-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proof-preview-media img { height: 140px; }
  .proof-preview-media iframe { height: 180px; }
}
.file-chip {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  background: var(--surface);
  cursor: pointer;
}
.file-chip:hover { border-color: var(--navy); }

.file-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  background: var(--bg);
}
.file-drop:hover { border-color: var(--navy); color: var(--navy); }
.file-preview-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.file-preview-item {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 12.5px;
}
.file-preview-item button { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 12px; font-weight: 600; }

/* ---------------- Timeline ---------------- */

.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -22px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--navy); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.timeline-item.approved::before { background: var(--success); }
.timeline-item.rejected::before { background: var(--danger); }
.timeline-item .t-when { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }
.timeline-item .t-title { font-size: 14px; font-weight: 700; margin: 2px 0; }
.timeline-item .t-by { font-size: 12.5px; color: var(--ink-soft); }
.timeline-item .t-remarks { font-size: 13px; color: var(--ink); margin-top: 4px; font-style: italic; }

/* ---------------- Toasts ---------------- */

.toast-stack {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  min-width: 240px;
  max-width: 360px;
  animation: toast-in 160ms ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--navy); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Misc ---------------- */

.pill-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.pill-tab {
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--ink-soft); cursor: pointer;
}
.pill-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-faint); }
.empty-state .big { font-size: 32px; margin-bottom: 6px; }

.text-muted { color: var(--ink-faint); }
.text-sm { font-size: 12.5px; }
.mt-0 { margin-top: 0 !important; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 8px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 700ms linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { text-align: center; padding: 30px; color: var(--ink-faint); }

/* ---------------- Config warning banner ---------------- */

.config-banner {
  background: var(--danger-bg); color: var(--danger);
  border-bottom: 1px solid #F1C6C3;
  padding: 10px 20px; font-size: 13px; text-align: center;
  display: none;
}
.config-banner.show { display: block; }

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 240px;
    transform: translateX(-100%);
    transition: transform 160ms ease;
    z-index: 90;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-2); }
  .main { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .kv-grid { grid-template-columns: repeat(2, 1fr); }
  /* Filter/search rows: one control per line instead of a cramped wrap. */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .field, .toolbar .search-input, .toolbar > .btn { min-width: 0; width: 100%; }
  .toolbar-spacer { display: none; }
}

/* Dimmed backdrop behind the mobile sidebar; injected by common.js. Tapping
   it, or pressing Escape, closes the sidebar. */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 24, 35, 0.45);
  z-index: 80;
}
@media (max-width: 900px) {
  body.sidebar-open .sidebar-backdrop { display: block; }
  /* Prevent the page behind the open sidebar from scrolling on touch. */
  body.sidebar-open { overflow: hidden; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .value { font-size: 21px; }
  .kv-grid { grid-template-columns: 1fr; }
  .modal-body, .modal-header, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 0 12px; }
  .topbar .who #who-name { display: none; }
  .auth-card { padding: 28px 20px 22px; }
  .btn { padding: 10px 14px; }
}

/* One column of small stat cards is more legible than a squeezed 2-up grid
   on the narrowest phones (iPhone SE / older Android, ~360px and below). */
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
}

.menu-toggle {
  display: none;
  border: none; background: none; cursor: pointer; font-size: 20px; color: var(--ink);
  min-width: 40px; min-height: 40px;
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
}


/* V5 workflow UI */
.nav-badge{display:inline-flex;align-items:center;justify-content:center;min-width:19px;height:19px;padding:0 6px;margin-left:7px;border-radius:999px;font-size:11px;font-weight:800;background:#d94841;color:#fff;vertical-align:middle}
.comments-list{display:flex;flex-direction:column;gap:10px}
.comment-item{padding:10px 12px;border:1px solid #e5e7eb;border-radius:8px;background:#fafafa}
.comment-meta{font-size:11px;color:#64748b;margin-bottom:5px}
.comment-body{white-space:pre-wrap;color:#1f2937}
.payment-summary{display:flex;gap:16px;align-items:center;font-size:13px;color:#64748b}
.payment-summary strong{font-size:18px;color:#172033}
.payment-selection-summary{margin:-4px 0 12px;padding:9px 12px;border-radius:8px;background:#f7f9fc;font-size:13px;color:#475569}
