/* ==========================================================================
   Voyage Ledger v2 — Design System
   Modern, friendly, professional. Designed for clarity at-a-glance.
   ========================================================================== */

:root {
  /* Brand palette — modern warm professional */
  --bg:          #fafaf7;          /* warm off-white background */
  --bg-soft:     #f3f3ee;          /* card/panel background */
  --bg-tint:     #ffffff;          /* pure white surfaces */
  --bg-dark:     #0f1419;          /* deep slate for header/sidebar */

  --ink:         #0f1419;          /* primary text */
  --ink-soft:    #4a5159;          /* secondary text */
  --ink-mute:    #8b9099;          /* tertiary / placeholders */

  --line:        rgba(15, 20, 25, 0.08);
  --line-soft:   rgba(15, 20, 25, 0.04);
  --line-strong: rgba(15, 20, 25, 0.14);

  /* Accent — modern blue with personality */
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   #eff6ff;
  --accent-ink:    #1d4ed8;

  /* Semantic */
  --green:        #16a34a;
  --green-soft:   #dcfce7;
  --amber:        #d97706;
  --amber-soft:   #fef3c7;
  --red:          #dc2626;
  --red-soft:     #fee2e2;
  --purple:       #7c3aed;
  --purple-soft:  #f3e8ff;
  --teal:         #0d9488;
  --teal-soft:    #ccfbf1;

  /* Layout */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 2px rgba(15,20,25,.04), 0 1px 3px rgba(15,20,25,.04);
  --shadow:     0 4px 12px -2px rgba(15,20,25,.06), 0 2px 4px rgba(15,20,25,.04);
  --shadow-lg:  0 12px 24px -4px rgba(15,20,25,.08), 0 4px 8px rgba(15,20,25,.04);
  --shadow-xl:  0 24px 48px -8px rgba(15,20,25,.12), 0 8px 16px rgba(15,20,25,.06);

  --font-display: 'Bebas Neue', 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

/* ==========================================================================
   App Shell — sidebar layout for logged-in users
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-dark);
  color: #fff;
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 20px;
}
.sidebar .brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 20px;
  color: #fff;
}
.sidebar .brand h1 { font-family: var(--font-display); font-size: 18px; letter-spacing: .03em; }
.sidebar .brand small { display: block; font-size: 10px; letter-spacing: .15em; color: rgba(255,255,255,.5); text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.75);
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-section {
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.4);
  padding: 16px 12px 8px;
}
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.sidebar-foot .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.sidebar-foot .name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.sidebar-foot .role { font-size: 11px; color: rgba(255,255,255,.5); }
.sidebar-foot .logout { width: 100%; padding: 8px; border-radius: 8px; color: rgba(255,255,255,.7); font-size: 12px; text-align: left; }
.sidebar-foot .logout:hover { background: rgba(255,255,255,.06); color: #fff; }

/* Main content area */
.main { background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar .actions { display: flex; align-items: center; gap: 12px; }

.content { padding: 32px; max-width: 1400px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  transition: all .15s var(--ease);
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg-tint); border-color: var(--line-strong); }
.btn-ghost { color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green); color: #fff; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--bg-soft); display: flex; align-items: center; justify-content: space-between; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.kpi .label { font-size: 12px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi .value { font-size: 32px; font-weight: 700; color: var(--ink); margin-top: 8px; line-height: 1; }
.kpi .change { font-size: 12px; margin-top: 8px; }
.kpi .change.up { color: var(--green); }
.kpi .change.down { color: var(--red); }
.kpi .icon-bg { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }

/* ==========================================================================
   Table
   ========================================================================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
th { font-size: 11px; font-weight: 600; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .05em; background: var(--bg-soft); }
tr:hover td { background: var(--bg-soft); }
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; padding: 60px 20px; color: var(--ink-mute); }
.empty .icon { width: 64px; height: 64px; border-radius: 16px; background: var(--bg-soft); display: grid; place-items: center; margin: 0 auto 16px; color: var(--ink-mute); }
.empty h3 { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-gray { background: var(--bg-soft); color: var(--ink-soft); }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ==========================================================================
   Login screen
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
@media (max-width: 900px) { .login-page { grid-template-columns: 1fr; } .login-hero { display: none; } }

.login-hero {
  background: linear-gradient(135deg, var(--bg-dark), #1a2332);
  color: #fff; padding: 60px 48px;
  display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.login-hero::before {
  content: ''; position: absolute; top: -100px; right: -100px;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,.3), transparent);
}
.login-hero h2 { font-family: var(--font-display); font-size: 48px; line-height: 1; letter-spacing: .02em; text-transform: uppercase; position: relative; }
.login-hero p { color: rgba(255,255,255,.7); margin-top: 16px; max-width: 400px; position: relative; }
.login-hero .features { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; position: relative; }
.login-hero .feature { display: flex; align-items: center; gap: 12px; }
.login-hero .feature .check { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.login-hero .feature .check svg { width: 14px; height: 14px; color: #fff; }

.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form { width: 100%; max-width: 380px; }
.login-form .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.login-form .brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-size: 22px; }
.login-form h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.login-form .subtitle { color: var(--ink-mute); margin-bottom: 28px; }
.login-form .demo-box { background: var(--accent-soft); border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 12px; margin-top: 20px; font-size: 12px; color: var(--accent-ink); }
.login-form .demo-box code { background: rgba(255,255,255,.6); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,20,25,.5);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fadeIn .15s;
}
.modal {
  background: #fff;
  border-radius: var(--radius-xl);
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp .2s var(--ease-out);
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--line); background: var(--bg-soft); display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-stack { position: fixed; top: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  min-width: 240px;
  animation: slideInRight .3s var(--ease-out);
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ==========================================================================
   Filters bar
   ========================================================================== */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 16px 0; margin-bottom: 16px;
  align-items: center;
}
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff; min-width: 280px;
}
.search input { border: 0; outline: 0; flex: 1; font-size: 13px; }
.search svg { width: 16px; height: 16px; color: var(--ink-mute); }
.chip {
  padding: 7px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line-strong);
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
  cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--ink-mute); color: var(--ink); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ==========================================================================
   Reveal animations
   ========================================================================== */
.reveal { opacity: 0; transform: translateY(8px); animation: revealIn .5s var(--ease-out) forwards; }
@keyframes revealIn { to { opacity: 1; transform: translateY(0); } }

/* Utility */
.flex { display: flex; }
.gap-12 { gap: 12px; }
.gap-8 { gap: 8px; }
.muted { color: var(--ink-mute); }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Print styles — for reports */
@media print {
  .sidebar, .topbar, .filters, .btn, .modal-backdrop, .toast-stack { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: 100%; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}
