/* ============================================================
   Reusable components: buttons, inputs, cards, status pills,
   toolbar, table shell, invoice-specific widgets.
   ============================================================ */

.card{
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.field-label{
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 6px; letter-spacing: .2px;
}
.field-input, select, textarea.field-input{
  width: 100%; font-family: var(--font); font-size: 14px; padding: 10px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--input-bg); color: var(--text-primary); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field-input:focus, select:focus, textarea.field-input:focus{
  border-color: var(--brand-green-soft); box-shadow: 0 0 0 3px rgba(74,81,71,.14);
}
.field-hint{ font-size: 11.5px; color: var(--text-secondary); margin-top: 5px; }
.field-row{ display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 16px; }
.field-row.cols-3{ grid-template-columns: repeat(3, 1fr); }
.auth-field{ margin-bottom: 16px; }

.btn{
  font-family: var(--font); font-size: 13px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--surface-alt); color: var(--text-primary);
  cursor: pointer; outline: none; transition: border-color .15s ease, background .15s ease, transform .1s ease;
  font-weight: 600;
}
.btn:hover{ border-color: var(--brand-green-soft); }
.btn:active{ transform: scale(.97); }
.btn:disabled{ opacity: .55; cursor: not-allowed; }
.btn.primary{
  background: linear-gradient(135deg, var(--brand-green) 0%, var(--brand-green-deep) 100%);
  color: #fbfaf6; border: none;
}
.btn.primary:hover{ filter: brightness(1.08); }
.btn.gold{
  background: linear-gradient(135deg, #bb9a5c 0%, var(--brand-gold) 100%);
  color: #2a2210; border: none;
}
.btn.gold:hover{ filter: brightness(1.06); }
.btn.danger{ color: var(--st-overdue-fg); border-color: var(--st-overdue-dot); }
.btn.danger:hover{ background: var(--st-overdue-bg); }
.btn.block{ width: 100%; }
.btn.sm{ padding: 6px 12px; font-size: 12px; }

.error-banner{
  background: var(--st-overdue-bg); color: var(--st-overdue-fg); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px;
}
.success-banner{
  background: var(--st-paid-bg); color: var(--st-paid-fg); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px;
}

/* ---------- Status pills (draft / pending_approval / approved / sent / paid) ---------- */
.status-pill{
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 5px 12px 5px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.status-pill .dot{ width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-pill.st-draft{ background: var(--st-draft-bg); color: var(--st-draft-fg); }
.status-pill.st-draft .dot{ background: var(--st-draft-dot); }
.status-pill.st-pending_approval{ background: var(--st-pending-bg); color: var(--st-pending-fg); }
.status-pill.st-pending_approval .dot{ background: var(--st-pending-dot); }
.status-pill.st-approved{ background: var(--st-approved-bg); color: var(--st-approved-fg); }
.status-pill.st-approved .dot{ background: var(--st-approved-dot); }
.status-pill.st-sent{ background: var(--st-sent-bg); color: var(--st-sent-fg); }
.status-pill.st-sent .dot{ background: var(--st-sent-dot); }
.status-pill.st-paid{ background: var(--st-paid-bg); color: var(--st-paid-fg); }
.status-pill.st-paid .dot{ background: var(--st-paid-dot); }

.type-pill{
  display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
}
.type-pill.type-client{ background: var(--brand-beige-2); color: var(--brand-green-deep); }
.type-pill.type-va{ background: var(--surface-alt); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* ---------- Stat cards (dashboard KPIs) ---------- */
.stat-grid{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card{
  background: var(--surface); border: 1px solid var(--border-color); border-left: 4px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover{ transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-label{
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-secondary); margin-bottom: 8px;
}
.stat-card .stat-value{ font-size: 28px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-card:nth-child(4n+1){ border-left-color: var(--brand-green); }
.stat-card:nth-child(4n+1) .stat-value{ color: var(--brand-green-deep); }
.stat-card:nth-child(4n+2){ border-left-color: var(--brand-gold); }
.stat-card:nth-child(4n+2) .stat-value{ color: #8a6f3c; }
.stat-card:nth-child(4n+3){ border-left-color: var(--st-approved-dot); }
.stat-card:nth-child(4n+3) .stat-value{ color: var(--st-approved-fg); }
.stat-card:nth-child(4n+4){ border-left-color: var(--st-paid-dot); }
.stat-card:nth-child(4n+4) .stat-value{ color: var(--st-paid-fg); }
@media (max-width: 1100px){ .stat-grid{ grid-template-columns: repeat(2, 1fr); } }

/* ---------- Reminder card: what's missing this period ---------- */
.reminder-card{
  background: linear-gradient(135deg, #fbf6ea 0%, var(--surface) 60%);
  border: 1px solid var(--brand-gold); border-radius: var(--radius-md);
  padding: 18px 20px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
:root[data-theme="dark"] .reminder-card, @media (prefers-color-scheme: dark) { .reminder-card { background: var(--surface); } }
.reminder-card .reminder-head{ display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.reminder-card .reminder-head .icon{
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-gold); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.reminder-card h3{ margin: 0; font-size: 15px; }
.reminder-card .reminder-sub{ font-size: 12px; color: var(--text-secondary); margin: 2px 0 0; }
.reminder-list{ display: flex; flex-wrap: wrap; gap: 8px; }
.reminder-chip{
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface-alt); border: 1px solid var(--border-color);
  border-radius: 999px; padding: 6px 12px 6px 10px; font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--text-primary);
  transition: border-color .15s ease, transform .1s ease;
}
.reminder-chip:hover{ border-color: var(--brand-gold); transform: translateY(-1px); }
.reminder-chip .chip-type{ font-size: 10px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; }
.reminder-empty{ font-size: 13px; color: var(--st-paid-fg); font-weight: 600; }

/* ---------- Toolbar (search/filter bar) ---------- */
.toolbar{
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.search-box{ flex: 1 1 240px; position: relative; min-width: 220px; }
.search-box input{
  width: 100%; padding: 10px 14px 10px 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--surface-alt); color: var(--text-primary);
  font-size: 13.5px; outline: none;
}
.search-box::before{
  content: "\2315"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: var(--text-secondary); pointer-events: none;
}
.results-count{ font-size: 12.5px; color: var(--text-secondary); margin-left: auto; white-space: nowrap; padding-left: 8px; }
.toolbar select.field-input{ width: auto; min-width: 150px; }

/* ---------- Table ---------- */
.table-wrap{ background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll{ overflow-x: auto; }
table{ width: 100%; border-collapse: collapse; }
table.items-table{ min-width: 900px; }
thead th{
  position: sticky; top: 0; background: var(--surface-alt); z-index: 5;
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-secondary); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
tbody tr{ border-bottom: 1px solid var(--border-color); transition: background .12s ease; }
tbody tr:last-child{ border-bottom: none; }
tbody tr.clickable{ cursor: pointer; }
tbody tr:hover{ background: var(--row-hover); }
tbody td{ padding: 10px 14px; font-size: 13.5px; vertical-align: middle; color: var(--text-primary); }
td.strong-cell{ font-weight: 600; }
td.num-cell{ text-align: right; font-variant-numeric: tabular-nums; }
td.actions-cell{ white-space: nowrap; }
td.actions-cell .btn{ padding: 6px 10px; font-size: 12px; margin-right: 6px; }

.empty-state{ text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state .big{ font-size: 38px; margin-bottom: 10px; }
.empty-state .eyebrow{ font-size: 13px; margin-bottom: 6px; }
.empty-state .cta{ margin-top: 16px; }

.skeleton-row td{ padding: 14px; }
.skeleton-bar{ height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border-color) 37%, var(--surface-alt) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer{ 0%{ background-position: 100% 50%; } 100%{ background-position: 0 50%; } }

.table-scroll::-webkit-scrollbar{ height: 10px; }
.table-scroll::-webkit-scrollbar-thumb{ background: var(--border-color); border-radius: 6px; }
.table-scroll::-webkit-scrollbar-track{ background: transparent; }

/* ---------- Modal / drawer ---------- */
.modal-overlay{
  position: fixed; inset: 0; background: rgba(20,22,18,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: flex-end;
}
.modal-overlay[hidden]{ display: none; }
.modal-panel{
  width: 100%; max-width: 520px; height: 100%; background: var(--surface);
  box-shadow: var(--shadow-lg); overflow-y: auto; padding: 28px 28px 40px;
  animation: slideIn .2s ease;
}
.modal-panel.wide{ max-width: 680px; }
@keyframes slideIn{ from{ transform: translateX(24px); opacity: 0; } to{ transform: translateX(0); opacity: 1; } }
.modal-header{ display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.modal-title{ font-size: 17px; font-weight: 700; margin: 0; font-family: var(--font-display); }
.modal-close{ background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary); line-height: 1; padding: 4px; }
.modal-close:hover{ color: var(--text-primary); }
.modal-section{ margin-bottom: 24px; }
.modal-section-title{ font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); margin-bottom: 10px; }
.modal-actions{ display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; }
.modal-actions .btn{ width: auto; }

.timeline-item{ display: flex; gap: 10px; padding: 10px 0; font-size: 13px; border-bottom: 1px solid var(--border-color); }
.timeline-item:last-child{ border-bottom: none; }
.timeline-item .timeline-dot{ width: 7px; height: 7px; border-radius: 50%; background: var(--brand-green-soft); margin-top: 6px; flex-shrink: 0; }
.timeline-item .timeline-body{ flex: 1; }
.timeline-item .timeline-meta{ color: var(--text-secondary); font-size: 11.5px; margin-top: 2px; }

.toolbar-title{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar-title h1{ font-size: 20px; margin: 0; }
.toolbar-title .sub{ font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.toolbar-title-actions{ display: flex; gap: 10px; }

.pill{ display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.pill.active{ background: var(--st-paid-bg); color: var(--st-paid-fg); }
.pill.inactive{ background: var(--st-draft-bg); color: var(--st-draft-fg); }

.checkbox-cell{ width: 32px; }

/* ---------- Invoice generation form ---------- */
.invoice-form-layout{ display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 1000px){ .invoice-form-layout{ grid-template-columns: 1fr; } }
.form-card{ padding: 22px 24px; }
.form-card + .form-card{ margin-top: 18px; }
.form-card h2{ font-size: 15px; margin: 0 0 16px; }
.type-toggle{ display: flex; gap: 8px; margin-bottom: 20px; }
.type-toggle button{
  flex: 1; padding: 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-color);
  background: var(--surface-alt); font-family: var(--font); font-weight: 700; font-size: 13.5px; cursor: pointer;
  color: var(--text-secondary); transition: all .15s ease;
}
.type-toggle button.active{
  border-color: var(--brand-green); background: var(--brand-green); color: #fff;
}

.summary-card{ position: sticky; top: 96px; }
.summary-row{ display: flex; justify-content: space-between; padding: 8px 0; font-size: 13.5px; border-bottom: 1px solid var(--border-color); }
.summary-row:last-of-type{ border-bottom: none; }
.summary-row .label{ color: var(--text-secondary); }
.summary-total{ display: flex; justify-content: space-between; padding-top: 14px; margin-top: 6px; border-top: 2px solid var(--text-primary); font-size: 18px; font-weight: 700; }

/* ---------- Invoice detail view ---------- */
.detail-header{ display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; flex-wrap: wrap; gap: 14px; }
.detail-header .num{ font-size: 24px; font-weight: 700; font-family: var(--font-display); }
.detail-header .sub{ font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.detail-actions{ display: flex; gap: 10px; flex-wrap: wrap; }
.approval-link-box{
  display: flex; align-items: center; gap: 10px; background: var(--surface-alt); border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; margin-top: 10px;
}
.approval-link-box input{ flex: 1; border: none; background: transparent; font-family: monospace; font-size: 12px; color: var(--text-secondary); outline: none; }

/* ---------- Public approval page ---------- */
.approve-shell{ min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand-green-deep); padding: 24px; }
.approve-card{ width: 100%; max-width: 460px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 36px; text-align: center; }
.approve-card .brand-wordmark{ display: inline-flex; }
.approve-card .brand-wordmark-main{ color: var(--accent-2); font-size: 20px; }
.approve-card .brand-wordmark-sub{ color: var(--text-secondary); }
.approve-card h1{ font-size: 20px; margin: 0 0 6px; }
.approve-card .sub{ font-size: 13.5px; color: var(--text-secondary); margin-bottom: 24px; }
.approve-amount{ font-size: 36px; font-weight: 700; margin: 20px 0 6px; }
.approve-meta{ font-size: 13px; color: var(--text-secondary); margin-bottom: 28px; }

/* ---------- Filter panel ---------- */
.filter-panel{
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.filter-panel[hidden]{ display: none; }
.filter-field{ display: flex; flex-direction: column; gap: 4px; }
.filter-field label{ font-size: 11.5px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .3px; }
@media (max-width: 900px){ .filter-panel{ grid-template-columns: repeat(2, 1fr); } }
