@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --charcoal: #1F1F1F;
  --charcoal-2: #1a1a1a;
  --orange: #F97316;
  --orange-hover: #EA6C0A;
  --orange-dark: #C2570B;
  --white: #FFFFFF;
  --bg: #FAFAFA;
  --border: #E5E7EB;
  --text: #111827;
  --text-2: #374151;
  --muted: #9CA3AF;
  --muted-2: #6B7280;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --green: #15803D;
  --green-bg: #F0FDF4;
  --blue: #1D4ED8;
  --blue-bg: #EFF6FF;
  --amber: #B45309;
  --amber-bg: #FFFBEB;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Montserrat', sans-serif; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.01em; }
h1 { font-size: 22px; color: var(--text); }
h2 { font-size: 14px; margin-top: 0; }
a { color: var(--orange-hover); text-decoration: none; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.small { font-size: 12.5px; }
.block { display: block; }
.eyebrow { font-size: 11px; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: 0.08em; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.brand-mark-text {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: var(--orange); color: var(--white);
  font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}
.auth-mark { width: 40px; height: 40px; font-size: 15px; }

/* --- Auth (split-panel login) --- */
.auth-body { min-height: 100vh; background: var(--bg); display: flex; }
.auth-side {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 380px;
  flex-shrink: 0;
  background: var(--charcoal-2);
  padding: 44px;
}
@media (min-width: 1024px) { .auth-side { display: flex; } }
.auth-side .brand-row { display: flex; align-items: center; gap: 10px; }
.auth-side .brand-name { color: var(--white); font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 14px; }
.auth-side h2 { color: var(--white); font-size: 30px; line-height: 1.2; margin: 16px 0 0; }
.auth-side .eyebrow { display: block; margin-bottom: 14px; }
.auth-side p.copy { color: rgba(255,255,255,0.4); font-size: 13.5px; line-height: 1.6; margin-top: 14px; }
.auth-side .copyright { color: rgba(255,255,255,0.2); font-size: 11.5px; margin: 0; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .mobile-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; }
@media (min-width: 1024px) { .auth-card .mobile-brand { display: none; } }
.auth-card h1 { font-size: 24px; margin-bottom: 2px; }
.auth-card .subtitle { color: var(--muted); font-size: 13.5px; margin: 0 0 26px; }
.auth-card form label { margin-bottom: 16px; }

/* --- Shell layout: top nav (no sidebar) --- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topnav {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 60px; flex-shrink: 0;
  background: var(--charcoal); position: sticky; top: 0; z-index: 30;
}
.topnav-brand { display: flex; align-items: center; gap: 9px; color: var(--white); font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 14.5px; flex-shrink: 0; }
.topnav-divider { width: 1px; height: 26px; background: rgba(255,255,255,0.12); flex-shrink: 0; }
.topnav-links { display: flex; align-items: center; gap: 4px; flex: 1; overflow-x: auto; }
.topnav-links a { color: rgba(255,255,255,0.62); font-size: 13.5px; font-weight: 500; padding: 8px 12px; border-radius: var(--r-sm); white-space: nowrap; }
.topnav-links a:hover { color: var(--white); background: rgba(255,255,255,0.06); }
.topnav-links a.active { color: var(--white); background: var(--orange); }
.nav-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; padding: 8px; cursor: pointer; }
.nav-toggle span { width: 20px; height: 2px; background: var(--white); border-radius: 1px; }
.topnav-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topnav-user { position: relative; }
.topnav-user > button { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; padding: 4px; }
.avatar-circle { width: 30px; height: 30px; border-radius: 50%; background: var(--orange); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; font-family: 'Montserrat', sans-serif; }
.user-name { color: var(--white); font-size: 13.5px; font-weight: 500; }
.topnav-user-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0,0,0,0.12); min-width: 190px; overflow: hidden; z-index: 40; }
.topnav-user-menu.open { display: block; }
.topnav-user-menu .menu-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.topnav-user-menu .menu-head strong { display: block; font-size: 13.5px; }
.topnav-user-menu .menu-head span { font-size: 12px; color: var(--muted); }
.topnav-user-menu a { display: block; padding: 10px 14px; font-size: 13.5px; color: var(--text-2); }
.topnav-user-menu a:hover { background: var(--bg); }

@media (max-width: 860px) {
  .topnav-links { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--charcoal); flex-direction: column; align-items: stretch; padding: 8px; box-shadow: 0 8px 16px rgba(0,0,0,0.2); }
  .topnav-links.open { display: flex; }
  .nav-toggle { display: flex; }
}

.shell-main { flex: 1; display: flex; }
.page { flex: 1; padding: 28px 32px; max-width: 1200px; width: 100%; margin: 0 auto; }
.shell-footer { text-align: center; padding: 18px; font-size: 12px; color: var(--muted); }

/* --- Page header --- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--muted); font-size: 13.5px; margin-top: -8px; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 600; border: 1px solid transparent; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-hover); }
.btn-secondary { background: var(--white); color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fde3e3; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- Cards / KPIs --- */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; }
.kpi-card .kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-card .kpi-value { font-family: 'Montserrat', sans-serif; font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi-card.accent-orange .kpi-value { color: var(--orange); }
.kpi-card.accent-red .kpi-value { color: var(--red); }
.kpi-card.accent-green .kpi-value { color: var(--green); }

/* --- Forms --- */
form label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13.5px; font-family: inherit; color: var(--text); background: var(--white);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,0.14); }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 160px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; }

/* --- Alerts --- */
.alert { padding: 11px 14px; border-radius: var(--r-md); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.alert-info { background: var(--blue-bg); color: var(--blue); border: 1px solid #bfdbfe; }

/* --- Tables --- */
table.data-table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
table.data-table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted-2); padding: 11px 14px; background: var(--bg); border-bottom: 1px solid var(--border); }
table.data-table td { padding: 12px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #FFFBF7; }
table.data-table td.num, table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-row td { text-align: center; color: var(--muted); padding: 36px 14px; }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-draft { background: #F3F4F6; color: var(--muted-2); }
.badge-sent { background: var(--blue-bg); color: var(--blue); }
.badge-paid { background: var(--green-bg); color: var(--green); }
.badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-void { background: #F3F4F6; color: var(--muted); text-decoration: line-through; }

/* --- Filters bar --- */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters-bar select, .filters-bar input { width: auto; margin-top: 0; min-width: 150px; }

/* --- Tabs --- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--muted-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--orange); border-bottom-color: var(--orange); }

/* --- Line-item editor (invoice_edit.php) --- */
.line-items-table { width: 100%; border-collapse: collapse; }
.line-items-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 6px 8px; }
.line-items-table td { padding: 6px 8px; vertical-align: top; }
.line-items-table input, .line-items-table select { margin-top: 0; }
.line-items-table td.amount-cell { text-align: right; font-weight: 600; padding-top: 15px; white-space: nowrap; }
.totals-box { max-width: 320px; margin-left: auto; margin-top: 16px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.totals-box .row.total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }

/* --- Invoice printable view --- */
.invoice-doc { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 44px; max-width: 820px; margin: 0 auto; }
.invoice-doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--charcoal); padding-bottom: 20px; margin-bottom: 24px; }
.invoice-doc-head .company-name { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 19px; }
.invoice-doc-head .tagline { color: var(--orange); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px; }
.invoice-doc-head .invoice-meta { text-align: right; }
.invoice-doc-head .invoice-meta h1 { font-size: 26px; margin-bottom: 4px; }
.invoice-bill-to { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.invoice-bill-to h3 { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; margin-bottom: 8px; }
.invoice-doc table.data-table { border: 1px solid var(--border); }
.invoice-footer-note { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted-2); }

@media print {
  .no-print { display: none !important; }
  body { background: var(--white); }
  .page { padding: 0; max-width: none; }
  .invoice-doc { border: none; padding: 0; }
}
