:root {
  --bg: #f7faff;
  --surface: #ffffff;
  --surface-2: #f1f6ff;
  --ink: #172033;
  --muted: #65728a;
  --line: #dbe7fb;
  --accent: #0066ff;
  --accent-strong: #0052cc;
  --accent-soft: #e9f6ff;
  --navy: #0b2f5b;
  --cyan: #00c8ff;
  --warning: #b7791f;
  --success: #047857;
  --danger: #c24141;
  --shadow: 0 18px 45px rgba(20, 45, 86, 0.08), 0 0 0 1px rgba(0, 102, 255, 0.04);
}

* { box-sizing: border-box; }
html {
  font-size: 16px;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(0, 102, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 102, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #f7fbff 0%, #eef6ff 100%),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 400;
  text-rendering: optimizeLegibility;
}
body.login-mode .sidebar,
body.login-mode .app-shell,
body.login-mode .detail-drawer,
body.login-mode .mobile-nav-toggle,
body.login-mode .sidebar-backdrop { display: none; }
body:not(.login-mode) .login-screen { display: none; }
.top-loader {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  z-index: 100;
  overflow: hidden;
  pointer-events: none;
}
.top-loader::before {
  content: "";
  position: absolute;
  top: 0;
  left: -30%;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--cyan), transparent);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.top-loader.active::before {
  opacity: 1;
  animation: top-loader-sweep 1.1s ease-in-out infinite;
}
@keyframes top-loader-sweep {
  0% { left: -30%; }
  100% { left: 100%; }
}
.login-screen { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px; }
.login-card {
  width: min(100%, 460px);
  display: grid;
  gap: 16px;
  padding: 24px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.recovery-card textarea { min-height: 84px; }
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row img { width: 42px; min-width: 42px; height: 42px; object-fit: contain; }
.brand-row strong { display: block; font-weight: 700; }
.brand-row span, p, small, .status { color: var(--muted); }
.brand-row span { font-size: 0.86rem; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 600; }
input, button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  font: inherit;
}
input:focus,
select:focus,
textarea:focus {
  border-color: #9ed4ff;
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
  outline: none;
}
input[type="checkbox"] {
  min-height: auto;
  width: 18px;
  height: 18px;
  padding: 0;
}
textarea {
  min-height: 120px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}
select {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  font: inherit;
  background: white;
}
.select-search {
  min-height: 38px;
  margin-bottom: 8px;
  background: #f8fbff;
}
.input-with-action {
  display: flex;
  gap: 8px;
}
.input-with-action input {
  flex: 1;
  min-width: 0;
}
.input-with-action button {
  white-space: nowrap;
  padding: 0 12px;
}
button {
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
button:hover { transform: translateY(-1px); }
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  color: white;
  border: none;
  box-shadow: 0 12px 24px rgba(0, 102, 255, 0.22);
}
.primary-btn:hover { box-shadow: 0 14px 30px rgba(0, 102, 255, 0.28); }
.secondary-btn {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}
.text-btn {
  min-height: auto;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
  box-shadow: none;
}
.text-btn:hover {
  transform: none;
  text-decoration: underline;
}
.secondary-btn:hover, .nav-item:hover {
  border-color: #b9dcff;
  background: #edf6ff;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 48px rgba(19, 43, 76, 0.08);
  overflow-y: auto;
}
nav { display: grid; gap: 4px; }
.nav-item {
  min-height: 40px;
  text-align: left;
  background: transparent;
  color: #4f5f78;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-item[hidden] {
  display: none;
}
.nav-item.active {
  color: #004cbd;
  background: #edf6ff;
  border-color: #b9dcff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.account-box { margin-top: auto; display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; flex-shrink: 0; }
.account-box .secondary-btn { min-height: 38px; }
.app-shell { margin-left: 280px; padding: 28px; }
.topbar, .panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.eyebrow { color: var(--navy); text-transform: uppercase; font-size: 0.78rem; font-weight: 700; margin: 0 0 4px; }
h1, h2, h3 {
  color: var(--navy);
  margin: 0 0 6px;
  line-height: 1.2;
  font-weight: 700;
}
h1 { font-size: clamp(2rem, 3vw, 2.6rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
}
.version-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}
.view { display: none; }
.view.active { display: block; }
.panel, .metric {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel { padding: 18px; margin-bottom: 16px; }
.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #eef8ff 100%);
  border-color: #cfe5fb;
}
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  font-size: 1.5rem;
  font-weight: 700;
  box-shadow: 0 14px 30px rgba(0, 102, 255, 0.22);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.metric { padding: 18px; min-width: 0; }
.metric strong { display: block; font-size: 2rem; color: var(--navy); font-weight: 700; line-height: 1.1; }
.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; }
th { color: var(--accent); font-size: 0.78rem; text-transform: uppercase; font-weight: 700; }
th.num, td.num { text-align: right; }
.status-pill { display: inline-block; padding: 6px 10px; border-radius: 999px; font-weight: 700; font-size: 0.82rem; }
.approved { background: #e8fbf2; color: var(--success); }
.rejected { background: #fff1f1; color: var(--danger); }
.pending { background: #edf6ff; color: var(--accent); }
.returned { background: #fff7df; color: var(--warning); }
.canceled { background: #eef2f6; color: var(--ink); }
.inline-form { display: grid; grid-template-columns: 1fr 180px auto; gap: 10px; margin-bottom: 16px; }
.filter-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px;
  gap: 10px;
  margin-bottom: 14px;
}
.report-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.3fr) 180px 180px 180px;
  gap: 12px;
  margin-bottom: 14px;
}
.import-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.report-summary,
.import-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.report-summary article,
.import-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
}
.report-summary strong,
.import-summary strong {
  display: block;
  color: var(--navy);
  font-size: 1.45rem;
}
.report-summary span,
.import-summary span {
  color: var(--muted);
  font-weight: 600;
}
.request-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.balance-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.workflow-form {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.workflow-builder {
  display: grid;
  gap: 10px;
}
.workflow-stage-list {
  display: grid;
  gap: 8px;
}
.workflow-stage-row {
  display: grid;
  grid-template-columns: 42px minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.workflow-stage-row > span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: var(--navy);
  font-weight: 700;
}
.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
  min-height: 42px;
}
.wide-field { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  justify-content: flex-end;
}
.list { display: grid; gap: 10px; }
.list-item, .approval-card, .settings-grid > div, .notification-card, .workflow-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbff;
}
.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.row-item small {
  max-width: 48%;
  overflow-wrap: anywhere;
  text-align: right;
}
.workflow-list {
  display: grid;
  gap: 10px;
}
.workflow-path {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.workflow-path span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbff;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 11px;
}
.workflow-path span.current {
  background: #edf6ff;
  border-color: #b9dcff;
  color: var(--accent);
}
.workflow-path span.done {
  background: #e8fbf2;
  border-color: #bdebd4;
  color: var(--success);
}
.workflow-item {
  text-align: left;
  display: grid;
  gap: 4px;
  min-height: 58px;
}
.workflow-item span {
  color: var(--muted);
  font-weight: 600;
}
.amend-form {
  margin: 12px 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.approval-list {
  display: grid;
  gap: 12px;
}
.approval-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.table-actions .secondary-btn {
  min-height: 34px;
  padding: 0 10px;
}
.danger-lite {
  color: var(--danger);
  border-color: #ffd6d6;
  background: #fff8f8;
}
.approve-btn,
.reject-btn,
.return-btn {
  min-height: 38px;
  padding: 0 14px;
}
.approve-btn {
  background: linear-gradient(135deg, var(--success), #10b981);
  color: white;
  border: none;
  box-shadow: 0 10px 20px rgba(4, 120, 87, 0.18);
}
.reject-btn {
  background: linear-gradient(135deg, var(--danger), #ef4444);
  color: white;
  border: none;
  box-shadow: 0 10px 20px rgba(194, 65, 65, 0.16);
}
.return-btn {
  background: #fff7df;
  color: #8a5a00;
  border-color: #f4d48a;
}
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-grid strong, .settings-grid span { display: block; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.guide-card {
  border: 1px solid #cfe5fb;
  border-radius: 8px;
  padding: 14px 16px;
  background: #f8fbff;
}
.guide-card h3 {
  margin-bottom: 8px;
}
.guide-card ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}
.guide-card li {
  margin: 6px 0;
}
.guide-card strong {
  color: var(--navy);
  font-weight: 700;
}
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.settings-tab {
  min-height: 40px;
  background: white;
  color: #4f5f78;
  border-color: var(--line);
}
.settings-tab.active {
  color: #004cbd;
  background: #edf6ff;
  border-color: #b9dcff;
  box-shadow: inset 0 -3px 0 var(--accent);
}
.settings-pane,
.user-pane { display: none; }
.settings-pane.active {
  display: grid;
  gap: 16px;
}
.user-pane.active { display: block; }
.pane-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.pane-heading h3 {
  margin: 0 0 6px;
  color: var(--navy);
}
.compact-heading {
  align-items: center;
}
.settings-form {
  grid-template-columns: minmax(220px, 320px) auto;
  align-items: end;
}
.settings-detail-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.subsection-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 16px;
}
.nested-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.notification-grid {
  display: block;
}
.notification-card {
  display: grid;
  gap: 12px;
  background: white;
}
.template-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 14px;
}
.template-list {
  display: grid;
  align-content: start;
  gap: 8px;
}
.template-link {
  min-height: 62px;
  display: grid;
  gap: 4px;
  text-align: left;
  background: white;
  border-color: var(--line);
}
.template-link strong,
.template-link span {
  display: block;
}
.template-link span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}
.template-link.active {
  border-color: #b9dcff;
  background: #edf6ff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.template-editor {
  min-width: 0;
}
.template-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 14px;
}
.template-fields {
  display: grid;
  gap: 12px;
}
.template-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
}
.email-preview {
  display: grid;
  gap: 10px;
  margin: 10px 0;
  padding: 14px;
  border: 1px solid #dbe7fb;
  border-radius: 8px;
  background: white;
}
.email-preview span {
  color: var(--muted);
  font-size: 0.88rem;
}
.email-preview strong {
  color: var(--navy);
  font-size: 1.05rem;
}
.email-preview p {
  margin: 0;
}
.notification-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.notification-head strong,
.notification-head small {
  display: block;
}
.password-form {
  display: grid;
  gap: 14px;
}
.compact-panel {
  width: min(520px, 100%);
}
.audit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.audit-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--navy);
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(11, 47, 91, 0.35);
  z-index: 60;
}
.field-hint {
  margin: -4px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.toast-error {
  background: #a01b2b;
  box-shadow: 0 14px 32px rgba(160, 27, 43, 0.35);
}
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 24, 44, 0.36);
  padding: 20px;
}
.modal-card {
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(20, 45, 86, 0.25);
}
.modal-card h3 { margin: 0; }
.modal-card p { margin: 0; color: var(--muted); }
.modal-card label { margin: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  background: rgba(10, 24, 44, 0.28);
}
.detail-panel {
  width: min(760px, 100%);
  height: 100%;
  overflow-y: auto;
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 45px rgba(20, 45, 86, 0.16);
  padding: 22px;
}
.detail-panel header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.detail-grid > div,
.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbff;
}
.detail-grid span,
.history-item span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}
.history-list {
  display: grid;
  gap: 10px;
}
.hidden { display: none; }
.mobile-nav-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 40;
  min-height: 40px;
  padding: 0 14px;
  color: var(--navy);
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(10, 24, 44, 0.32);
}
@media (max-width: 820px) {
  .mobile-nav-toggle { display: flex; }
  .sidebar-backdrop.open { display: block; }
  .sidebar {
    width: min(280px, 82vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 45;
  }
  .sidebar.open { transform: translateX(0); }
  .app-shell { margin-left: 0; padding: 16px; padding-top: 68px; }
  .topbar, .panel-heading, .pane-heading, .hero { flex-direction: column; }
  .metrics, .settings-grid, .guide-grid, .inline-form, .audit-grid, .notification-grid, .filter-row, .report-filters, .report-summary, .import-grid, .import-summary, .template-layout, .template-edit-grid { grid-template-columns: 1fr; }
  .request-form, .balance-form, .user-form, .workflow-form, .settings-detail-form { grid-template-columns: 1fr; }
}
