/* Invoice Phase-In app — screen styles (print styles at the bottom).
   Visual language matches invoicephasein.com: dark slate/violet,
   Archivo body, DM Serif Display headings. */
:root {
  color-scheme: dark;
  --paper:#06050d; --ink:#ece9f7; --muted:#a49fc4; --line:#2b2350;
  --panel:#100c22; --panel2:#171130; --violet:#8b5cff; --violet-strong:#6126d6;
  --violet-bright:#c855ff; --slate:#2E4A68; --bad:#ff7a8a; --good:#7be2a8;
  --warn:#ffd97a;
}
* { box-sizing:border-box; }
body { margin:0; background:linear-gradient(180deg,#05040f 0%,#0a1030 34%,#170b36 68%,#030208 100%); background-attachment:fixed; color:var(--ink); font-family:"Archivo",sans-serif; font-size:15px; line-height:1.5; }
a { color:var(--violet-bright); }
h1 { font-family:"DM Serif Display",serif; font-weight:400; font-size:34px; margin:0 0 6px; }
h2 { font-family:"DM Serif Display",serif; font-weight:400; font-size:24px; margin:24px 0 10px; }
h3 { margin:0 0 6px; font-size:17px; }
.eyebrow { margin:0 0 10px; color:var(--violet); font-size:12px; font-weight:700; letter-spacing:.13em; text-transform:uppercase; }
.muted { color:var(--muted); }
.small { font-size:13px; }
.hidden { display:none !important; }

[hidden] { display:none !important; }
form label { display:block; margin:14px 0 4px; font-weight:600; font-size:13px; }
input, select, textarea {
  width:100%; background:#0a0720; color:var(--ink); border:1px solid var(--line);
  padding:10px 12px; font:inherit; font-size:15px; border-radius:2px;
}
input:focus, select:focus, textarea:focus { outline:2px solid var(--violet); outline-offset:0; }
textarea { min-height:90px; resize:vertical; }
.form-error { color:var(--bad); font-size:14px; }

/* ---------- buttons ---------- */
.button {
  display:inline-flex; align-items:center; justify-content:center; min-height:42px;
  padding:10px 18px; background:var(--violet-strong); color:#fff; text-decoration:none;
  font-weight:700; border:3px solid var(--slate); cursor:pointer; font:inherit; font-size:15px;
}
.button:hover { background:var(--violet); }
.button.secondary { background:transparent; color:var(--ink); }
.button.danger { background:transparent; border-color:#5a2330; color:var(--bad); }
.button.small-btn { min-height:34px; padding:6px 12px; font-size:13px; }
button.link-btn { background:none; border:none; color:var(--violet-bright); cursor:pointer; font:inherit; padding:0; text-decoration:underline; }

/* ---------- layout ---------- */
.topbar { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 22px; border-bottom:1px solid var(--line); background:rgba(6,5,13,.85); position:sticky; top:0; z-index:5; flex-wrap:wrap; }
.brand { font-family:"DM Serif Display",serif; font-size:22px; }
.topbar-right { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.plan-badge { background:var(--slate); color:#fff; padding:3px 10px; font-size:12px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; }
.plan-badge.pro { background:var(--violet-strong); }
.layout { display:flex; align-items:flex-start; }
.sidebar { width:230px; flex:0 0 230px; padding:18px 12px; display:flex; flex-direction:column; gap:2px; }
.sidebar .nav-link { color:var(--ink); text-decoration:none; padding:10px 12px; font-weight:600; border-left:3px solid transparent; }
.sidebar .nav-link:hover { color:var(--violet-bright); }
.sidebar .nav-link.active { border-left-color:var(--violet); background:var(--panel); }
.sidebar .nav-link.nav-big { font-size:17px; border:2px solid var(--violet); border-radius:10px; margin-top:6px; height:52px; padding:0 12px; display:flex; align-items:center; box-sizing:border-box; }
.sidebar .nav-link.nav-big.active { border-color:var(--violet-bright); }
.sidebar .nav-link.nav-group-start { margin-top:22px; }
.pro-tag { font-size:10px; background:var(--violet-strong); color:#fff; padding:1px 6px; margin-left:6px; vertical-align:middle; letter-spacing:.05em; }
.content { flex:1; min-width:0; padding:26px 30px 80px; max-width:1060px; }
@media (max-width:760px) {
  .layout { flex-direction:column; }
  .sidebar { width:100%; flex:none; flex-direction:row; flex-wrap:wrap; padding:10px; }
  .sidebar .nav-link { border-left:none; border-bottom:3px solid transparent; }
  .sidebar .nav-link.active { border-bottom-color:var(--violet); }
  .content { padding:18px 16px 60px; width:100%; }  /* width:100% stops the column flex layout sizing .content to wide content (e.g. tables) — without it .table-scroll has no constrained width to scroll within */
}

/* ---------- components ---------- */
.cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:14px; margin:18px 0; }
.card { background:var(--panel); border:1px solid var(--line); padding:18px; }
.card .big { font-family:"DM Serif Display",serif; font-size:30px; }
table.list { border-collapse:collapse; width:100%; margin:12px 0; }
.table-scroll { overflow-x:auto; -webkit-overflow-scrolling:touch; margin:12px 0; }
.table-scroll table.list { margin:0; }
table.list th, table.list td { border-bottom:1px solid var(--line); padding:10px 8px; text-align:left; vertical-align:top; }
table.list th { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.07em; }
.row-actions { white-space:nowrap; }
.row-actions button { margin-right:6px; }
.panel { background:var(--panel); border:1px solid var(--line); padding:20px; margin:16px 0; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:0 18px; }
@media (max-width:760px) { .grid2 { grid-template-columns:1fr; } }
.status { font-size:12px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; padding:2px 8px; background:var(--slate); color:#fff; }
.status.paid { background:#1d5c3a; }
.status.overdue { background:#7a2233; }
.status.partial, .status.sent { background:#5c4a1d; }
.notice { border:1px solid var(--violet); background:var(--panel2); padding:14px 16px; margin:14px 0; }
.notice.warn { border-color:#5c4a1d; }
.line-items { width:100%; border-collapse:collapse; }
.line-items th, .line-items td { padding:6px 4px; border-bottom:1px solid var(--line); }
.line-items input { padding:7px 8px; }
.tier-box { border:1px solid var(--line); background:var(--panel); padding:16px; margin:14px 0; }
.tier-box.picked { border-color:var(--violet); }
.checkline { display:flex; gap:8px; align-items:center; margin:8px 0; font-weight:500; }
.checkline input { width:auto; }

/* ---------- contracts: signature pad ---------- */
.sig-canvas {
  display:block; width:100%; height:180px; background:#fff; border:1px solid var(--line);
  border-radius:2px; touch-action:none; cursor:crosshair;
}
.sig-preview { background:#fff; max-width:340px; width:100%; border:1px solid var(--line); }
.pay-url-input { font-family:monospace; font-size:13px; }

/* ---------- print fallback panel (screen only) ---------- */
#print-fallback {
  position:fixed; left:50%; bottom:26px; transform:translateX(-50%);
  width:min(620px, 92vw); background:var(--panel2); color:var(--ink);
  border:2px solid var(--violet); padding:16px 20px; z-index:60;
  box-shadow:0 12px 40px rgba(0,0,0,.55);
}
#print-fallback h3 { margin-top:0; }
#print-fallback p { margin:8px 0; }
#toast { position:fixed; left:50%; bottom:26px; transform:translateX(-50%); background:var(--violet-strong); color:#fff; padding:12px 20px; font-weight:600; z-index:50; border:2px solid var(--slate); max-width:90vw; text-align:center; }
.empty { color:var(--muted); padding:18px 0; }

/* ---------- print document ---------- */
#print-area { display:none; }
@media print {
  body { background:#fff !important; }
  #app-view, #toast, #print-fallback { display:none !important; }
  #print-area { display:block !important; color:#111; font-family:"Archivo",sans-serif; font-size:13px; }
  .doc { padding:10px 6px 60px; }
  .doc h1 { font-family:"DM Serif Display",serif; font-size:30px; color:#111; margin:0; }
  .doc h2 { font-family:"DM Serif Display",serif; font-size:19px; color:#111; margin:22px 0 8px; }
  .doc table { border-collapse:collapse; width:100%; margin:8px 0; }
  .doc th, .doc td { border-bottom:1px solid #bbb; padding:7px 6px; text-align:left; vertical-align:top; }
  .doc th { font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:#444; }
  .doc .right { text-align:right; }
  .doc .muted { color:#555; }
  .doc .totals td { border-bottom:none; font-weight:700; }
  .doc .terms { white-space:pre-wrap; font-size:12px; border:1px solid #bbb; padding:12px; margin-top:8px; }
  .doc .prewrap { white-space:pre-wrap; }
  .doc .sig-img { max-height:70px; max-width:320px; }
  .doc .sig-line { margin:30px 0 10px; }
  .doc .pay-box { border:2px solid #111; padding:12px 14px; margin:16px 0; }
  .doc .pay-box h2 { margin-top:0; }
  .doc .pay-url { font-family:monospace; font-size:14px; word-break:break-all; }
  .doc .doc-logo { max-height:64px; max-width:220px; }
  .doc-footer {
    position:fixed; bottom:0; left:0; right:0; text-align:center;
    font-size:11px; color:#555; border-top:1px solid #bbb; padding:8px 0 2px; background:#fff;
  }
  @page { margin:18mm 14mm 20mm; }
}
