/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: #1a1a2e;
  background: #f0f4f8;
  min-height: 100vh;
}

/* ─── Setup Banner ─────────────────────────────────────────────────────────── */
.setup-banner {
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  color: #92400e;
  padding: 10px 24px;
  font-size: 14px;
  text-align: center;
}
.setup-banner a { color: #92400e; font-weight: 600; }

/* ─── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 32px 16px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 40px 36px;
}

.logo-area {
  text-align: center;
  margin-bottom: 32px;
}
.logo-icon { font-size: 40px; margin-bottom: 12px; }
.logo-area h1 { font-size: 24px; font-weight: 700; color: #1a1a2e; }
.subtitle { color: #6b7280; font-size: 14px; margin-top: 6px; line-height: 1.5; }

.help-text {
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  margin-top: 20px;
  line-height: 1.5;
}

/* ─── Portal Page ──────────────────────────────────────────────────────────── */
.portal-page {
  display: flex;
  flex-direction: column;
}

.portal-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-logo { font-weight: 700; font-size: 17px; color: #1a1a2e; }
.header-user { display: flex; align-items: center; gap: 12px; }
#header-name { color: #6b7280; font-size: 14px; }

.portal-layout {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 24px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  width: 100%;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  text-align: left;
  transition: all 0.15s;
}
.nav-item:hover { background: #f3f4f6; color: #1a1a2e; }
.nav-item.active { background: #eff6ff; color: #2563eb; }
.nav-icon { font-size: 16px; }

/* ─── Content Panel ────────────────────────────────────────────────────────── */
.portal-content {
  flex: 1;
  min-width: 0;
}

.tab-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
  padding: 28px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.panel-header h2 { font-size: 20px; font-weight: 700; }

.balance-badge {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ─── Tables ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  border-bottom: 1px solid #f3f4f6;
}
.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid #f9fafb;
  color: #374151;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }

.muted { color: #9ca3af; }
.paid-check { color: #10b981; font-weight: 600; font-size: 13px; }

/* ─── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }
.badge-yellow { background: #fef3c7; color: #92400e; }

/* ─── Account Card ─────────────────────────────────────────────────────────── */
.account-card { max-width: 560px; }
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 0;
}
.form-row .form-group { flex: 1; }

/* ─── Forms ────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.form-group input {
  padding: 10px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: #2563eb; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: #2563eb;
  color: #fff;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: #6b7280;
  border: 1.5px solid #e5e7eb;
}
.btn-ghost:hover { background: #f3f4f6; }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ─── Messages ─────────────────────────────────────────────────────────────── */
.error-msg {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}
.success-msg {
  background: #d1fae5;
  color: #065f46;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}
.error-banner {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
}
.loading-state {
  color: #9ca3af;
  font-size: 14px;
  padding: 20px 0;
}
.empty-state {
  color: #9ca3af;
  font-size: 14px;
  padding: 32px 0;
  text-align: center;
}

/* ─── Invoice expand rows ──────────────────────────────────────────────────── */
.inv-row { cursor: pointer; }
.inv-row td { transition: background 0.12s; }
.inv-row:hover td { background: #f0f4ff !important; }

.inv-chev-cell { width: 28px; padding-right: 0 !important; }
.inv-chev {
  display: inline-block;
  color: #9ca3af;
  font-size: 17px;
  font-weight: 300;
  transition: transform 0.2s;
  line-height: 1;
  user-select: none;
}
.inv-chev.open { transform: rotate(90deg); color: #2563eb; }

.inv-detail-row td { padding: 0 !important; background: #f8faff; }
.inv-detail-panel {
  padding: 20px 24px 24px;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}

.inv-detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 20px;
}
.inv-addr-block { min-width: 160px; }
.inv-addr-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #9ca3af;
  margin-bottom: 5px;
}
.inv-addr-value { font-size: 13px; color: #374151; line-height: 1.6; }

.inv-lines-table { margin-bottom: 16px; font-size: 13px; }
.inv-lines-table th, .inv-lines-table td { padding: 9px 10px; }
.text-right { text-align: right !important; }

.inv-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
}
.inv-total-row {
  display: flex;
  gap: 48px;
  font-size: 13px;
  color: #374151;
  min-width: 260px;
  justify-content: space-between;
}
.inv-total-final {
  font-weight: 700;
  font-size: 14px;
  border-top: 1px solid #e5e7eb;
  padding-top: 6px;
  margin-top: 2px;
}
.inv-total-due  { color: #dc2626; font-weight: 700; font-size: 14px; }
.inv-total-paid { color: #10b981; font-weight: 600; }

.po-tag {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}


/* ─── Payment type badges ──────────────────────────────────────────────────── */
.pmt-type-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.pmt-card  { background: #eff6ff; color: #1d4ed8; }
.pmt-check { background: #fef3c7; color: #92400e; }
.pmt-cash  { background: #d1fae5; color: #065f46; }
.pmt-other { background: #f3f4f6; color: #374151; }
.pmt-mono  { font-family: 'Courier New', monospace; font-size: 13px; letter-spacing: 0.04em; }

/* ─── Estimate action buttons ──────────────────────────────────────────────── */
.btn-success {
  background: #10b981;
  color: #fff;
}
.btn-success:hover { background: #059669; }
.btn-success:disabled { background: #6ee7b7; cursor: not-allowed; }

.btn-danger {
  background: transparent;
  color: #dc2626;
  border: 1.5px solid #dc2626;
}
.btn-danger:hover { background: #fee2e2; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

.action-group { display: flex; gap: 8px; align-items: center; }

/* ─── Nav badge (pending count) ────────────────────────────────────────────── */
.nav-badge {
  background: #ef4444;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  margin-left: auto;
  line-height: 1.6;
}

/* ─── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .portal-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .form-row { flex-direction: column; }
  .data-table th:nth-child(3),
  .data-table td:nth-child(3) { display: none; }
}
