/* ═══════════════════════════════════════════════════════
   App shell — list, login, view and print
   Loaded after style.css, reuses its theme variables.
════════════════════════════════════════════════════════ */

a.hbtn, a.btn-primary, a.btn-ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ── Login ─────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 16px;
  padding: 36px 30px 30px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.login-glyph {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 13px;
  background: var(--inv-net-grad);
}
.login-title {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.login-sub {
  font-size: 12.5px;
  color: rgba(148, 163, 184, 0.85);
  margin: 4px 0 22px;
}
.login-input { margin-bottom: 12px; text-align: center; }
.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* ── List page shell ───────────────────────────────────── */
.list-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 24px 60px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 13px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.75);
}
.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.stat-sub { font-size: 11.5px; color: rgba(148, 163, 184, 0.7); }
.stat-due  .stat-value { color: #fbbf24; }
.stat-paid .stat-value { color: #34d399; }

/* ── Filter bar ────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.tab-row { display: flex; gap: 5px; flex-wrap: wrap; }
.ftab {
  padding: 7px 15px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.9);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.ftab:hover { background: rgba(255, 255, 255, 0.05); color: #e2e8f0; }
.ftab.active {
  background: var(--inv-accent);
  border-color: var(--inv-accent);
  color: #fff;
}
.search-form { display: flex; gap: 7px; align-items: center; }
.search-input { width: 250px; max-width: 55vw; }

/* ── Table ─────────────────────────────────────────────── */
.table-card {
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 13px;
  overflow: hidden;
}
.list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.list-table thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.8);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--sidebar-border);
  white-space: nowrap;
}
.list-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}
.list-table tbody tr:last-child td { border-bottom: none; }
.list-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.ta-r { text-align: right; }
.cell-strong { font-weight: 600; color: #e2e8f0; }
.cell-sub { font-size: 12px; color: rgba(148, 163, 184, 0.85); }
.cell-danger { color: #f87171; font-weight: 600; }
.cell-ok { color: #34d399; }
.inv-link {
  color: var(--inv-accent);
  font-weight: 700;
  text-decoration: none;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.01em;
}
.inv-link:hover { text-decoration: underline; }

/* ── Status pills ──────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 3.5px 10px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill-draft   { background: rgba(234, 179, 8, 0.14);  color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); }
.pill-due     { background: rgba(59, 130, 246, 0.14); color: #60a5fa; border-color: rgba(96, 165, 250, 0.35); }
.pill-partial { background: rgba(168, 85, 247, 0.14); color: #c084fc; border-color: rgba(192, 132, 252, 0.35); }
.pill-overdue { background: rgba(239, 68, 68, 0.14);  color: #f87171; border-color: rgba(248, 113, 113, 0.4); }
.pill-paid    { background: rgba(16, 185, 129, 0.14); color: #34d399; border-color: rgba(52, 211, 153, 0.35); }

/* ── Row actions ───────────────────────────────────────── */
.row-actions { display: inline-flex; gap: 5px; justify-content: flex-end; }
.ract {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border-radius: 7px;
  padding: 5px 9px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.14s;
}
.ract:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.ract:disabled { opacity: 0.5; cursor: wait; }
.ract-ok { color: #34d399; border-color: rgba(52, 211, 153, 0.35); }
.ract-ok:hover { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.ract-danger { color: #f87171; border-color: rgba(248, 113, 113, 0.3); }
.ract-danger:hover { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

.empty-state { padding: 60px 20px; text-align: center; color: rgba(148, 163, 184, 0.8); }
.empty-state p { margin-bottom: 16px; font-size: 14px; }

/* ── Editor save bar ───────────────────────────────────── */
.save-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.save-state {
  font-size: 11.5px;
  color: rgba(148, 163, 184, 0.8);
  white-space: nowrap;
}
.save-state.dirty { color: #fbbf24; }
.save-state.saved { color: #34d399; }

/* ── Standalone invoice view ───────────────────────────── */
.view-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px 20px 70px;
}
.view-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.view-toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-meta { font-size: 12px; color: rgba(148, 163, 184, 0.8); }

/* The paper is a fixed 800px document; let it scroll rather than break the page. */
.paper-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
  display: flex;
  justify-content: center;
}
.paper-scroll > #invoice-paper { flex: 0 0 auto; }

.share-box {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 14px;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 11px;
  padding: 12px 14px;
}
.share-box label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.75);
  white-space: nowrap;
}
.share-box input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  padding: 7px 10px;
  color: #e2e8f0;
  font: inherit;
  font-size: 12px;
}

/* Paid / overdue watermark on the rendered paper. */
.paper-stamp {
  position: absolute;
  top: 150px;
  right: 44px;
  font-family: 'Outfit', sans-serif;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 20px;
  border: 4px solid currentColor;
  border-radius: 10px;
  transform: rotate(-14deg);
  opacity: 0.16;
  pointer-events: none;
}
.stamp-paid    { color: #059669; }
.stamp-overdue { color: #dc2626; }
#invoice-paper { position: relative; }

/* ── Print ─────────────────────────────────────────────── */
@media print {
  @page { size: A4; margin: 10mm; }

  body { background: #fff !important; }

  .app-header,
  .view-toolbar,
  .share-box,
  .sidebar,
  .canvas-bar,
  .toast,
  .no-print { display: none !important; }

  .view-wrap,
  .canvas-area,
  .paper-scroll {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    display: block !important;
  }

  #invoice-paper {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    transform: none !important;
  }

  .inv-table tr,
  .inv-svc-table tr,
  .inv-fin-wrap,
  .inv-pay-section-wrap,
  .inv-notes-wrap { break-inside: avoid; }
}

/* ── Small screens ─────────────────────────────────────── */
@media (max-width: 760px) {
  .list-table thead { display: none; }
  .list-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .list-table tbody td { border: none; padding: 2px 0; }
  .list-table tbody td:nth-child(3),
  .list-table tbody td:nth-child(6) { display: none; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 6px; }
  .search-input { width: 100%; }
  .search-form { width: 100%; }
}

/* Amount in words, under the net-due badge on the paper. */
.amount-words {
  margin-top: 9px;
  font-size: 10.5px;
  font-style: italic;
  line-height: 1.5;
  color: #64748b;
  text-align: right;
}
.amount-words:empty { display: none; }

/* Paper status chip — states style.css does not define. */
.ih-status-chip.status-due {
  background: #dbeafe;
  color: #2563eb;
  border-color: #bfdbfe;
}
.ih-status-chip.status-partial {
  background: #f3e8ff;
  color: #9333ea;
  border-color: #e9d5ff;
}
