/* ══════ CLIENT VIEW MODE ══════ */
body.client-view .toolbar { display: none !important; }
body.client-view .action-bar { display: none !important; }
body.client-view .del-cell { display: none !important; }
body.client-view .action-head { display: none !important; }
body.client-view .add-item-bar { display: none !important; }
body.client-view .catalog-panel { display: none !important; }
body.client-view input.field,
body.client-view input.brand-name,
body.client-view .amt-cell input.price-field,
body.client-view .fv-cell input.fv-field,
body.client-view .svc-name,
body.client-view .svc-desc,
body.client-view .d-input,
body.client-view select.d-input {
  border-color: transparent !important;
  background: transparent !important;
  pointer-events: none;
  overflow: visible;
  text-overflow: unset;
}
/* Client view: align field labels with section headers */
body.client-view .field-row label { text-align: left; }
/* Client view: keep details away from right edge */
body.client-view .details-block { padding-right: 8px; }
/* Client view: inputs replaced with wrapping text spans */
.cv-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  border: none !important;
  background: transparent !important;
  padding: 4px 0;
}
.cv-text.field {
  flex: 1;
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--charcoal);
}
.cv-text.brand-name {
  display: block;
  font-family: var(--heading-font);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: var(--heading-transform);
}
.cv-text.d-input {
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
  text-align: right;
}

/* ══════ SETTINGS PANEL ══════ */
/* settings-btn replaced by .btn-icon */

.settings-panel {
  width: 100%;
  max-width: 880px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  margin-bottom: 16px;
  overflow: hidden;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--light-bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--body-font);
  font-size: 13px;
  color: var(--primary);
}

.settings-body { padding: 16px 20px; }
.settings-section { }
.settings-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--primary); display: block; margin-bottom: 8px; }

@media print { .settings-panel { display: none !important; } }

/* ══════ CSS VARIABLES (default = FFL) ══════ */
:root {
  --primary: #4A2D6B;
  --secondary: #7ECBC0;
  --accent: #C084D8;
  --charcoal: #3D3D3D;
  --cream: #FDF8FF;
  --light-bg: #f5f0fa;
  --border: #ddd3e6;
  --input-bg: #faf7fd;
  --heading-font: 'Playfair Display', serif;
  --body-font: 'Quicksand', sans-serif;
  --cursive-font: 'Sacramento', cursive;
  --thanks-color: #7ECBC0;
  --btn-radius: 4px;
  --heading-transform: none;
  --heading-spacing: normal;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--body-font);
  color: var(--charcoal);
  background: #eee9f2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 40px;
}

/* ══════ TOOLBAR (replaces brand-switcher) ══════ */
.toolbar {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 880px;
  overflow: hidden;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
}

.toolbar-row-actions {
  border-bottom: 1px solid #eee;
}

.toolbar-row-config {
  gap: 16px;
}

.toolbar-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.toolbar-lookup {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar label {
  font-family: 'Quicksand', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
  white-space: nowrap;
}

.toolbar select {
  font-family: 'Quicksand', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border: 2px solid var(--primary);
  border-radius: 6px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  outline: none;
  flex: 1;
  min-width: 0;
}

.lookup-field {
  font-family: var(--body-font);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input-bg);
  outline: none;
  width: 60px;
  transition: border-color 0.2s;
}

.lookup-field:focus {
  border-color: var(--accent);
  background: #fff;
}

.toolbar-btn {
  font-family: var(--body-font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border: 2px solid var(--primary);
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.toolbar-btn:hover {
  background: transparent;
  color: var(--primary);
}

.btn-icon {
  font-size: 18px;
  padding: 4px 8px;
  background: transparent;
  color: var(--primary);
  border-color: transparent;
  margin-left: auto;
}
.btn-icon:hover {
  background: var(--light-bg);
  border-color: var(--border);
}

/* Status badge */
.status-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--light-bg);
  color: var(--primary);
  border: 1px solid var(--border);
}

.status-badge.sent { background: #e8f4fd; color: #1a73e8; border-color: #a8d4f0; }
.status-badge.paid { background: #e6f9e6; color: #1a8c1a; border-color: #a8e6a8; }
.status-badge.partial { background: #fff8e1; color: #f57f17; border-color: #ffcc02; }
.status-badge.overdue { background: #fde8e8; color: #d93025; border-color: #f0a8a8; }

/* ══════ GLOBAL INPUTS ══════ */
input.field {
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--charcoal);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 7px 10px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(192,132,216,0.15);
  background: #fff;
}

input.field::placeholder { color: #bfaed0; font-weight: 400; }

/* ══════ AUTOCOMPLETE DROPDOWN ══════ */
.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-dropdown.visible { display: block; }

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--light-bg); }
.autocomplete-item .ac-name { font-weight: 600; color: var(--primary); }
.autocomplete-item .ac-detail { font-size: 11px; color: #999; margin-top: 2px; }

/* ══════ INVOICE WRAPPER ══════ */
.invoice {
  background: #fff;
  width: 100%;
  max-width: 880px;
  box-shadow: 0 8px 40px rgba(74,45,107,0.1);
}

/* ══════ HEADER ══════ */
.header {
  background: var(--primary);
  padding: 32px 40px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left input.brand-name {
  font-family: var(--heading-font);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: transparent;
  border: 1px dashed rgba(255,255,255,0.25);
  border-radius: 3px;
  padding: 6px 12px;
  width: 340px;
  outline: none;
  letter-spacing: 0.5px;
  text-transform: var(--heading-transform);
}

.header-left input.brand-name::placeholder { color: rgba(255,255,255,0.45); }
.header-left input.brand-name:focus { border-color: var(--secondary); background: rgba(255,255,255,0.06); }

.header-right h1 {
  font-family: var(--heading-font);
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: right;
}

.header-right .inv-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  margin-top: 6px;
  letter-spacing: 1px;
  text-align: right;
}

.grad-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--accent) 50%, var(--primary) 100%);
}

.body { padding: 28px 40px 32px; overflow: hidden; }

/* ══════ TOP GRID ══════ */
.top-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 28px;
  margin-bottom: 28px;
}

.contact-block h3, .details-block h3 {
  font-family: var(--heading-font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--primary);
  margin-bottom: 14px;
  position: relative;
  display: inline-block;
}

.contact-block h3::after, .details-block h3::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 2px;
  background: var(--secondary);
  border-radius: 1px;
}

.field-group { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.field-row { display: flex; align-items: center; gap: 8px; min-height: 25px; }
.field-row label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--accent); width: 56px;
  flex-shrink: 0; text-align: right;
}
.field-row input.field { flex: 1; }

.details-list { margin-top: 16px; display: flex; flex-direction: column; gap: 2px; }
body.client-view .details-list { gap: 6px; }

.d-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; min-height: 25px; border-bottom: 1px solid #f0ebf5;
}
.d-row .d-label { flex-shrink: 0; }
.d-row .d-value, .d-row .d-input, .d-row .cv-text.d-input { margin-left: auto; }
.d-row:last-child { border-bottom: none; }
body.client-view .d-row { border-bottom: none; padding: 0; height: 25px; }

.d-label { font-weight: 700; color: var(--primary); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.d-value { font-weight: 600; }
.d-value.hl { color: var(--primary); font-weight: 700; }

.d-input {
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 5px 8px;
  outline: none;
  text-align: right;
  max-width: 130px;
  transition: border-color 0.2s;
}

.d-input:focus {
  border-color: var(--accent);
  background: #fff;
}

select.d-input {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 12px;
}

/* ══════ TABLE ══════ */
table.items {
  width: 100%; border-collapse: separate;
  border-spacing: 0; margin-bottom: 16px;
}

table.items thead th {
  font-family: var(--body-font);
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: #fff; background: var(--primary);
  padding: 10px 14px; text-align: left;
}

table.items thead th:first-child { border-radius: 4px 0 0 0; }
table.items thead th:last-child  { border-radius: 0 4px 0 0; }
table.items thead th.amt-head { text-align: right; }
table.items thead th.action-head { width: 40px; }

table.items tbody td {
  padding: 10px 14px; font-size: 13px;
  border-bottom: 1px solid #ede8f3; vertical-align: top;
}

table.items tbody tr:nth-child(even) td { background: var(--light-bg); }
table.items tbody tr:last-child td { border-bottom: 2px solid var(--primary); }

.num-cell { width: 36px; text-align: center; font-weight: 700; color: var(--primary); }
.svc-name {
  font-weight: 700; color: var(--primary); font-size: 13.5px; margin-bottom: 4px;
  border: none; background: transparent; font-family: var(--body-font);
  width: 100%; outline: none; padding: 0;
}
.svc-name:focus { background: var(--input-bg); border-radius: 3px; padding: 2px 4px; }

.svc-desc {
  font-size: 12px; color: #888; line-height: 1.55;
  border: none; background: transparent; font-family: var(--body-font);
  width: 100%; outline: none; padding: 0; resize: none;
}
.svc-desc:focus { background: var(--input-bg); border-radius: 3px; padding: 2px 4px; }

.amt-cell { width: 120px; text-align: right; vertical-align: middle !important; }

.amt-cell input.price-field {
  font-family: var(--body-font);
  font-size: 14px; font-weight: 700; color: var(--primary);
  text-align: right; width: 100%; background: transparent;
  border: 1px solid transparent; border-radius: 3px;
  padding: 6px 8px; outline: none; transition: all 0.2s;
}

.amt-cell input.price-field:hover { background: var(--input-bg); border-color: var(--border); }
.amt-cell input.price-field:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(192,132,216,0.15); }

/* Full Value column */
.fv-cell {
  width: 120px; text-align: right; vertical-align: middle !important;
}

.fv-cell input.fv-field {
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 600;
  color: #999;
  text-decoration: line-through;
  font-style: italic;
  text-align: right;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 6px 8px;
  outline: none;
  transition: all 0.2s;
}

.fv-cell input.fv-field:hover {
  background: var(--input-bg);
  border-color: var(--border);
  text-decoration: none;
  color: var(--charcoal);
  font-style: normal;
}

.fv-cell input.fv-field:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(192,132,216,0.15);
  text-decoration: none;
  color: var(--charcoal);
  font-style: normal;
}

/* Delete button cell */
.del-cell {
  width: 36px;
  text-align: center;
  vertical-align: middle !important;
}

.del-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
}

.del-btn:hover {
  color: #d93025;
  background: #fde8e8;
}

/* ══════ ADD LINE ITEM BAR ══════ */
.add-item-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}

.add-btn {
  font-family: var(--body-font);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--btn-radius);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
}

.add-btn:hover {
  border-color: var(--primary);
  background: var(--light-bg);
}

.add-btn-custom {
  border-style: dashed;
  color: #888;
}

/* ══════ CATALOG PANEL ══════ */
.catalog-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  margin-bottom: 24px;
  overflow: hidden;
}

.catalog-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--light-bg);
}

.catalog-search {
  flex: 1;
  font-family: var(--body-font);
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  background: #fff;
}

.catalog-search:focus { border-color: var(--accent); }

.catalog-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.catalog-close:hover { color: var(--primary); }

.catalog-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 0;
}

.catalog-category {
  padding: 6px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  background: #faf7fd;
}

.catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #f5f0fa;
}

.catalog-item:hover { background: var(--light-bg); }

.catalog-item-info { flex: 1; }
.catalog-item-name { font-size: 13px; font-weight: 600; color: var(--charcoal); }
.catalog-item-desc { font-size: 11px; color: #999; margin-top: 2px; }
.catalog-item-price { font-size: 13px; font-weight: 700; color: var(--primary); margin-left: 12px; white-space: nowrap; }

/* ══════ TOTALS ══════ */
.totals-wrap { display: flex; justify-content: flex-end; margin-bottom: 28px; }
.totals-note-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: start;
  margin-bottom: 28px;
}
.totals-note-grid .pwyc-note { margin-bottom: 0; align-self: start; }
.totals-right { display: flex; flex-direction: column; width: 320px; flex-shrink: 0; }
.totals { width: 100%; }

.t-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; font-size: 13.5px;
  font-family: var(--body-font);
}

.t-row.full-value { font-weight: 600; color: #bbb; font-size: 12px; font-style: italic; }
.t-row.contributed { font-weight: 600; color: var(--secondary); font-size: 12.5px; }
.t-row.sub { border-top: 2px solid var(--border); font-weight: 700; }

.t-row.total {
  background: var(--primary); color: #fff;
  font-family: var(--body-font);
  font-size: 18px; font-weight: 700;
  border-radius: 4px; margin-top: 8px; padding: 14px 16px;
}

/* ══════ CLIENT OPTIONS (under Total Due) ══════ */
.client-options { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.client-option-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--body-font);
  font-size: 13px; font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  padding: 12px 16px;
  min-height: 44px;
  background: linear-gradient(135deg, #f8f5fc, #f0ebf5);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.client-option-toggle:hover { background: #ede5f5; border-color: var(--secondary); }
.client-option-toggle:active { transform: scale(0.98); }
.client-option-icon { font-size: 16px; }

/* ══════ PWYC CLIENT ACCORDION ══════ */
.pwyc-client-section {
  margin-bottom: 0;
}
.pwyc-client-toggle {
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
  padding: 10px 0;
  text-align: center;
  transition: color 0.2s;
}
.pwyc-client-toggle:hover { color: var(--primary); }
.pwyc-toggle-arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 11px;
}
.pwyc-toggle-arrow.open { transform: rotate(180deg); }
.pwyc-client-body {
  margin-top: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--light-bg);
  text-align: center;
}
.pwyc-client-desc {
  font-family: var(--body-font);
  font-size: 12.5px;
  color: #777;
  margin-bottom: 14px;
  line-height: 1.5;
}
.pwyc-amount-wrap {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  transition: border-color 0.2s;
}
.pwyc-amount-wrap:focus-within {
  border-color: var(--secondary);
}
.pwyc-dollar {
  font-family: var(--body-font);
  font-size: 22px;
  font-weight: 700;
  color: #bbb;
}
.pwyc-amount {
  font-family: var(--body-font);
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  border: none;
  outline: none;
  background: transparent;
  width: 120px;
  padding: 6px 4px;
}
.pwyc-error {
  font-family: var(--body-font);
  font-size: 12px;
  color: #d93025;
  margin-top: 10px;
  padding: 8px 12px;
  background: #fde8e8;
  border-radius: 4px;
  border: 1px solid #f0a8a8;
}

/* ══════ TOGGLE SWITCH ══════ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 20px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--secondary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Hide admin controls in client view */
body.client-view .pwyc-admin { display: none !important; }
body.client-view .plan-admin { display: none !important; }
body.client-view .plan-admin-options { display: none !important; }
body.client-view .plan-admin-section { display: none !important; }

/* ══════ PAYMENT PLAN — ADMIN ══════ */
.plan-admin-section {
  background: var(--light-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.plan-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.plan-admin-header h3 {
  font-family: var(--heading-font);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--primary);
  margin: 0;
}
.plan-admin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.plan-admin-controls label {
  font-family: var(--body-font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
}
.plan-admin-controls select {
  font-family: var(--body-font);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--charcoal);
  cursor: pointer;
  outline: none;
}

.plan-admin-table-head {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 40px;
  gap: 8px;
  padding: 6px 10px;
  font-family: var(--body-font);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #aaa;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.plan-col-amount { text-align: right; }
.plan-col-paid { text-align: center; }

.installments-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.installment-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 4px;
  font-family: var(--body-font);
  font-size: 13px;
  border-left: 3px solid var(--secondary);
  transition: all 0.2s;
}
.installment-row .inst-num {
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}
.installment-row input {
  font-family: var(--body-font);
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  outline: none;
  background: #fff;
  width: 100%;
}
.installment-row input:focus {
  border-color: var(--accent);
}
.installment-row input.inst-amount {
  text-align: right;
  font-weight: 700;
  color: var(--primary);
}
.installment-row .inst-paid {
  justify-self: center;
}
.installment-row .inst-paid input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--secondary);
}
.installment-row.is-paid {
  opacity: 0.7;
  border-left-color: #1a8c1a;
  background: var(--light-bg);
}
.installment-row.is-paid input.inst-amount {
  text-decoration: line-through;
  color: #aaa;
}
.inst-paid-date {
  width: 115px;
  font-size: 11px;
  padding: 4px 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
}
.inst-paid-via {
  width: 90px;
  font-size: 11px;
  padding: 4px 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
}
.installment-row.has-delete {
  grid-template-columns: 32px 1fr 1fr 40px 28px;
}
.plan-admin-table-head.has-delete {
  grid-template-columns: 32px 1fr 1fr 40px 28px;
}

/* ══════ PAYMENT PLAN — CLIENT ══════ */
.plan-client-section {
  margin-bottom: 24px;
}
.plan-client-toggle {
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
  padding: 10px 0;
  text-align: center;
  transition: color 0.2s;
}
.plan-client-toggle:hover { color: var(--primary); }
.plan-toggle-arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 11px;
}
.plan-toggle-arrow.open { transform: rotate(180deg); }
.plan-client-body {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  background: var(--light-bg);
}
.plan-pay-note {
  font-family: var(--body-font);
  font-size: 12px;
  color: #777;
  text-align: center;
  margin-top: 12px;
  font-style: italic;
}
.plan-schedule-progress {
  font-family: var(--body-font);
  font-size: 12px;
  color: #777;
  margin-bottom: 12px;
}
.plan-schedule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-installment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: var(--body-font);
}
.plan-installment.is-current {
  border-color: var(--secondary);
  border-width: 2px;
  background: linear-gradient(135deg, #f0faf8, #e8f5f1);
}
.plan-installment.is-paid {
  opacity: 0.6;
  background: #f5f5f5;
}
.plan-inst-status {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.plan-inst-status.paid {
  background: #e6f9e6;
  color: #1a8c1a;
}
.plan-inst-status.unpaid {
  background: var(--light-bg);
  color: #bbb;
  border: 2px solid var(--border);
}
.plan-inst-status.current {
  background: var(--secondary);
  color: #fff;
}
.plan-inst-details {
  flex: 1;
}
.plan-inst-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--charcoal);
}
.plan-inst-date {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}
.plan-inst-paid-info {
  font-size: 11px;
  color: #1a8c1a;
  margin-top: 2px;
}
.plan-inst-amount {
  font-family: var(--body-font);
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}
.plan-installment.is-paid .plan-inst-amount {
  text-decoration: line-through;
  color: #aaa;
}

/* ══════ PWYC NOTE ══════ */
.pwyc-note {
  background: linear-gradient(135deg, #f8f5fc, #f0ebf5);
  border: 1px solid var(--border);
  border-left: 3px solid var(--secondary);
  border-radius: 4px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 12px;
  line-height: 1.65;
  color: #777;
}

.pwyc-note strong { color: var(--primary); font-weight: 700; }

.section-divider {
  border: none; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 0 0 24px;
}

/* ══════ PAYMENT SECTION (inside .body) ══════ */
.payment-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.payment-terms-block h4,
.payment-methods-block h4 {
  font-family: var(--heading-font);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 2px; color: var(--primary);
  margin-bottom: 12px; position: relative; display: inline-block;
}

.payment-terms-block h4::after,
.payment-methods-block h4::after {
  content: ''; position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 2px; background: var(--secondary); border-radius: 1px;
}

.payment-terms-block p { font-size: 12.5px; line-height: 1.75; color: #777; margin-top: 8px; }

/* ══════ INVOICE FOOTER ══════ */
.invoice-footer {
  padding: 28px 40px 32px;
  text-align: center;
}

.thanks { padding-bottom: 16px; }
.thanks span {
  font-family: var(--cursive-font);
  font-size: 30px;
  color: var(--thanks-color);
}

.footer-info {
  font-family: var(--body-font);
  font-size: 12px;
  color: #999;
  margin-bottom: 12px;
}

.footer-divider {
  margin: 0 8px;
  color: #ccc;
}

.footer-powered {
  font-family: var(--body-font);
  font-size: 10px;
  color: #bbb;
  letter-spacing: 0.5px;
}
.footer-powered strong {
  color: #999;
}

/* ══════ PAYMENT BUTTONS ══════ */
.pay-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.pay-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--btn-radius);
  background: #fff;
  text-decoration: none;
  color: var(--charcoal);
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
}

.pay-btn:hover {
  border-color: var(--primary);
  background: var(--light-bg);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.pay-btn .pay-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.pay-btn.venmo .pay-icon { background: #008CFF; }
.pay-btn.paypal .pay-icon { background: #003087; }
.pay-btn.cashapp .pay-icon { background: #00D632; }

.pay-btn .pay-label { flex: 1; }
.pay-btn .pay-amount {
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
}

.bottom-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 50%, var(--secondary) 100%);
}

/* ══════ ACTION BAR ══════ */
.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  width: 100%;
  max-width: 880px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 700;
  padding: 12px 24px;
  border: 2px solid var(--primary);
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.action-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

.save-btn { background: var(--primary); color: #fff; }
.save-btn:hover { background: transparent; color: var(--primary); }

.send-btn { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.send-btn:hover { background: transparent; color: var(--secondary); }

.link-btn { background: transparent; color: var(--accent); border-color: var(--accent); }
.link-btn:hover { background: var(--accent); color: #fff; }

.print-btn { background: transparent; color: var(--primary); }
.print-btn:hover { background: var(--primary); color: #fff; }

.paid-btn { background: transparent; color: #1a8c1a; border-color: #1a8c1a; }
.paid-btn:hover { background: #1a8c1a; color: #fff; }

/* ══════ TOAST ══════ */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-family: var(--body-font);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: bottom 0.3s ease;
  z-index: 1000;
}

.toast.visible { bottom: 24px; }
.toast.error { background: #d93025; }
.toast.success { background: #1a8c1a; }

/* ══════ MOBILE RESPONSIVE ══════ */
@media (max-width: 768px) {
  body { padding: 12px 6px 32px; }

  .toolbar { border-radius: 6px; }

  .toolbar-row { flex-wrap: wrap; padding: 8px 10px; }

  .toolbar-row-config { flex-direction: column; gap: 6px; }
  .toolbar-field { width: 100%; }

  .toolbar select { font-size: 14px; padding: 8px 12px; }

  .lookup-field { width: 50px; }

  .header {
    flex-direction: column;
    gap: 16px;
    padding: 28px 24px 24px;
    text-align: center;
  }

  .header-left input.brand-name {
    width: 100%;
    text-align: center;
    font-size: 19px;
    padding: 8px 10px;
  }

  .header-right h1 { text-align: center; font-size: 28px; letter-spacing: 2px; }
  .header-right .inv-num { text-align: center; }

  .body { padding: 24px 18px 28px; }

  .top-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 28px;
  }

  .field-row {
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
  }

  .field-row label {
    width: auto;
    text-align: left;
    font-size: 9px;
  }

  input.field {
    font-size: 15px;
    padding: 10px 12px;
    min-height: 44px;
  }

  /* Table → Compact rows on mobile */
  table.items { margin-bottom: 12px; }
  table.items thead { display: none; }
  table.items tbody { display: block; }
  table.items tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
  }

  table.items tbody tr:nth-child(even) td { background: transparent !important; }
  table.items tbody tr:last-child { border-bottom: 2px solid var(--primary); }

  table.items tbody td {
    padding: 0;
    border: none !important;
    background: transparent !important;
  }

  td.num-cell {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    width: auto;
    min-width: auto;
  }

  /* Service name inline with number, amount on right */
  td:nth-child(2) {
    flex: 1;
    min-width: 0;
  }

  .svc-name {
    font-size: 14px;
    margin-bottom: 2px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    height: auto;
  }
  .svc-desc {
    font-size: 11px;
    margin-bottom: 0;
    line-height: 1.4;
    white-space: normal;
    overflow: visible;
    height: auto;
  }

  /* Hide full value on mobile client view to save space */
  body.client-view .fv-cell { display: none !important; }

  .fv-cell {
    display: none !important;
  }

  .amt-cell {
    width: auto !important;
    text-align: right;
  }

  .amt-cell::before { display: none; }

  .amt-cell input.price-field {
    font-size: 15px;
    padding: 4px 0;
    text-align: right;
    background: transparent;
    border: none;
    width: auto;
    min-width: 80px;
  }

  .del-cell {
    position: absolute;
    top: 8px;
    right: 4px;
    width: auto;
  }

  .totals-wrap { justify-content: stretch; }
  .totals-note-grid { grid-template-columns: 1fr; }
  .totals-right { width: 100%; }
  .totals { width: 100%; }

  .t-row { padding: 10px 12px; font-size: 15px; }
  .t-row.total { font-size: 18px; padding: 14px 12px; }
  .t-row.full-value { font-size: 13px; }
  .t-row.contributed { font-size: 13px; }
  .t-row.sub { font-size: 15px; }

  .pwyc-note { padding: 12px 14px; font-size: 13px; }

  .client-options { gap: 10px; margin-top: 14px; }
  .client-option-toggle {
    min-height: 48px;
    font-size: 15px;
    padding: 14px 18px;
    border-radius: 10px;
  }
  .client-option-icon { font-size: 18px; }

  .thanks span { font-size: 26px; }

  /* General mobile font bump */
  .cv-text.field { font-size: 14px; }
  .cv-text.d-input { font-size: 14px; }

  .payment-section {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .payment-terms-block p { font-size: 13px; line-height: 1.6; }

  .invoice-footer { padding: 20px 18px 24px; }

  .pwyc-client-toggle { font-size: 14px; }
  .plan-client-toggle { font-size: 14px; }
  .pwyc-client-desc { font-size: 13px; }

  .d-input, select.d-input {
    font-size: 14px;
    max-width: 100%;
    min-height: 40px;
    padding: 8px 10px;
  }

  .pay-btn {
    padding: 14px 16px;
    font-size: 14px;
    min-height: 52px;
  }

  .pay-btn .pay-icon { width: 32px; height: 32px; font-size: 15px; }
  .pay-btn .pay-amount { font-size: 15px; }

  .add-item-bar { flex-direction: column; }
  .add-btn { padding: 12px; font-size: 14px; min-height: 44px; text-align: center; }

  .action-bar { flex-direction: column; }
  .action-btn { width: 100%; text-align: center; padding: 14px; }

  /* Payment plan admin */
  .plan-admin-section { padding: 12px 14px; }
  .plan-admin-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .plan-admin-controls { flex-wrap: wrap; gap: 6px; }
  .plan-admin-table-head { display: none; }
  .installment-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
    padding: 12px;
    border-left-width: 3px;
  }
  .installment-row .inst-num {
    text-align: left;
    font-size: 12px;
  }
  .installment-row .inst-num::before { content: 'Payment '; }
  .installment-row input.inst-amount { text-align: left; font-size: 15px; min-height: 40px; }
  .installment-row input.inst-date { font-size: 14px; min-height: 40px; }
  .installment-row .inst-paid {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .installment-row .inst-paid::after { content: 'Paid'; font-size: 12px; color: #999; }
  .inst-paid-date { width: 100%; min-height: 40px; font-size: 14px; }
  .inst-paid-via { width: 100%; min-height: 40px; font-size: 14px; }

  /* Payment plan client */
  .plan-installment { padding: 10px 12px; gap: 10px; }
  .plan-inst-amount { font-size: 14px; }
  .plan-inst-label { font-size: 12px; }

  /* PWYC */
  .pwyc-client-body { padding: 14px 12px; }
  .pwyc-amount { font-size: 18px; width: 100px; }
  .pwyc-dollar { font-size: 18px; }
}

/* Extra small (phones < 400px) */
@media (max-width: 400px) {
  .header { padding: 24px 16px 20px; }
  .header-left input.brand-name { font-size: 17px; }
  .header-right h1 { font-size: 24px; }

  .body { padding: 20px 14px 24px; }

  .field-row label { font-size: 8.5px; }

  .invoice-footer { padding: 16px 14px 20px; }

  .t-row.total { font-size: 16px; }

  .plan-installment { flex-wrap: wrap; }
  .plan-inst-amount { width: 100%; text-align: left; margin-top: 4px; }
}

/* ══════ PRINT ══════ */
@media print {
  body { background: #fff; padding: 0; }
  .invoice { box-shadow: none; }
  .toolbar { display: none !important; }
  .action-bar { display: none !important; }
  .toast { display: none !important; }
  .del-cell { display: none !important; }
  .add-item-bar { display: none !important; }
  .catalog-panel { display: none !important; }
  .action-head { display: none !important; }

  input.field, input.brand-name,
  .amt-cell input.price-field,
  .fv-cell input.fv-field,
  .d-input, select.d-input,
  .svc-name, .svc-desc {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding-left: 0;
  }

  .field-row label { color: #999; }

  /* Compress for single-page print */
  .header { padding: 28px 40px 22px; }
  .header-left input.brand-name { font-size: 18px; }
  .header-right h1 { font-size: 28px; }
  .body { padding: 24px 40px 20px; }
  .top-grid { gap: 24px; margin-bottom: 24px; }
  .field-group { gap: 3px; margin-top: 10px; }
  input.field { font-size: 11px; padding: 3px 0; }
  .field-row label { font-size: 9px; }
  table.items { margin-bottom: 16px; }
  table.items thead th { padding: 8px 12px; }
  table.items tbody td { padding: 10px 12px; font-size: 12px; }
  .svc-name { font-size: 12px; margin-bottom: 2px; }
  .svc-desc { font-size: 10.5px; }
  .amt-cell input.price-field { font-size: 12px; padding: 3px 6px; }
  .fv-cell input.fv-field { font-size: 11px; padding: 3px 6px; }
  .totals-wrap { margin-bottom: 16px; }
  .t-row { padding: 5px 10px; font-size: 12px; }
  .t-row.total { font-size: 15px; padding: 10px 12px; }
  .thanks span { font-size: 22px; }
  .section-divider { margin: 0 0 16px; }
  .thanks { padding-bottom: 16px; }
  .payment-section { gap: 16px; }
  .payment-terms-block p { font-size: 11px; }
  .invoice-footer { padding: 16px 40px 20px; }
  .footer-powered { display: none; }
  .pay-btn { padding: 8px 12px; font-size: 11px; min-height: auto; }
  .pay-btn .pay-icon { width: 22px; height: 22px; font-size: 11px; }

  /* Hide PWYC elements on print */
  .fv-head, .fv-cell { display: none !important; }
  .t-row.contributed { display: none !important; }
  .t-row.full-value { display: none !important; }
  .pwyc-note { display: none !important; }

  /* Payment buttons print as text */
  .pay-btn { border: 1px solid #ccc; box-shadow: none; }
  .pay-btn:hover { transform: none; }
}
