:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2430;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --info-soft: #e8f2fe;
  --info-dark: #1d4ed8;
  --radius: 10px;
}

html, body {
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

/* Navbar: stays fixed in place while the content below it scrolls */
.app-navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  z-index: 1030;
}
.app-content {
  flex: 1 1 auto;
  overflow-y: auto;
}
@media print {
  .app-navbar { display: none; }
  body { display: block; height: auto; }
  .app-content { overflow: visible; height: auto; }
}
.app-navbar .navbar-brand {
  color: var(--text);
}
.app-navbar .navbar-brand i { color: var(--accent); }
.app-navbar .nav-link {
  color: var(--text-muted);
  font-weight: 500;
}
.app-navbar .nav-link:hover { color: var(--text); }
.app-navbar .nav-link.active {
  color: var(--accent);
  font-weight: 600;
}
.app-navbar .user-menu { color: var(--text); }
.app-navbar .user-menu:hover { color: var(--accent-dark); }

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

.card-header {
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 600;
}

.btn-brand {
  background: var(--accent);
  color: #fff;
  border: none;
}
.btn-brand:hover { background: var(--accent-dark); color: #fff; }

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  color: var(--text);
}
.stat-card h2 { font-size: 1.75rem; margin: 0; font-weight: 700; }
.stat-card small {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .72rem;
  font-weight: 600;
}
.stat-card.blue { border-left-color: #4f46e5; }
.stat-card.green { border-left-color: #16a34a; }
.stat-card.orange { border-left-color: #d97706; }
.stat-card.purple { border-left-color: #7c3aed; }

table.items-table input, table.items-table select {
  min-width: 100px;
}

.remove-row-btn { cursor: pointer; }

/* Printable document view - invoice-style template */
.doc-view {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
}
.doc-view-inner { padding: 40px 40px 8px; }

.doc-view .doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 20px;
}
.doc-view .doc-header-left { flex: 1 1 0; min-width: 0; }
.doc-view .doc-header-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
}
.doc-view .doc-header-logo img { max-height: 72px; max-width: 160px; object-fit: contain; }
.doc-view .biz-name { font-size: 1.6rem; font-weight: 800; color: var(--text); margin: 0 0 2px; }
.doc-view .biz-tagline { color: var(--accent); font-size: .8rem; font-weight: 600; letter-spacing: .03em; }
.doc-view .biz-website { color: var(--text); font-size: .85rem; font-weight: 700; margin-top: 2px; }

.doc-view .doc-contact-line {
  color: var(--text-muted);
  font-size: .82rem;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.doc-view .doc-title { text-align: right; flex: 1 1 0; }
.doc-view .doc-title h1 {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 1.5px;
  font-size: 2.1rem;
  margin: 0;
}

.doc-meta-row {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.doc-box {
  flex: 1 1 260px;
  min-width: 220px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.doc-box.doc-box-ref { background: var(--info-soft); }
.doc-box-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--accent-dark);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.doc-box-ref .doc-box-title { color: var(--info-dark); }
.doc-box table { width: 100%; }
.doc-box table td { padding: 2px 0; font-size: .9rem; vertical-align: top; }
.doc-box table td:first-child { color: var(--text-muted); padding-right: 12px; white-space: nowrap; }

table.doc-items { margin: 0; }
table.doc-items thead th {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border: none;
}
table.doc-items tbody tr:nth-child(even) { background: var(--accent-soft); }
table.doc-items td, table.doc-items th { padding: 10px 12px; }

.doc-view .totals-box {
  width: 320px;
  margin-left: auto;
  margin-top: 20px;
}
.doc-view .totals-box table { width: 100%; }
.doc-view .totals-box table td { padding: 4px 8px; }
.doc-view .totals-box .grand td {
  font-weight: 700;
  font-size: 1.2rem;
  border-top: 2px solid var(--accent);
  color: var(--accent-dark);
  padding-top: 10px;
}

.doc-bottom-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.doc-bottom-row > div { flex: 1 1 220px; min-width: 220px; }
.doc-bottom-title {
  font-weight: 700;
  color: var(--accent-dark);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.doc-bottom-row .small-line { font-size: .88rem; color: var(--text); margin-bottom: 2px; }

.doc-footer-bar {
  margin-top: 32px;
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 14px 20px;
  font-size: .85rem;
  font-weight: 500;
}

.signature-row { margin-top: 50px; }
.signature-line { border-top: 1px solid #333; margin-top: 40px; padding-top: 5px; }

/* Login / setup pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 1rem;
}
.auth-brand i { color: var(--accent); font-size: 1.2rem; }
.auth-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* Logo on login page */
.auth-logo {
  text-align: center;
}
.auth-logo img {
  max-height: 72px;
  max-width: 100%;
  object-fit: contain;
}
