:root {
  /* Warm, friendly palette for non-accountants */
  --bg: #f4f6fb;
  --bg-tint: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6eaf2;
  --border-strong: #d5dbe8;
  --text: #1b2333;
  --text-soft: #46536b;
  --muted: #7c8aa3;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0fe;
  --accent: #0ea5a4;
  --success: #16a34a;
  --success-soft: #e7f7ec;
  --warning: #d97706;
  --warning-soft: #fdf3e3;
  --danger: #e0483d;
  --danger-soft: #fdecea;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 55, 0.06), 0 1px 3px rgba(20, 30, 55, 0.05);
  --shadow: 0 4px 14px rgba(20, 30, 55, 0.08);
  --shadow-lg: 0 12px 34px rgba(20, 30, 55, 0.14);
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.01em; }
a { color: var(--primary); }

/* ---------------- Layout ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0;
  background: linear-gradient(185deg, #1a2140 0%, #151a33 55%, #131730 100%);
  color: #c4cbdd;
  padding: 20px 14px 28px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  color: #fff; font-weight: 800; font-size: 19px;
  padding: 4px 10px 2px; display: flex; align-items: center; gap: 9px;
}
.sidebar .brand .brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 800;
}
.sidebar .brand-sub { font-size: 11.5px; color: #8b97b4; padding: 2px 10px 14px; }

.nav-section { margin-top: 16px; }
.nav-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: #737fa0; padding: 4px 12px; font-weight: 700;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 1px 0; color: #b9c1d6;
  text-decoration: none; font-size: 13.5px; font-weight: 500;
  border-radius: 9px; transition: background .12s, color .12s;
}
.sidebar a .nav-ico { width: 18px; text-align: center; font-size: 14px; opacity: .95; }
.sidebar a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.active {
  background: linear-gradient(90deg, var(--primary), #6366f1);
  color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}
.sidebar a.active .nav-ico { opacity: 1; }
.sidebar .signout { margin-top: 20px; color: #8b97b4; }
.sidebar .signout:hover { background: rgba(255,255,255,0.05); color: #fff; }

.main { flex: 1; padding: 30px 38px; max-width: 1180px; width: 100%; }

/* ---------------- Greeting / hero ---------------- */
.hero {
  background: linear-gradient(120deg, #ffffff 0%, #f3f2ff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.hero h1 { font-size: 23px; margin-bottom: 4px; }
.hero p { color: var(--text-soft); font-size: 13.5px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.qa {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 15px; border-radius: 11px; cursor: pointer;
  background: #fff; border: 1px solid var(--border-strong);
  font-size: 13.5px; font-weight: 600; color: var(--text); text-decoration: none;
  box-shadow: var(--shadow-sm); transition: transform .1s, box-shadow .12s, border-color .12s;
}
.qa:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--primary); }
.qa .qa-ico { font-size: 16px; }

/* ---------------- Cards & KPIs ---------------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.kpi { position: relative; overflow: hidden; }
.kpi .kpi-ico {
  position: absolute; top: 16px; right: 16px; width: 34px; height: 34px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--primary-soft);
}
.kpi .label { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; font-weight: 600; padding-right: 40px; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.kpi .value.green { color: var(--success); }
.kpi .value.red { color: var(--danger); }
.kpi .value.orange { color: var(--warning); }

/* ---------------- Tables ---------------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
th, td { text-align: left; padding: 12px 15px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-click { cursor: pointer; }

h2 { font-size: 15.5px; }

/* ---------------- Badges ---------------- */
.badge { padding: 3px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em; }
.badge.draft { background: #eef1f6; color: #566079; }
.badge.sent { background: #e5eafe; color: #4338ca; }
.badge.partially_paid { background: var(--warning-soft); color: #b45309; }
.badge.paid { background: var(--success-soft); color: #15803d; }
.badge.overdue { background: var(--danger-soft); color: #c0392f; }
.badge.cancelled { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: block; font-size: 12.5px; color: var(--text-soft); margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong);
  border-radius: 9px; font-size: 14px; background: #fff; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.field { margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 10px 18px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 13.5px; font-weight: 700;
  cursor: pointer; text-decoration: none; box-shadow: 0 2px 8px rgba(79,70,229,0.28);
  transition: background .12s, transform .1s, box-shadow .12s;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn.secondary { background: #eef1f6; color: var(--text); box-shadow: none; }
.btn.secondary:hover { background: #e2e7f0; }
.btn.danger { background: var(--danger); box-shadow: none; }
.btn.small { padding: 6px 13px; font-size: 12.5px; }

/* ---------------- Page header ---------------- */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }

/* ---------------- Auth ---------------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e9e8ff 0%, var(--bg) 60%);
  padding: 20px;
}
.auth-card { width: 400px; box-shadow: var(--shadow-lg); border-radius: 18px; padding: 30px 30px 26px; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .brand-mark {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 21px; font-weight: 800;
}
.auth-brand .brand-name { font-weight: 800; font-size: 17px; }
.auth-card h1 { margin-bottom: 18px; font-size: 20px; text-align: center; }
.auth-card .field { margin-bottom: 13px; }
.auth-card .btn { width: 100%; margin-top: 6px; padding: 12px; }
.auth-toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-toggle a { color: var(--primary); cursor: pointer; font-weight: 600; }

.error-msg { background: var(--danger-soft); color: #c0392f; padding: 11px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; font-weight: 500; }
.ok-msg { background: var(--success-soft); color: #15803d; padding: 11px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; font-weight: 500; }
.empty { color: var(--muted); text-align: center; padding: 34px; font-size: 13.5px; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 20, 40, 0.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal { width: 560px; max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-lg); border-radius: 16px; }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Invoice item rows */
.item-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }

/* ---------------- Section titles ---------------- */
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; color: var(--text); }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------------- Drag & drop overlay ---------------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center;
  background: rgba(79, 70, 229, 0.14); backdrop-filter: blur(3px);
}
.drop-overlay.show { display: flex; }
.drop-card {
  background: #fff; border: 2.5px dashed var(--primary); border-radius: 20px;
  padding: 48px 60px; text-align: center; box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.drop-card .drop-emoji { font-size: 46px; }
.drop-card h2 { font-size: 20px; margin: 12px 0 6px; }
.drop-card p { color: var(--muted); font-size: 13.5px; }

/* dropzone inline (bank page) */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 14px;
  padding: 26px; text-align: center; background: var(--surface-2);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .dz-emoji { font-size: 30px; }
.dropzone h3 { font-size: 15px; margin: 8px 0 4px; }
.dropzone p { color: var(--muted); font-size: 12.5px; }

/* ---------------- Toasts ---------------- */
.toast-wrap { position: fixed; right: 22px; bottom: 22px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow-lg);
  min-width: 260px; max-width: 360px; font-size: 13.5px; animation: toastIn .18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast .toast-title { font-weight: 700; margin-bottom: 2px; }
.toast .toast-body { color: var(--text-soft); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px; }
  .main { padding: 20px 16px; }
  .nav-section { margin-top: 10px; }
}
