/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-bg: #eef2ff;
  --accent-light: #c7d2fe;
  --surface: #ffffff;
  --surface2: #f4f5fb;
  --border: #e1e4ee;
  --text: #1a1d2e;
  --muted: #6e7491;
  --green-bg: #dcfce7;
  --green-text: #166534;
  --green-border: #bbf7d0;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
  --red-border: #fecaca;
  --yellow-bg: #fef9c3;
  --yellow-text: #854d0e;
  --radius: 10px;
  --radius-lg: 12px;
  --shadow: 0 2px 12px rgba(79,70,229,.08);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--surface2);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ── */
.topbar {
  background: #4E1263;
  border-bottom: none;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  color: white;
  text-decoration: none;
  flex-shrink: 0;
}

/* ── Desktop Nav ── */
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav a {
  font-size: 13px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { color: white; }
.nav a.active { color: white; font-weight: 600; }
.nav-divider { width: 1px; height: 16px; background: rgba(255,255,255,.2); }

/* ── Hamburger (mobile only) ── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .2s;
}

/* ── Mobile nav drawer ── */
.nav-drawer {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  flex-direction: column;
  gap: 4px;
  z-index: 99;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.nav-drawer.open { display: flex; }
.nav-drawer a {
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.nav-drawer a:last-child { border-bottom: none; }
.nav-drawer a:hover { color: var(--accent); }

/* ── Main container ── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}
.main-narrow {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
}
.main-large {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.main-mid {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Page header ── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.page-header p { font-size: 14px; color: var(--muted); }
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* ── Stat cards ── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.stat-value { font-size: 26px; font-weight: 600; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.clickable { cursor: pointer; transition: box-shadow .15s; text-decoration: none; color: inherit; display: block; }
.stat-card.clickable:hover { box-shadow: var(--shadow); }

/* ── Section card ── */
.section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}
.section-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-title { font-size: 14px; font-weight: 600; }
.section-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 9px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--accent-light); cursor: not-allowed; }
.btn-outline {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-bg); }
.btn-danger {
  background: var(--surface);
  color: var(--red-text);
  border: 1px solid var(--red-border);
}
.btn-danger:hover { background: var(--red-bg); }
.btn-lg { padding: 12px 32px; font-size: 15px; font-weight: 600; }
.btn-full { width: 100%; text-align: center; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group.full { grid-column: 1 / -1; }
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}
input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[readonly] { background: var(--surface2); color: var(--muted); cursor: not-allowed; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th {
  text-align: left;
  padding: 11px 20px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--surface2);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-approved { background: var(--green-bg); color: var(--green-text); }
.badge-review { background: var(--red-bg); color: var(--red-text); }
.badge-rejected { background: var(--surface2); color: var(--muted); }
.badge-vat { background: var(--green-bg); color: var(--green-text); }
.badge-exempt { background: var(--surface2); color: var(--muted); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}
.alert-green { background: #f0fdf4; color: var(--green-text); border: 1px solid var(--green-border); }
.alert-red { background: var(--red-bg); color: var(--red-text); border: 1px solid var(--red-border); }
.alert-yellow { background: var(--yellow-bg); color: var(--yellow-text); border: 1px solid #fde047; }
.alert-blue { background: var(--accent-bg); color: #3730a3; border: 1px solid var(--accent-light); }

/* ── Inbox box ── */
.inbox-box {
  margin: 16px 24px 20px;
  background: var(--accent-bg);
  border-radius: 8px;
  padding: 13px 16px;
  font-size: 13px;
  color: #3730a3;
}
.inbox-box strong { display: block; font-weight: 600; margin-bottom: 2px; }

/* ── Empty state ── */
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty h3 { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.empty p { font-size: 13px; line-height: 1.6; max-width: 300px; margin: 0 auto 16px; }

/* ── Action links ── */
.action-links { display: flex; gap: 10px; align-items: center; }
.view-link { font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.view-link:hover { text-decoration: underline; }
.edit-link { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.edit-link:hover { color: var(--accent); text-decoration: underline; }

/* ── FX note ── */
.fx-note { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ── Confidence bar ── */
.confidence-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.bar-bg { flex: 1; height: 6px; background: var(--border); border-radius: 3px; }
.bar-fill { height: 6px; border-radius: 3px; }
.bar-low { background: #ef4444; }
.bar-mid { background: #f59e0b; }
.bar-high { background: #22c55e; }
.bar-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Mobile responsive ── */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .nav { display: none; }
  .hamburger { display: none !important; }
  .hamburger { display: flex; }

  .main, .main-narrow, .main-large {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.main-mid { padding: 20px 16px; }

  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-value { font-size: 22px; }

  .section-header { flex-wrap: wrap; gap: 8px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }

  .page-header h1 { font-size: 18px; }

  .card { padding: 18px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .btn-lg { padding: 11px 20px; font-size: 14px; }
}

/* Locked nav item */
.nav-locked {
  font-size: 13px;
  color: var(--muted) !important;
  text-decoration: none;
  font-weight: 500;
  opacity: 0.5;
  cursor: pointer;
  white-space: nowrap;
}
.nav-locked:hover { color: var(--accent) !important; opacity: 1; }

/* Search overlay */
.search-btn { background: none; border: none; outline: none; cursor: pointer; padding: 6px; color: var(--muted); display: flex; align-items: center; box-shadow: none; }
.search-btn:hover { color: var(--accent); }
.search-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); z-index: 1000; align-items: flex-start; justify-content: center; padding-top: 80px; }
.search-overlay.open { display: flex; }
.search-box { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 600px; margin: 0 20px; box-shadow: 0 8px 40px rgba(0,0,0,.2); overflow: hidden; }
.search-input-wrap { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.search-input-wrap svg { color: var(--muted); margin-right: 12px; flex-shrink: 0; }
.search-input-wrap input { flex: 1; border: none; outline: none; font-size: 16px; background: transparent; color: var(--text); }
.search-results { max-height: 400px; overflow-y: auto; }
.search-section-title { font-size: 11px; font-weight: 700; color: var(--muted); padding: 12px 20px 6px; text-transform: uppercase; letter-spacing: .05em; }
.search-result-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; cursor: pointer; text-decoration: none; color: var(--text); }
.search-result-item:hover { background: var(--accent-bg); }
.search-result-main { font-size: 13px; font-weight: 500; }
.search-result-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.search-result-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--surface2); color: var(--muted); }
.search-empty { padding: 24px 20px; text-align: center; font-size: 13px; color: var(--muted); }

/* Footer */
.app-footer { margin-top: 40px; padding: 20px 24px; border-top: 1px solid var(--border); text-align: center; font-size: 12px; color: var(--muted); }
.app-footer a { color: var(--muted); text-decoration: none; margin: 0 8px; }
.app-footer a:hover { color: var(--accent); }

.stat-card-warning { border: 2px solid #f59e0b !important; background: #fffbeb !important; }

/* ── Dropdown nav ── */
.nav-standalone { font-size: 13px; font-weight: 500; color: rgba(255,255,255,.85); text-decoration: none; padding: 6px 10px; border-radius: 6px; transition: background .15s; }
.nav-standalone:hover { background: rgba(255,255,255,.12); color: white; }
.nav-drawer-standalone { padding: 12px 24px; font-size: 15px; color: white !important; font-weight: 600; border-bottom: 0.5px solid rgba(255,255,255,.15); }
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown-btn { background: none; border: none; color: rgba(255,255,255,.85); font-size: 13px; font-weight: 500; cursor: pointer; padding: 6px 10px; display: flex; align-items: center; gap: 4px; border-radius: 6px; transition: background .15s; }
.nav-dropdown-btn:hover { background: rgba(255,255,255,.12); color: white; }
.nav-arrow { font-size: 9px; opacity: .7; }
.nav-dropdown-menu { display: none; position: absolute; top: calc(100% + 2px); left: 0; background: #3A0D4A; border-radius: 8px; min-width: 160px; padding: 4px 0; z-index: 1000; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu::before { content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
.nav-dropdown-menu a { display: block; color: rgba(255,255,255,.85); font-size: 13px; padding: 9px 16px; text-decoration: none; transition: background .1s; }
.nav-dropdown-menu a:hover { background: rgba(255,255,255,.1); color: white; }
.nav-dropdown-menu a.active { color: white; font-weight: 600; }
/* ── Mobile drawer groups ── */
.nav-drawer-group { margin-bottom: 4px; }
.nav-drawer-label { font-size: 10px; font-weight: 700; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: .08em; padding: 10px 20px 4px; }
.nav-drawer {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #3A0D4A;
  padding: 8px 0 16px;
  z-index: 999;
  flex-direction: column;
  overflow-y: auto;
}
.nav-drawer.open { display: flex; }
.nav-drawer a {
  padding: 12px 24px;
  font-size: 15px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-weight: 400;
  border-bottom: 0.5px solid rgba(255,255,255,.08);
}
.nav-drawer a:hover { background: rgba(255,255,255,.1); color: white; }
.nav-drawer-group { margin-bottom: 0; }
.nav-drawer-label { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: .08em; padding: 14px 24px 6px; }
/* NProgress brand colour override */
#nprogress .bar { background: #4E1263 !important; height: 3px; }
#nprogress .peg { box-shadow: 0 0 10px #4E1263, 0 0 5px #4E1263; }

/* Password toggle eye icon */
.password-wrapper { position: relative; }
.password-wrapper input[type="password"],
.password-wrapper input[type="text"] { padding-right: 40px; width: 100%; }
.password-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; color: var(--muted); font-size: 16px; user-select: none; }
