/* ═══════════════════════════════════════════════════
   INVOICE STYLES  ·  styles.css
   Apex Creative Studio — Interactive Invoice Form
   Aesthetic: Dark-header editorial with red accent
═══════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────────────── */
:root {
  --bg:        #edeae4;
  --card:      #ffffff;
  --ink:       #0f172a;
  --ink-mid:   #475569;
  --ink-faint: #94a3b8;
  --accent:    #e11d48;
  --accent-bg: #fff1f2;
  --border:    #e2ddd8;
  --border-md: #cbd5e1;
  --surface:   #f8fafc;
  --success:   #16a34a;
  --shadow:    0 8px 40px rgba(15,23,42,.13), 0 2px 8px rgba(15,23,42,.06);
  --r:         4px;
  --rl:        10px;
  --sans:      'DM Sans', 'Helvetica Neue', Arial, sans-serif;
  --serif:     'Playfair Display', Georgia, serif;
}

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

/* ── Base ────────────────────────────────────────── */
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  padding: 48px 16px 96px;
}

/* ── Page wrapper ────────────────────────────────── */
.page {
  max-width: 880px;
  margin: 0 auto;
}

/* ── Card ────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--rl);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ════════════════════════════════════════════════════
   HEADER
════════════════════════════════════════════════════ */
.hdr {
  background: var(--ink);
  padding: 36px 48px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
}

.diamond {
  width: 22px;
  height: 22px;
  background: var(--accent);
  transform: rotate(45deg);
  border-radius: 3px;
  margin-bottom: 14px;
}

.brand-name {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.3px;
  line-height: 1.1;
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #64748b;
  margin-top: 5px;
}

.inv-id-wrap { text-align: right; }

.inv-lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}

.inv-num-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
  justify-content: flex-end;
}

.inv-hash {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}

.inv-num-in {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  color: #f8fafc;
  background: transparent;
  border: none;
  border-bottom: 1.5px dashed #334155;
  outline: none;
  width: 90px;
  text-align: right;
  transition: border-color 0.2s;
}

.inv-num-in:focus { border-bottom-color: var(--accent); }

/* ════════════════════════════════════════════════════
   CONTACT BAR
════════════════════════════════════════════════════ */
.cbar {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  background: #1e293b;
  color: #94a3b8;
  padding: 11px 48px;
  font-size: 12px;
  border-bottom: 1px solid #0a0f1a;
}

.cbar span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cbar svg { opacity: 0.6; flex-shrink: 0; }

/* ════════════════════════════════════════════════════
   PILLS / META BAR
════════════════════════════════════════════════════ */
.pills {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.pill {
  flex: 1;
  padding: 16px 20px 16px 24px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pill:last-child { border-right: none; }

.flbl {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
  display: block;
}

.fin {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-md);
  outline: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  padding: 3px 0;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.2s;
}

.fin:focus { border-bottom-color: var(--accent); }

select.fin {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  padding-right: 18px;
}

/* ════════════════════════════════════════════════════
   BILL TO / PROJECT
════════════════════════════════════════════════════ */
.bill-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}

.bcol { padding: 28px 32px 28px 48px; }

.bcol:last-child {
  border-left: 1px solid var(--border);
  padding-left: 32px;
  padding-right: 48px;
}

.sh {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
  padding-bottom: 5px;
  margin-bottom: 16px;
}

.bin {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink);
  padding: 8px 0;
  margin-bottom: 2px;
  transition: border-color 0.2s;
}

.bin:focus { border-bottom-color: var(--accent); }

.bin::placeholder { color: var(--ink-faint); font-style: italic; }

textarea.bin {
  resize: vertical;
  height: 108px;
  border: 1px dashed var(--border-md);
  border-radius: var(--r);
  background: var(--surface);
  padding: 10px 12px;
  line-height: 1.65;
}

textarea.bin:focus { border-color: var(--accent); border-style: solid; }

/* ════════════════════════════════════════════════════
   LINE ITEMS TABLE
════════════════════════════════════════════════════ */
.twrap {
  padding: 0 48px 28px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 28px;
  table-layout: fixed;
}

thead tr { border-bottom: 2px solid var(--ink); }

th {
  font-size: 9.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 10px 10px;
  color: var(--ink-mid);
  text-align: left;
}

th.r { text-align: right; }

.c-d { width: 44%; }
.c-q { width: 11%; }
.c-r { width: 17%; }
.c-a { width: 18%; }
.c-x { width: 10%; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

tbody tr:nth-child(even) { background: var(--surface); }
tbody tr:hover            { background: var(--accent-bg); }

td { padding: 10px 10px; vertical-align: middle; }

/* Cell inputs */
.tdin {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink);
  padding: 2px 0;
  transition: border-bottom 0.15s;
}

.tdin:focus { border-bottom: 1px solid var(--accent); }

.tdin::placeholder { color: var(--ink-faint); font-style: italic; }

.tdin.r { text-align: right; }

/* Invalid number input highlight */
.tdin.invalid {
  border-bottom: 1px solid var(--accent) !important;
  background: var(--accent-bg);
  border-radius: 2px;
}

/* Row amount display */
.tamt {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Delete button */
.bdel {
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--r);
  display: block;
  margin: 0 auto;
  transition: color 0.15s, background 0.15s;
}

.bdel:hover { color: var(--accent); background: var(--accent-bg); }

/* Table action buttons row */
.tbl-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.badd {
  background: none;
  border: 1px dashed var(--border-md);
  color: var(--ink-mid);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 9px 20px;
  cursor: pointer;
  border-radius: var(--r);
  transition: all 0.18s;
}

.badd:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.bclear {
  background: none;
  border: 1px dashed var(--border-md);
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 9px 20px;
  cursor: pointer;
  border-radius: var(--r);
  transition: all 0.18s;
}

.bclear:hover {
  border-color: #dc2626;
  color: #dc2626;
  background: var(--accent-bg);
}

/* Validation message */
.val-msg {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  min-height: 18px;
  font-weight: 500;
}

/* ════════════════════════════════════════════════════
   TOTALS
════════════════════════════════════════════════════ */
.tout {
  display: flex;
  justify-content: flex-end;
  padding: 28px 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tbox {
  width: 320px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--card);
}

.trow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.trow:last-child { border-bottom: none; }

.trow-grand {
  background: var(--ink);
}

.tlbl {
  font-size: 11px;
  color: var(--ink-mid);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tval {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.trow-grand .tlbl {
  font-family: var(--serif);
  font-size: 13px;
  color: #94a3b8;
  text-transform: none;
  letter-spacing: 0;
}

.trow-grand .tval {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

/* Inline number inputs inside totals */
.taxin {
  width: 48px;
  border: none;
  border-bottom: 1px dashed var(--border-md);
  background: transparent;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink);
  text-align: right;
  outline: none;
  padding: 0 2px;
  transition: border-color 0.2s;
}

.taxin:focus { border-bottom-color: var(--accent); }

/* ════════════════════════════════════════════════════
   NOTES
════════════════════════════════════════════════════ */
.nwrap {
  padding: 28px 48px;
  border-bottom: 1px solid var(--border);
}

.nlbl {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
  margin-bottom: 10px;
}

.nta {
  width: 100%;
  height: 78px;
  border: 1px dashed var(--border-md);
  border-radius: var(--r);
  background: var(--surface);
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-mid);
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  line-height: 1.65;
  transition: border-color 0.2s;
}

.nta:focus { border-color: var(--accent); border-style: solid; }

/* ════════════════════════════════════════════════════
   FOOTER
════════════════════════════════════════════════════ */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 48px;
  background: var(--ink);
  flex-wrap: wrap;
  gap: 14px;
}

.ftxt {
  font-size: 12px;
  color: #64748b;
  font-style: italic;
}

.ftxt strong { color: #94a3b8; font-style: normal; }

.bprint {
  background: var(--accent);
  color: #ffffff;
  border: none;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 11px 24px;
  cursor: pointer;
  border-radius: var(--r);
  transition: opacity 0.18s;
}

.bprint:hover { opacity: 0.85; }

/* ════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════ */
@media (max-width: 680px) {
  body { padding: 12px 8px 60px; }

  .hdr { padding: 24px 20px; flex-direction: column; gap: 20px; }
  .inv-id-wrap { text-align: left; }
  .inv-num-row { justify-content: flex-start; }

  .cbar { padding: 10px 20px; gap: 10px; flex-direction: column; }

  .pills { flex-direction: column; }
  .pill  { border-right: none; border-bottom: 1px solid var(--border); padding: 14px 20px; }
  .pill:last-child { border-bottom: none; }

  .bill-row { grid-template-columns: 1fr; }
  .bcol     { padding: 20px 20px; }
  .bcol:last-child {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 20px;
    padding-right: 20px;
  }

  .twrap { padding: 0 12px 20px; }

  .tout  { padding: 20px 16px; }
  .tbox  { width: 100%; }

  .nwrap { padding: 20px 20px; }

  footer { padding: 16px 20px; }
}

/* ════════════════════════════════════════════════════
   PRINT
════════════════════════════════════════════════════ */
@media print {
  body  { background: #ffffff; padding: 0; }

  .card { box-shadow: none; border-radius: 0; border: none; }

  .badd,
  .bclear,
  .bdel,
  .bprint { display: none !important; }

  .hdr,
  .cbar,
  footer  { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  input,
  textarea,
  select  { color: #000 !important; }
}
