/* ============================================================
   DESIGN TOKENS — carried from moodmedia.pro
   Dark near-black + warm cream, bold grotesk paired with an
   italic serif accent, crisp hairline-bordered components.
   ============================================================ */
:root {
  --black: #0a0a0a;
  --cream: #f2efe8;
  --cream-2: #e9e4d8;
  --ink: #17160f;
  --line-dark: rgba(255,255,255,0.14);
  --line-light: #d9d3c3;
  --muted-dark: rgba(255,255,255,0.55);
  --muted-light: #726c5e;
  --white: #ffffff;

  --cat-meals: #4a7a64;
  --cat-transport: #3e6e92;
  --cat-office: #6b63a6;
  --cat-utilities: #b0812e;
  --cat-maintenance: #a2502f;
  --cat-it: #5c7a34;
  --cat-marketing: #a2456c;
  --cat-others: #8a8578;

  --ok: #3a6b4c;
  --error: #a2402e;

  --font-display: "Archivo", sans-serif;
  --font-accent: "Playfair Display", serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  background: var(--black);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}
.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(255,255,255,0.07), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(255,255,255,0.05), transparent 50%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0px, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 64px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0px, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 64px);
  pointer-events: none;
}
.auth-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
}
.auth-eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--muted-dark);
  margin-bottom: 18px;
}
.auth-headline {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 36px;
}
.auth-headline em {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 400;
}
.auth-card {
  border: 1px solid var(--line-dark);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-error {
  font-size: 13px;
  color: #e8a596;
  background: rgba(162,64,46,0.18);
  border: 1px solid rgba(162,64,46,0.4);
  padding: 10px 12px;
}
.auth-foot {
  margin-top: 28px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted-dark);
  text-transform: uppercase;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-light);
}
.form-label--dark { color: var(--muted-dark); }
.form-input {
  border: 1px solid var(--line-light);
  background: var(--white);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 14px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--ink); }
.form-input--dark {
  background: rgba(255,255,255,0.04);
  border-color: var(--line-dark);
  color: var(--white);
}
.form-input--dark:focus { border-color: var(--white); }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 640px) {
  .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   BUTTONS — crisp corners, tracked uppercase labels
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 11px 20px;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn-block { width: 100%; }
.btn-light { background: var(--white); color: var(--black); }
.btn-primary { background: var(--ink); color: var(--white); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line-light); }
.btn-ghost { background: transparent; color: var(--muted-light); border-color: transparent; padding: 8px 10px; }
.btn-sm { font-size: 12px; padding: 8px 12px; }
.btn-signout {
  background: transparent;
  color: var(--muted-dark);
  border: 1px solid var(--line-dark);
  border-radius: 2px;
  padding: 9px 12px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.btn-signout:hover { color: var(--white); border-color: var(--white); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-header { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.sidebar-mark {
  width: 34px; height: 34px;
  border: 1px solid var(--line-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.sidebar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--muted-dark);
  font-size: 13px; font-weight: 500;
  padding: 11px 10px; text-align: left; cursor: pointer;
  border-radius: 2px;
}
.nav-item i { width: 16px; text-align: center; }
.nav-item:hover { color: var(--white); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--white); background: rgba(255,255,255,0.09); }
.sidebar-footer { border-top: 1px solid var(--line-dark); padding-top: 16px; margin-top: 16px; }
.user-info { font-size: 12px; color: var(--muted-dark); margin-bottom: 10px; word-break: break-word; }

.main { flex: 1; padding: 40px 44px; max-width: 1180px; }
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 10px 6px;
    padding: 12px 14px;
  }
  .sidebar-header { margin-bottom: 0; gap: 8px; }
  .sidebar-mark { width: 28px; height: 28px; font-size: 12px; flex-shrink: 0; }
  .sidebar-title { font-size: 12px; }
  .sidebar-nav {
    flex-direction: row; flex-wrap: nowrap;
    flex: 1 1 auto; justify-content: flex-end;
    gap: 2px; min-width: 0;
  }
  .nav-item {
    flex-shrink: 0;
    padding: 9px 10px;
    justify-content: center;
  }
  .nav-label { display: none; }
  .sidebar-footer {
    border-top: none; border-left: 1px solid var(--line-dark);
    padding: 0 0 0 10px; margin: 0;
    display: flex; align-items: center;
    flex-shrink: 0; width: auto;
  }
  .user-info { display: none; }
  .btn-signout { width: auto; padding: 9px 10px; }
  .btn-signout .nav-label { display: none; }
  .main { padding: 22px 16px 90px; }

  /* Keep every row the same height regardless of how long the
     vendor name is — long names truncate instead of wrapping to
     multiple lines and throwing off row alignment. */
  table td:nth-child(2), table th:nth-child(2) {
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Secondary columns in the All Receipts table (Payment, Notes,
     Ref) hide below this width — Date / Vendor / Category / Amount
     plus the delete action stay, and fit without horizontal scroll. */
  .hide-mobile { display: none; }
}

.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 28px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.12em;
  color: var(--muted-light); margin-bottom: 8px;
}
.page-header h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.page-sub { color: var(--muted-light); font-size: 14px; margin: 0; }

/* ============================================================
   CARDS / SCAN
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--line-light);
  padding: 22px;
  margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-weight: 700; font-size: 14px; }
.ai-badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--ok); background: rgba(58,107,76,0.1);
  border: 1px solid rgba(58,107,76,0.3);
  padding: 4px 9px; border-radius: 2px;
  display: inline-flex; align-items: center; gap: 6px;
}

.scan-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .scan-layout { grid-template-columns: 1fr; } }

.upload-zone {
  border: 1px dashed var(--line-light);
  background: var(--white);
  min-height: 320px;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  cursor: pointer;
  padding: 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone.drag { border-color: var(--ink); background: var(--cream-2); }
.upload-icon { font-size: 34px; color: var(--muted-light); margin-bottom: 12px; }
.upload-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.upload-sub { font-size: 12px; color: var(--muted-light); }
.preview-img { max-width: 100%; max-height: 400px; object-fit: contain; }

.scan-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--line-light);
}
.status-loading { color: var(--muted-light); }
.status-done { color: var(--ok); border-color: rgba(58,107,76,0.35); background: rgba(58,107,76,0.06); }
.status-error { color: var(--error); border-color: rgba(162,64,46,0.35); background: rgba(162,64,46,0.06); }
.status-idle { color: var(--muted-light); }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } }
.metric-card { background: var(--white); border: 1px solid var(--line-light); padding: 18px; }
.metric-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-light); margin-bottom: 8px; }
.metric-value { font-family: var(--font-display); font-weight: 800; font-size: 24px; }
.metric-sub { font-size: 11px; color: var(--muted-light); margin-top: 2px; }

.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 120px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bar { width: 100%; max-width: 30px; background: var(--ink); }
.bar-lbl { font-size: 11px; color: var(--muted-light); }

.cat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cat-name { width: 110px; font-size: 12px; flex-shrink: 0; }
.cat-bg { flex: 1; height: 8px; background: var(--cream-2); }
.cat-fill { height: 100%; }
.cat-amt { width: 80px; text-align: right; font-size: 12px; font-weight: 600; flex-shrink: 0; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted-light); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--line-light);
}
td { padding: 10px; border-bottom: 1px solid var(--cream-2); }
.empty-state { text-align: center; color: var(--muted-light); padding: 40px 20px !important; }
.empty-state i { font-size: 24px; margin-bottom: 8px; display: block; }

.badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 2px;
  color: var(--white); display: inline-block;
}
.cat-meals { background: var(--cat-meals); }
.cat-transport { background: var(--cat-transport); }
.cat-office { background: var(--cat-office); }
.cat-utilities { background: var(--cat-utilities); }
.cat-maintenance { background: var(--cat-maintenance); }
.cat-it { background: var(--cat-it); }
.cat-marketing { background: var(--cat-marketing); }
.cat-others { background: var(--cat-others); }

.btn-delete {
  background: none; border: 1px solid var(--line-light); color: var(--muted-light);
  padding: 5px 8px; border-radius: 2px; cursor: pointer;
}
.btn-delete:hover { color: var(--error); border-color: var(--error); }

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-input {
  border: 1px solid var(--line-light); background: var(--white);
  padding: 9px 11px; font-size: 13px; border-radius: 2px;
}
.filter-count { font-size: 12px; color: var(--muted-light); margin-left: auto; }
.table-total { text-align: right; font-weight: 700; margin-top: 10px; font-size: 14px; }

/* ============================================================
   TOAST / LOADING
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--white);
  padding: 12px 18px; border-radius: 2px; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  opacity: 0; pointer-events: none; transition: all 0.2s;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--error); }
.toast.ok { background: var(--ok); }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(10,10,10,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.loading-box {
  background: var(--white); padding: 18px 26px; border-radius: 2px;
  display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500;
}
