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

:root {
  --ink: #14262d;
  --ink-soft: #496068;
  --navy: #102b35;
  --navy-light: #173d49;
  --paper: #f5f7f6;
  --white: #ffffff;
  --line: #dbe3e1;
  --cyan: #16a8a2;
  --cyan-dark: #087a76;
  --cyan-wash: #e4f6f4;
  --coral: #e66754;
  --coral-wash: #fff0ed;
  --amber: #d59624;
  --amber-wash: #fff6df;
  --green: #21875b;
  --green-wash: #e7f5ed;
  --shadow: 0 12px 36px rgba(16, 43, 53, 0.07);
  --radius: 7px;
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 3px solid rgba(22, 168, 162, 0.3);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }

body:not(.session-ready) { overflow: hidden; }
.session-state { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; gap: 8px; padding: 24px; background: var(--paper); color: var(--ink); text-align: center; }
.session-state strong { font-size: 16px; }
.session-state span { color: var(--ink-soft); font-size: 13px; }
.session-state button { min-height: 40px; margin: 8px auto 0; padding: 0 16px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); font-weight: 600; }
.session-state[hidden] { display: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  background: var(--navy);
  color: #dce9e9;
}

.brand {
  display: flex;
  height: 80px;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  color: #65dbd5;
}

.brand-mark::before, .brand-mark::after {
  position: absolute;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.brand-mark::after { transform: rotate(90deg); }
.brand-name { color: white; font-size: 20px; font-weight: 700; letter-spacing: 0; }
.brand-name span { color: #65dbd5; }

.nav-label, .eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.nav-label { margin: 28px 24px 10px; color: #78939a; }
.nav-list { display: grid; gap: 5px; padding: 0 12px; }

.nav-link {
  position: relative;
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 13px;
  padding: 0 12px;
  border-radius: 5px;
  color: #acc1c5;
  font-weight: 500;
  transition: background .18s ease, color .18s ease;
}

.nav-link:hover { background: rgba(255,255,255,.07); color: white; }
.nav-link.active { background: var(--navy-light); color: white; }
.nav-link.active::before { position: absolute; inset: 9px auto 9px -12px; width: 3px; background: #57d2cc; content: ""; }
.nav-link svg { width: 18px; height: 18px; }

.system-status { margin: auto 18px 20px; padding: 15px; border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius); background: rgba(255,255,255,.04); }
.system-line { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #61d49b; box-shadow: 0 0 0 4px rgba(97,212,155,.1); }
.system-status p { margin: 7px 0 0; color: #819ba1; font-size: 11px; }

.topbar {
  position: fixed;
  inset: 0 0 auto var(--sidebar-width);
  z-index: 20;
  display: flex;
  height: 80px;
  align-items: center;
  gap: 20px;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
}

.mobile-menu { display: none; }

.search-wrap { position: relative; width: min(520px, 50vw); }
.search-wrap > svg { position: absolute; top: 50%; left: 14px; width: 18px; transform: translateY(-50%); color: #72888e; }
.global-search { width: 100%; height: 43px; padding: 0 42px; border: 1px solid var(--line); border-radius: 5px; background: #f7f9f8; color: var(--ink); }
.global-search:focus { border-color: var(--cyan); background: white; outline: none; box-shadow: 0 0 0 3px rgba(22,168,162,.1); }
.search-shortcut { position: absolute; top: 9px; right: 10px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 3px; color: #71868c; font: 11px "IBM Plex Mono", monospace; }

.search-results {
  position: absolute;
  top: 51px;
  left: 0;
  display: none;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}
.search-results.open { display: block; }
.search-result { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #edf1f0; }
.search-result:hover { background: #f5f9f8; }
.search-result:last-child { border-bottom: 0; }
.search-result small { color: var(--ink-soft); }
.search-empty { padding: 20px; color: var(--ink-soft); text-align: center; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-button { position: relative; display: grid; width: 40px; height: 40px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--ink); }
.icon-button:hover { background: #edf3f2; }
.icon-button svg { width: 19px; }
.notification-count { position: absolute; top: 2px; right: 1px; display: grid; min-width: 17px; height: 17px; padding: 0 4px; place-items: center; border: 2px solid white; border-radius: 10px; background: var(--coral); color: white; font: 9px "IBM Plex Mono", monospace; }

.profile-button { display: flex; align-items: center; gap: 10px; margin-left: 8px; padding: 5px 7px; border: 0; border-radius: 5px; background: transparent; color: var(--ink); text-align: left; }
.profile-button:hover { background: #edf3f2; }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: var(--navy); color: white; font-size: 12px; font-weight: 700; }
.profile-copy strong, .profile-copy small { display: block; }
.profile-copy strong { font-size: 13px; }
.profile-copy small { color: var(--ink-soft); font-size: 11px; }

.popover { position: fixed; z-index: 50; display: none; width: 310px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.popover.open { display: block; }
.notification-popover { top: 68px; right: 110px; }
.profile-popover { top: 68px; right: 24px; width: 220px; }
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 15px; border-bottom: 1px solid var(--line); }
.popover-head button { border: 0; background: none; color: var(--cyan-dark); font-size: 12px; }
.notification-item { padding: 13px 15px; border-bottom: 1px solid #edf1f0; }
.notification-item.unread { border-left: 3px solid var(--cyan); background: #f7fbfa; }
.notification-item p { margin: 0 0 3px; font-size: 13px; font-weight: 600; }
.notification-item small { color: var(--ink-soft); }
.profile-menu-link { display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: 13px; }
.profile-menu-link:hover { background: #f4f8f7; }
.profile-menu-link svg { width: 16px; }

.main { min-height: 100vh; margin-left: var(--sidebar-width); padding: 112px 34px 48px; }
.page { width: min(1420px, 100%); margin: 0 auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--cyan-dark); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 42px); font-weight: 600; line-height: 1.08; letter-spacing: 0; }
h2 { margin: 0; font-size: 20px; letter-spacing: 0; }
h3 { margin: 0; font-size: 15px; }
.page-heading p:not(.eyebrow) { max-width: 590px; margin: 10px 0 0; color: var(--ink-soft); }
.date-stamp { color: var(--ink-soft); font: 12px "IBM Plex Mono", monospace; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 4px 20px rgba(16,43,53,.025); }
.panel-header { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 20px; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 9px; padding: 0 17px; border: 1px solid transparent; border-radius: 5px; font-weight: 600; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button svg { width: 17px; height: 17px; }
.button-primary { background: var(--navy); color: white; }
.button-primary:hover { background: var(--navy-light); }
.button-accent { background: var(--cyan-dark); color: white; }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }
.button-danger { background: var(--coral-wash); color: #a74031; }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.button-small { min-height: 34px; padding: 0 12px; font-size: 12px; }

.field { display: grid; gap: 7px; }
.field label { color: #314950; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfdad8; border-radius: 4px; background: white; color: var(--ink); }
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 0 3px rgba(22,168,162,.1); }
.field input:disabled { background: #edf1f0; color: #718388; }
.field-hint { color: var(--ink-soft); font-size: 11px; }
.field-error { display: none; color: #b74536; font-size: 11px; }
.field.invalid .field-error { display: block; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--coral); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }

.badge { display: inline-flex; min-height: 25px; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px; font: 11px "IBM Plex Mono", monospace; white-space: nowrap; }
.badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge-approved, .badge-verified { background: var(--green-wash); color: var(--green); }
.badge-declined { background: var(--coral-wash); color: #b54a3b; }
.badge-pending, .badge-review { background: var(--amber-wash); color: #966813; }
.badge-info { background: var(--cyan-wash); color: var(--cyan-dark); }

.dropzone { position: relative; display: grid; min-height: 220px; padding: 30px; place-items: center; border: 1px dashed #9eb4b4; border-radius: var(--radius); background: #f8fbfa; text-align: center; transition: border .18s ease, background .18s ease; }
.dropzone.dragging { border-color: var(--cyan); background: var(--cyan-wash); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-icon { display: grid; width: 52px; height: 52px; margin: 0 auto 14px; place-items: center; border-radius: 50%; background: var(--cyan-wash); color: var(--cyan-dark); }
.dropzone-icon svg { width: 23px; }
.dropzone h3 { margin-bottom: 6px; }
.dropzone p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.dropzone .button { margin-top: 16px; }

.file-card { display: none; align-items: center; gap: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 5px; background: white; text-align: left; }
.file-card.visible { display: flex; }
.file-icon { display: grid; width: 39px; height: 44px; flex: 0 0 auto; place-items: center; border-radius: 4px; background: var(--coral-wash); color: var(--coral); }
.file-meta { min-width: 0; flex: 1; }
.file-meta strong, .file-meta small { display: block; }
.file-meta strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small { margin-top: 2px; color: var(--ink-soft); }
.file-actions { display: flex; gap: 5px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.metric { padding: 18px; border-top: 2px solid var(--line); background: white; }
.metric.accent { border-color: var(--cyan); }
.metric.warn { border-color: var(--coral); }
.metric-label { color: var(--ink-soft); font-size: 12px; }
.metric-value { display: block; margin-top: 8px; font: 600 28px "IBM Plex Mono", monospace; letter-spacing: 0; }
.metric-detail { color: var(--ink-soft); font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f7f9f8; color: #62767b; font: 600 10px "IBM Plex Mono", monospace; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 16px; border-bottom: 1px solid #e8eeec; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfc; }
.mono { font-family: "IBM Plex Mono", monospace; }

.empty-state { display: grid; min-height: 240px; padding: 30px; place-items: center; color: var(--ink-soft); text-align: center; }
.empty-state svg { width: 34px; height: 34px; margin-bottom: 10px; color: #8fa5aa; }
.empty-state p { margin: 0; }

.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: grid; width: min(370px, calc(100vw - 32px)); gap: 9px; }
.toast { display: flex; align-items: flex-start; gap: 11px; padding: 14px; border: 1px solid var(--line); border-left: 3px solid var(--cyan); border-radius: 5px; background: white; box-shadow: var(--shadow); animation: toast-in .25s ease; }
.toast.error { border-left-color: var(--coral); }
.toast svg { width: 18px; flex: 0 0 auto; color: var(--cyan-dark); }
.toast.error svg { color: var(--coral); }
.toast p { margin: 0; font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; padding: 20px; background: rgba(8,28,34,.52); backdrop-filter: blur(3px); }
.modal-backdrop.open { display: grid; }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; border-radius: var(--radius); background: white; box-shadow: 0 24px 80px rgba(4,22,28,.22); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1020px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .profile-copy { display: none; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 12px 0 40px rgba(4,22,28,.2); }
  .topbar { left: 0; height: 68px; padding: 0 14px; gap: 10px; }
  .mobile-menu { display: grid; flex: 0 0 auto; }
  .search-wrap { width: auto; flex: 1; }
  .search-shortcut { display: none; }
  .profile-button { display: none; }
  .notification-popover { top: 62px; right: 12px; width: calc(100vw - 24px); }
  .main { margin-left: 0; padding: 92px 16px 34px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading p:not(.eyebrow) { font-size: 13px; }
  .date-stamp { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .panel-header, .panel-body { padding-left: 15px; padding-right: 15px; }
  .modal-footer { flex-wrap: wrap; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar-actions { gap: 0; }
  .global-search::placeholder { color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
