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

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  --brand:        #0f766e;
  --brand-dark:   #0a4f4a;
  --brand-deeper: #042f2e;
  --brand-light:  #ccfbf1;
  --brand-mid:    #14b8a6;

  --bg:           #f8fafc;
  --surface:      #ffffff;
  --surface-2:    #f1f5f9;
  --border:       #e2e8f0;
  --border-mid:   #cbd5e1;

  --ink:          #0f172a;
  --ink-muted:    #475569;
  --ink-faint:    #94a3b8;

  --success-bg:   #dcfce7;
  --success-fg:   #15803d;
  --danger-bg:    #fee2e2;
  --danger-fg:    #dc2626;
  --warn-bg:      #fef9c3;
  --warn-fg:      #a16207;

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    18px;

  --shadow-xs:    0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-sm:    0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .06);
  --shadow-md:    0 4px 6px -1px rgb(0 0 0 / .08), 0 2px 4px -2px rgb(0 0 0 / .05);

  --topbar-h:     56px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Fira Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 99px; }

/* ═══════════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--brand-deeper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 2px 12px rgb(0 0 0 / .25);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--brand-mid);
  box-shadow: 0 0 8px var(--brand-mid);
  animation: pulse 2.5s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { box-shadow: 0 0 4px var(--brand-mid); }
  to   { box-shadow: 0 0 14px var(--brand-mid), 0 0 28px var(--brand); }
}

.topbar-name { font-size: 0.95rem; font-weight: 700; color: #fff; letter-spacing: 0.01em; }
.topbar-sub  { font-size: 0.7rem; color: #5eead4; font-weight: 400; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--brand-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-light);
}

.topbar-username { font-size: 0.82rem; color: #a7f3d0; font-weight: 600; }
.topbar-role     { font-size: 0.68rem; color: #5eead4; }

/* ── Logout btn ── */
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-md);
  color: #a7f3d0;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
}
.btn-logout:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.35);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════ */
.page {
  padding-top: calc(var(--topbar-h) + 24px);
  padding-bottom: 40px;
  padding-left: 20px;
  padding-right: 20px;
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ═══════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: '';
  width: 3px; height: 13px;
  background: var(--brand-mid);
  border-radius: 2px;
  flex-shrink: 0;
}

.card-body { padding: 20px; }

/* ═══════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════ */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 150ms ease;
  line-height: 1;
  white-space: nowrap;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--brand-dark); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-mid);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-danger {
  background: transparent;
  color: var(--danger-fg);
  border: 1px solid var(--danger-fg);
  padding: 4px 10px;
  font-size: 0.75rem;
}
.btn-danger:hover { background: var(--danger-fg); color: #fff; }

/* ═══════════════════════════════════════════════════════
   INPUTS
═══════════════════════════════════════════════════════ */
label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

input, select, textarea {
  display: block;
  width: 100%;
  padding: 8px 11px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 140ms, box-shadow 140ms;
}
input::placeholder { color: var(--ink-faint); }
input:focus, select:focus {
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgb(20 184 166 / .12);
}
input[type="file"] { padding: 6px 10px; }

/* ═══════════════════════════════════════════════════════
   UPLOAD FORM
═══════════════════════════════════════════════════════ */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 16px;
}

.full { grid-column: 1 / -1; }

/* Autocomplete */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0; right: 0;
  z-index: 200;
  background: var(--surface);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 160px;
  overflow-y: auto;
}
.ac-item {
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 80ms;
}
.ac-item:hover { background: var(--brand-light); color: var(--brand-dark); }

/* Upload actions */
.upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.upload-actions .btn-primary { padding: 10px 24px; }

/* ═══════════════════════════════════════════════════════
   MESSAGE / TOAST
═══════════════════════════════════════════════════════ */
.msg {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
}
.msg-success { background: var(--success-bg); color: var(--success-fg); }
.msg-error   { background: var(--danger-bg);  color: var(--danger-fg); }
.msg-hidden  { display: none; }

/* ═══════════════════════════════════════════════════════
   FILTERS BAR
═══════════════════════════════════════════════════════ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.filters input, .filters select {
  width: auto;
  min-width: 120px;
  flex: 1;
}
.filters .btn { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════
   SUMMARY STRIP
═══════════════════════════════════════════════════════ */
.summary-strip {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #f0fdf9;
  border: 1px solid #99f6e4;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--brand-dark);
}
.summary-strip.visible { display: flex; }
.summary-strip svg { flex-shrink: 0; color: var(--brand-mid); }

/* ═══════════════════════════════════════════════════════
   TABLE  — no sticky thead, proper scroll wrapper
═══════════════════════════════════════════════════════ */
.table-outer {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  width: 100%;
  /* Fixed height so only the body scrolls, keeping header visible */
  max-height: 540px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 820px;
}

/* Header — no sticky, just a clear background that stays at the top
   of the scroll container via the fixed max-height approach */
thead {
  background: var(--surface-2);
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--border-mid);
  white-space: nowrap;
}

/* Body */
tbody tr {
  transition: background 80ms;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f0fdf9; }

tbody td {
  padding: 10px 14px;
  color: var(--ink);
  vertical-align: middle;
}

/* Column styles */
.col-date   { color: var(--ink-muted); font-family: 'Fira Code', monospace; font-size: 0.8rem; white-space: nowrap; }
.col-amount { font-family: 'Fira Code', monospace; font-size: 0.85rem; font-weight: 600; color: var(--brand-dark); white-space: nowrap; }
.col-notes  { color: var(--ink-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-uploader { color: var(--ink-faint); font-size: 0.8rem; white-space: nowrap; }
.col-actions { text-align: right; white-space: nowrap; }

/* Currency label */
.currency-label {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--ink-faint);
  margin-left: 3px;
  font-family: 'Fira Sans', inherit;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-teal { background: var(--brand-light); color: var(--brand-dark); }
.badge-gray { background: var(--surface-2);   color: var(--ink-muted); }

/* View PDF link */
.link-pdf {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  transition: color 140ms;
}
.link-pdf:hover { color: var(--brand-dark); text-decoration: underline; }

/* Empty + error states */
.table-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-faint);
  font-size: 0.9rem;
}
.table-state.is-error { color: var(--danger-fg); }

/* ═══════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════ */
.login-root { min-height: 100vh; display: flex; }

.brand-panel {
  display: none;
  position: relative;
  overflow: hidden;
  background: var(--brand-deeper);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}
@media (min-width: 900px) { .brand-panel { display: flex; width: 44%; } }

.smoke-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.brand-content { position: relative; z-index: 1; text-align: center; }
.brand-icon {
  width: 68px; height: 68px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 0 40px hsla(174,80%,60%,.4);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.brand-icon svg { width: 36px; height: 36px; color: var(--brand-light); }
.brand-divider {
  width: 44px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-mid), transparent);
  margin: 18px auto;
  border-radius: 1px;
}
.brand-title { font-size: 2rem; font-weight: 700; color: #fff; margin-bottom: 6px; }
.brand-sub  { font-size: 0.95rem; color: #5eead4; margin-bottom: 4px; }
.brand-sub2 { font-size: 0.82rem; color: #2dd4bf; opacity: .7; }

.form-panel {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 2rem; background: var(--bg);
}
.form-wrap { width: 100%; max-width: 380px; }

.mobile-logo { text-align: center; margin-bottom: 28px; }
@media (min-width: 900px) { .mobile-logo { display: none; } }
.mobile-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px;
}
.mobile-icon svg { width: 28px; height: 28px; color: var(--brand-light); }
.mobile-logo h1 { font-size: 1.35rem; font-weight: 700; color: var(--brand); }

.login-card { padding: 30px; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.login-heading    { font-size: 1.25rem; font-weight: 700; color: var(--ink); text-align: center; margin-bottom: 4px; }
.login-subheading { font-size: 0.8rem; color: var(--ink-muted); text-align: center; margin-bottom: 22px; }
.login-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.login-field label { font-size: 0.72rem; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.login-submit { width: 100%; padding: 10px; margin-top: 6px; font-size: 0.9rem; }
.login-error { margin-top: 10px; text-align: center; font-size: 0.82rem; color: var(--danger-fg); min-height: 18px; font-weight: 600; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .upload-grid { grid-template-columns: 1fr 1fr; }
  .topbar-sub  { display: none; }
  .page { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 500px) {
  .upload-grid { grid-template-columns: 1fr; }
}
