/* ── View-specific styles ──────────────────────────────────────────────────── */



/* ── Send document ───────────────────────────────────────────────────────── */

.send-doc {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5);
  max-width: 560px;
}

.send-doc__block {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.send-doc__block-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.send-doc__client-name {
  font-size: var(--text-base);
  font-weight: 600;
}

.send-doc__client-email {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
}

.send-doc__warning {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: var(--r-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.send-doc__warning-text {
  font-size: var(--text-sm);
  color: #92400e;
}

.send-doc__warning-btn {
  align-self: flex-start;
}

.send-doc__textarea {
  min-height: 96px;
  resize: vertical;
}

.send-doc__error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--r-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--c-danger);
}

.send-doc__send-btn {
  align-self: flex-start;
}

.send-doc__optional {
  font-weight: 400;
  color: var(--c-text-muted);
}

/* ── Auth ────────────────────────────────────────────────────────────────── */

#view-auth {
  justify-content: center;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-logo__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--c-primary);
}

.auth-logo__sub {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
}

.auth-link {
  display: block;
  margin-top: var(--space-2);
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--c-primary);
  cursor: pointer;
  text-align: left;
}
.auth-link:hover { text-decoration: underline; }

.auth-learn-more {
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}
.auth-learn-more a {
  color: inherit;
  text-decoration: none;
}
.auth-learn-more a:hover { text-decoration: underline; }

.auth-section-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-text);
  margin: 0 0 var(--space-4);
}

.auth-section-sub {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin: calc(-1 * var(--space-2)) 0 var(--space-4);
}

/* ── Jobs list / Dashboard ───────────────────────────────────────────────── */

.month-revenue {
  background: var(--c-primary);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}

.month-revenue__label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: var(--space-1);
}

.month-revenue__amount {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: white;
}

.jobs-search-wrap {
  margin-bottom: var(--space-5);
}


/* Extra bottom padding so content doesn't hide behind the FAB */
#view-jobs {
  padding-bottom: calc(88px + var(--safe-bottom));
}

/* Floating action button — lives outside #app so fixed pos is always viewport-relative */
.fab {
  position: fixed;
  bottom: calc(32px + var(--safe-bottom));
  right: 24px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 14px 22px;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: 99px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  z-index: 50;
  transition: background .15s, transform .1s;
}

.fab:hover  { background: var(--c-primary-dk); }
.fab:active { background: var(--c-primary-dk); transform: scale(0.96); }

.fab__icon {
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 300;
}

.jobs-search {
  background: var(--c-surface);
}

/* Section blocks */
.jobs-section {
  margin-bottom: var(--space-6);
}

.jobs-section__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.jobs-section__header--btn {
  width: 100%;
  justify-content: flex-start;
  min-height: unset;
  height: auto;
  padding: var(--space-1) 0;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0;
}

.jobs-section__title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-text-muted);
}

.jobs-section__count {
  background: var(--c-border);
  color: var(--c-text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 7px;
  line-height: 1.6;
}

.jobs-section__chevron {
  margin-left: auto;
  color: var(--c-text-muted);
  font-size: var(--text-lg);
  line-height: 1;
  transition: transform .2s;
}

.jobs-section__header--btn[aria-expanded="true"] .jobs-section__chevron {
  transform: rotate(90deg);
}

/* Job rows */
.job-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .12s;
  box-shadow: var(--shadow-sm);
}

.job-row + .job-row { margin-top: var(--space-2); }

.job-row:active { background: var(--c-bg); }

/* Avatar */
.job-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
}

/* Row content */
.job-row__body {
  flex: 1;
  min-width: 0;
}

.job-row__name {
  font-weight: 600;
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-row__meta {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Right side */
.job-row__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
}

.job-row__doc-count {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}

/* ── Old job-card styles (kept for any other references) ─────────────────── */

.job-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.job-card__name {
  font-weight: 600;
  font-size: var(--text-base);
}

.job-card__meta {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-top: 2px;
}

.job-card__doc-count {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Job form ────────────────────────────────────────────────────────────── */

/* Form sections (Client / Job) */
.form-section {
  margin-bottom: var(--space-6);
}

.form-section__label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-text-muted);
  margin-bottom: var(--space-3);
}

/* Stacked primary + secondary action buttons */
.form-actions-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* Selected client chip */
.client-selected {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: #EBF1F8;
  border: 1.5px solid var(--c-primary);
  border-radius: var(--r-sm);
}

.client-selected__info {
  flex: 1;
  min-width: 0;
}

.client-selected__name {
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-selected__sub {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-selected__change {
  font-size: var(--text-sm);
  color: var(--c-primary);
  text-decoration: underline;
  height: auto;
  min-height: unset;
  min-width: unset;
  padding: 0;
  flex-shrink: 0;
}

/* Override info toggle link */
.client-override-toggle {
  display: block;
  margin-top: var(--space-2);
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
}
.client-override-toggle:hover { color: var(--c-text); }

/* "Add new client" option in dropdown */
.client-dropdown__item--add {
  font-weight: 600;
  color: var(--c-primary);
}

.client-field-wrap {
  position: relative;
}

#job-address-fields {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
}

/* ── Job detail ──────────────────────────────────────────────────────────── */

.job-detail__header {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.job-detail__client {
  font-size: var(--text-lg);
  font-weight: 700;
}

.job-detail__address {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-top: 2px;
}

.job-detail__desc {
  font-size: var(--text-sm);
  margin-top: var(--space-3);
  color: var(--c-text);
  white-space: pre-wrap;
}

.doc-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  min-height: var(--tap);
  transition: background .12s;
}
.doc-list-item:active { background: var(--c-bg); }

.doc-list-item__number {
  font-weight: 700;
  font-size: var(--text-sm);
  min-width: 56px;
}

.doc-list-item__label {
  flex: 1;
  font-size: var(--text-sm);
}

/* ── Document editor ─────────────────────────────────────────────────────── */

/* Document header */
.doc-header {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.doc-header__from-to {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--c-border);
}

@media (max-width: 480px) {
  .doc-header__from-to {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

.doc-header__block-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  margin-bottom: var(--space-2);
}

.doc-header__company-name {
  font-weight: 700;
  font-size: var(--text-base);
  margin-bottom: 2px;
}

.doc-header__client-name {
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: 2px;
}

.doc-header__block-line {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  line-height: 1.5;
}

.doc-header__dates {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.doc-header__date-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.doc-header__date-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  width: 72px;
  flex-shrink: 0;
}

.doc-header__date-val {
  font-size: var(--text-sm);
  color: var(--c-text);
}

.doc-header__date-input {
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 4px var(--space-2);
  background: var(--c-surface);
  height: 32px;
  min-height: unset;
  transition: border-color .15s;
}

.doc-header__date-input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(27,58,92,.12);
}

/* Actions row */
.doc-actions__row {
  display: flex;
  gap: var(--space-3);
}

.doc-actions__row .btn {
  flex: 1;
}

.doc-actions__send {
  background: var(--c-primary);
  color: #fff;
}
.doc-actions__send:active { background: var(--c-primary-dk); }

/* Save as invoice — green */
.btn--success {
  background: var(--c-success);
  color: #fff;
}
.btn--success:active { opacity: .85; }

.doc-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

@media (max-width: 440px) {
  .doc-meta-grid { grid-template-columns: 1fr; }
}

/* Line items table */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

.line-items-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text-muted);
  padding: var(--space-2) var(--space-2);
  border-bottom: 2px solid var(--c-border);
}

.line-items-table td {
  padding: var(--space-1) var(--space-2);
  vertical-align: middle;
}

.line-items-table tr:not(:last-child) td {
  border-bottom: 1px solid var(--c-border);
}

/* Column widths */
.col-type  { width: 16%; }
.col-desc  { width: 30%; }
.col-qty   { width: 10%; }
.col-price { width: 18%; }
.col-total { width: 14%; text-align: right; }
.col-del   { width: 5%;  text-align: center; }

/* .line-items-table th { text-align: left } (specificity 0,1,1) overrides
   .col-total { text-align: right } (specificity 0,1,0) for th elements.
   These rules (0,2,1) restore alignment to match the right-aligned data cells. */
.line-items-table th.col-qty,
.line-items-table th.col-price,
.line-items-table th.col-total { text-align: right; }

/* Qty and Unit Price data cells contain an <input> with its own padding (space-2
   right), stacked on top of the td's padding (space-2 right). The header sees only
   the th's padding (space-2 right). Compensate so headers align with input text. */
.line-items-table th.col-qty,
.line-items-table th.col-price { padding-right: calc(var(--space-2) * 2); }

/* ── Mobile card layout for line items (below 600px) ────────────────────── */
@media (max-width: 599px) {
  /* Hide table header */
  .line-items-table thead { display: none; }

  /* Flatten the table structure */
  .line-items-table,
  .line-items-table tbody { display: block; width: 100%; }

  /* Each row becomes a flex card */
  .line-item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-2) var(--space-3);
    padding: var(--space-3);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    margin-bottom: var(--space-2);
    box-shadow: var(--shadow-sm);
  }

  /* Reset all td to block with no table-cell spacing */
  .line-item-row td {
    display: block;
    padding: 0;
    width: auto !important;
    border-bottom: none !important;
  }

  /* ── Line 1: Type (grows) + Delete (end) ── */
  .line-item-row .col-type { order: 1; flex: 1 1 auto;  min-width: 0; }
  .line-item-row .col-del  { order: 2; flex: 0 0 auto;  align-self: center; }

  /* ── Line 2: Description full-width (forces its own row) ── */
  .line-item-row .col-desc { order: 3; flex: 1 1 100%;  min-width: 0; }

  /* ── Line 3: Qty / Unit Price / Total side by side ── */
  .line-item-row .col-qty   { order: 4; flex: 1 1 0; min-width: 52px; display: flex; flex-direction: column; gap: 2px; }
  .line-item-row .col-price { order: 5; flex: 2 1 0; min-width: 80px; display: flex; flex-direction: column; gap: 2px; }
  .line-item-row .col-total { order: 6; flex: 1 1 0; min-width: 90px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

  /* Mini labels above each number cell */
  .line-item-row .col-qty::before,
  .line-item-row .col-price::before,
  .line-item-row .col-total::before {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--c-text-muted);
  }
  .line-item-row .col-qty::before   { content: 'Qty'; }
  .line-item-row .col-price::before { content: 'Unit price'; }
  .line-item-row .col-total::before { content: 'Total'; }

  /* Total value: vertically centered, right-aligned */
  .line-item-row .li-row-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 36px;
    font-weight: 600;
    white-space: normal;
    word-break: break-word;
  }

  /* Inputs and selects fill their cell */
  .line-item-row .li-input,
  .line-item-row .li-select { width: 100%; }
}

.li-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: var(--space-1) var(--space-2);
  font-family: inherit;
  font-size: var(--text-sm);
  background: transparent;
  min-height: 36px;
  transition: border-color .15s, background .15s;
}

.li-input:focus {
  outline: none;
  border-color: var(--c-primary);
  background: var(--c-surface);
}

.li-input--num {
  text-align: right;
}

.li-input--desc {
  resize: none;
  overflow: hidden;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}

.li-select {
  padding: var(--space-1) var(--space-1);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  cursor: pointer;
  min-height: 36px;
  appearance: auto;
}

.li-del-btn {
  color: var(--c-text-muted);
  font-size: 18px;
  min-height: 36px;
  min-width: 36px;
}
.li-del-btn:active { color: var(--c-danger); }

.add-line-btn {
  color: var(--c-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) 0;
}

/* Totals block */
.totals-block {
  margin-left: auto;
  width: 260px;
  border-top: 2px solid var(--c-border);
  padding-top: var(--space-3);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: var(--text-sm);
}

.totals-row--total {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-top: var(--space-2);
  border-top: 1px solid var(--c-border);
  padding-top: var(--space-2);
}

.btn-add-tax {
  font-size: var(--text-sm);
  color: var(--c-primary);
  text-decoration: underline;
  text-decoration-color: transparent;
  height: auto;
  min-height: unset;
  min-width: unset;
  padding: 0;
  transition: text-decoration-color .15s;
}
.btn-add-tax:hover { text-decoration-color: var(--c-primary); }

/* Status selector strip */
.status-strip {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.status-btn {
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: 99px;
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1.5px solid var(--c-border);
  color: var(--c-text-muted);
  background: var(--c-surface);
  min-width: unset;
  min-height: 36px;
}

.status-btn[aria-pressed="true"] {
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: #e8f0fe;
}

/* Sticky bottom action bar */
.doc-sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.doc-sticky-bar__row {
  display: flex;
  gap: var(--space-2);
}

.doc-sticky-bar__save {
  flex: 1;
}

.doc-sticky-bar__send {
  flex: 2;
}

/* Dark navy — matches app nav bar */
.btn--dark {
  background: var(--c-primary);
  color: #fff;
  border: none;
}
.btn--dark:active { background: var(--c-primary-dk); }

/* Text links row: "Save draft · Save as invoice" */
.doc-sticky-bar__convert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.doc-sticky-bar__convert-sep {
  font-size: 14px;
  color: var(--c-text-muted);
  line-height: 1;
}

.doc-sticky-bar__convert-link {
  background: none;
  border: none;
  padding: var(--space-1) 0;
  font-size: 14px;
  color: var(--c-text-muted);
  text-decoration: underline;
  cursor: pointer;
}
.doc-sticky-bar__convert-link:active {
  opacity: .7;
}

/* Extra bottom padding on the editor so content isn't hidden under the bar */
#view-doc-editor {
  padding-bottom: 120px;
}

/* ── Document view (read-only / print) ──────────────────────────────────── */

#view-doc-view {
  padding-top: 0;
  max-width: 780px;
}

/* Screen toolbar */
.doc-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0 var(--space-4);
  border-bottom: 1px solid var(--c-border);
  margin-bottom: var(--space-5);
}

.doc-view-toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.doc-view-toolbar__btn {
  font-size: var(--text-sm);
  height: 36px;
  min-height: 36px;
  padding: 0 var(--space-3);
  min-width: unset;
  color: var(--c-text-muted);
}

.doc-view-toolbar__send {
  height: 36px;
  min-height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: 700;
  min-width: unset;
}

/* Inline send panel — sits between toolbar and document */
.docview-send-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}

/* The printable document card */
.print-doc {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
}

@media screen and (max-width: 480px) {
  .print-doc { padding: var(--space-5); }
}

.print-doc__table th {
  white-space: nowrap;
}

/* ── Screen-only: simplify the estimate view + hide print-only elements ──── */
@media screen {
  .print-doc__watermark { display: none; }
  /* Hide company branding — irrelevant to the user viewing their own estimate */
  .print-doc__from   { display: none; }
  /* Hide large doc type / number heading (already shown in the app bar) */
  #pdv-doc-type,
  #pdv-doc-number    { display: none; }
  /* Hide footer signature block */
  .print-doc__footer { display: none !important; }
  /* Allow table to scroll horizontally on narrow viewports */
  .print-doc         { overflow-x: auto; }
}


/* Header: logo+company left, doc meta right */
.print-doc__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-5);
}

@media screen and (max-width: 480px) {
  .print-doc__header { flex-direction: column; gap: var(--space-4); }
}

.print-doc__logo {
  max-width: 120px;
  max-height: 64px;
  object-fit: contain;
  margin-bottom: var(--space-3);
  display: block;
}

.print-doc__company-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--c-text);
  margin-bottom: var(--space-1);
}

.print-doc__from-line {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  line-height: 1.6;
}

/* Right: doc type, number, status, dates */
.print-doc__doc-meta {
  text-align: right;
  flex-shrink: 0;
}

.print-doc__doc-type {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--c-primary);
  letter-spacing: -.02em;
  line-height: 1.1;
  margin-bottom: var(--space-1);
}

.print-doc__doc-number {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-bottom: var(--space-2);
}

.print-doc__status-chip {
  margin-bottom: var(--space-3);
}

.print-doc__meta-date {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: var(--space-2);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

.print-doc__meta-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-text-muted);
}

/* Divider */
.print-doc__rule {
  border: none;
  border-top: 1.5px solid var(--c-border);
  margin: var(--space-5) 0;
}

/* Prepared For / Job Site / Job */
.print-doc__info-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

@media screen and (max-width: 500px) {
  .print-doc__info-row {
    grid-template-columns: 1fr 1fr;
  }
}

.print-doc__info-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  margin-bottom: var(--space-1);
}

.print-doc__info-val {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-text);
}

.print-doc__info-sub {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-top: 2px;
}

/* Line items table */
.print-doc__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.print-doc__table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text-muted);
  padding: var(--space-2);
  border-bottom: 2px solid var(--c-border);
}

.print-doc__table td {
  padding: var(--space-2);
  vertical-align: top;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
}

.print-col-type  { width: 14%; }
.print-col-desc  { width: 36%; }
.print-col-qty   { width: 10%; text-align: right; }
.print-col-price { width: 18%; text-align: right; }
.print-col-total { width: 16%; text-align: right; }

/* .print-doc__table th { text-align: left } (specificity 0,1,1) overrides the
   text-align: right on .print-col-* (specificity 0,1,0) for th elements.
   These rules (0,2,1) restore right-alignment for the numeric column headers. */
.print-doc__table th.print-col-qty,
.print-doc__table th.print-col-price,
.print-doc__table th.print-col-total { text-align: right; }

@media screen and (max-width: 480px) {
  /* Scroll-shadow: right-edge fade signals the table is horizontally scrollable.
     Two layers: the `scroll` layer sits fixed at the element's right edge (always
     present); the `local` layer scrolls with the content and masks the `scroll`
     layer once the user has reached the rightmost position. */
  .print-doc {
    background:
      linear-gradient(#fff, #fff) right / 52px 100% local  no-repeat,
      linear-gradient(to left, #fff 30%, transparent) right / 52px 100% scroll no-repeat;
    background-color: #fff;
  }
}

/* Totals */
.print-doc__totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-bottom: var(--space-6);
}

.print-totals-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  font-size: var(--text-sm);
  width: 260px;
}

.print-totals-row--total {
  font-weight: 700;
  font-size: var(--text-base);
  padding-top: var(--space-2);
  margin-top: var(--space-1);
  border-top: 1.5px solid var(--c-border);
}

/* Notes block */
.print-doc__notes {
  background: var(--c-bg);
  border-radius: var(--r-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}

.print-doc__notes-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  margin-bottom: var(--space-2);
}

.print-doc__notes-text {
  font-size: var(--text-sm);
  color: var(--c-text);
  white-space: pre-wrap;
  line-height: 1.6;
}

/* Footer */
.print-doc__footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--c-border);
}

.print-doc__thanks {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: var(--space-1);
}

.print-doc__footer-contact {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
}

.print-doc__footer-right {
  text-align: right;
  flex-shrink: 0;
  padding-top: var(--space-8);
}

.print-doc__sig-line {
  width: 220px;
  border-bottom: 1px solid var(--c-text);
  margin-bottom: var(--space-2);
  /* height drives the space above the line for signing */
  padding-top: 48px;
}

.print-doc__sig-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-text-muted);
}

.print-doc__sig-name {
  font-size: var(--text-sm);
  color: var(--c-text);
  margin-top: 4px;
}

@page {
  size: letter portrait;
  margin: 0.75in;
}

/* ── Print media — hide everything except .print-doc ────────────────────── */
@media print {
  .no-print,
  #app-bar,
  #toast { display: none !important; }

  body { background: #fff; }

  #app {
    height: auto;
    overflow: visible;
  }

  #views {
    overflow: visible;
  }

  .view { display: none !important; }

  #view-doc-view {
    display: block !important;
    padding: 0;
    max-width: none;
    margin: 0;
  }

  .print-doc {
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    width: 750px !important;
    min-width: 750px !important;
    max-width: 750px !important;
  }

  .doc-sticky-bar { display: none; }

  .print-doc__watermark {
    display: block;
    text-align: center;
    font-size: 10px;
    color: #999;
    margin-top: var(--space-6);
  }
}

/* ── Clients / Address book ─────────────────────────────────────────────── */

.clients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.clients-header__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
}

.clients-header__add {
  font-size: var(--text-sm);
  height: 36px;
  min-height: 36px;
  padding: 0 var(--space-4);
}

.client-row {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.client-row__summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
}
.client-row__summary:active { background: var(--c-bg); }

.client-row__name {
  font-weight: 600;
  font-size: var(--text-base);
  flex: 1;
}

.client-row__sub {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  flex: 1;
}

.client-row__chevron {
  color: var(--c-text-muted);
  font-size: 1.25rem;
  transition: transform .15s;
}
.client-row--open .client-row__chevron { transform: rotate(90deg); }

.client-row__form {
  border-top: 1px solid var(--c-border);
  padding: var(--space-4);
}

.client-row--new .client-row__form {
  border-top: none;
}

.client-contact-actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) 0;
}

.client-contact-btn {
  flex: 1;
  display: flex;
  justify-content: center;
  text-decoration: none;
}

.client-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.client-form__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-2);
  flex-wrap: wrap;
}

.client-form__cancel {
  background: none;
  border: none;
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  min-height: unset;
}
.client-form__cancel:active { opacity: .7; }

/* ── Document type picker ────────────────────────────────────────────────── */

#view-doc-type { max-width: 520px; }

.doc-type-subtitle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-6);
}

.doc-type-subtitle__client {
  font-weight: 600;
  font-size: var(--text-base);
}

.doc-type-subtitle__addr {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
}

.doc-type-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 380px) {
  .doc-type-cards { grid-template-columns: 1fr; }
}

.doc-type-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--space-5);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
  height: auto;
  min-height: unset;
  min-width: unset;
  white-space: normal;
}

.doc-type-card:hover,
.doc-type-card:focus-visible {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-md);
  outline: none;
}

.doc-type-card:active { background: var(--c-bg); }

.doc-type-card__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--c-text);
  margin-bottom: var(--space-3);
  letter-spacing: -.01em;
}

.doc-type-card__desc {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  line-height: 1.6;
}

/* ── Settings / Company Setup ────────────────────────────────────────────── */

#view-settings { max-width: 520px; }

/* Onboarding header */
.setup-header {
  text-align: center;
  padding: var(--space-6) 0 var(--space-8);
}

.setup-heading {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--c-text);
  margin-bottom: var(--space-2);
  letter-spacing: -.01em;
}

.setup-subheading {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  line-height: 1.6;
}

/* Step indicator */
.step-indicator {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-bottom: var(--space-6);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.step__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-border);
  display: block;
  margin-top: 2px;
}

.step--active .step__dot {
  background: var(--c-accent);
  width: 10px;
  height: 10px;
  margin-top: 1px;
}

.step__label {
  font-size: 0.6875rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}

.step--active .step__label {
  color: var(--c-accent);
  font-weight: 700;
}

.step-line {
  width: 48px;
  height: 1px;
  background: var(--c-border);
  margin: 6px var(--space-2) 0;
  flex-shrink: 0;
}

/* Logo upload field */
.logo-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.logo-field__preview-wrap {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border: 2px dashed var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--c-bg);
  transition: border-color .15s, background .15s;
  padding: 0;
  min-height: unset;
  min-width: unset;
}

.logo-field__preview-wrap:hover,
.logo-field__preview-wrap:focus-visible {
  border-color: var(--c-primary);
  background: #EBF1F8;
}

.logo-field__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.logo-field__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-1);
  pointer-events: none;
}

.logo-field__icon {
  width: 22px;
  height: 22px;
  color: var(--c-border);
  display: block;
}

.logo-field__add-text {
  font-size: 0.6875rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

.logo-field__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-1);
}

.logo-field__hint {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  line-height: 1.6;
}

.logo-field__remove {
  font-size: var(--text-xs);
  color: var(--c-danger);
  text-decoration: underline;
  text-decoration-color: transparent;
  height: auto;
  min-height: unset;
  min-width: unset;
  padding: 0;
  justify-content: flex-start;
  transition: text-decoration-color .15s;
}

.logo-field__remove:hover { text-decoration-color: var(--c-danger); }

.logo-field input[type="file"] { display: none; }

/* Two-column fields row */
.fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
  align-items: start;
}

.fields-row .field + .field { margin-top: 0; }

@media (max-width: 380px) {
  .fields-row { grid-template-columns: 1fr; }
}

/* Optional label hint */
.label--opt {
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--c-text-muted);
  font-size: var(--text-xs);
  margin-left: 2px;
}


/* ── Trial banner ─────────────────────────────────────────────────────────── */

.trial-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  font-size: var(--text-sm);
  color: #92400e;
}

.trial-banner.hidden { display: none; }

.trial-banner .btn--sm {
  padding: 6px 12px;
  font-size: var(--text-xs);
  min-height: 0;
  height: auto;
}


/* ── Subscription modal ───────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding: var(--space-4);
}

.modal-overlay.hidden { display: none; }

.modal-card {
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: var(--space-6) var(--space-5);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-card__title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
}

.modal-card__context {
  color: var(--c-text-muted);
  font-size: var(--text-sm);
  margin: 0;
  min-height: 1em;
}

.plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.plan-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-4) var(--space-3);
  border: 2px solid var(--c-border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
  position: relative;
}

.plan-card--selected,
.plan-card:focus-visible {
  border-color: var(--c-primary);
  background: #eff6ff;
  outline: none;
}

.plan-card--featured { background: #f0fdf4; border-color: #86efac; }
.plan-card--featured.plan-card--selected { border-color: #16a34a; background: #dcfce7; }

.plan-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #16a34a;
  margin-bottom: 4px;
}

.plan-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1;
}

.plan-period {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}


/* ── Settings subscription section ───────────────────────────────────────── */

.settings-section-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0 0 var(--space-2);
  color: var(--c-text);
}

.settings-sub-status {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin: 0 0 var(--space-3);
}


/* ── Admin panel ──────────────────────────────────────────────────────────── */

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.admin-stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: var(--space-3);
  text-align: center;
}

.admin-stat--warn { background: #fef3c7; border-color: #fcd34d; }

.admin-stat__val {
  font-size: 28px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1;
}

.admin-stat__label {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  margin-top: 4px;
}

.admin-section-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

.admin-user-row {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.admin-user-row__email {
  font-size: var(--text-sm);
  font-weight: 600;
  word-break: break-all;
}

.admin-user-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.admin-user-row__role {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  font-style: italic;
}

.admin-user-row__detail {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}

.admin-user-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.btn--xs {
  font-size: var(--text-xs);
  padding: 4px 10px;
  min-height: 0;
  height: auto;
  border-radius: 6px;
}

.admin-loading {
  color: var(--c-text-muted);
  font-size: var(--text-sm);
}

/* FAB locked state */
.fab--locked {
  opacity: 0.65;
  filter: grayscale(0.4);
}
