*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
input, select, textarea { min-width: 0; }

:root {
  --bg:          #0d0f14;
  --surface:     #161920;
  --surface2:    #1e2230;
  --border:      #2a2f42;
  --text:        #e4e8f0;
  --muted:       #6b7289;
  --accent:      #4f7ef8;
  --green:       #3ecf8e;
  --red:         #f87171;
  --yellow:      #fbbf24;
  --purple:      #a78bfa;
  --pink:        #f472b6;
  --radius:      10px;
}

/* ── Light theme ── */
.theme-light {
  --bg:      #f5f7fb;
  --surface: #ffffff;
  --surface2: #edf0f7;
  --border:  #dce1ef;
  --text:    #111827;
  --muted:   #6b7289;
  color-scheme: light;
}

/* ── System preference (when no explicit class) ── */
@media (prefers-color-scheme: light) {
  :root:not(.theme-dark):not(.theme-light) {
    --bg:      #f5f7fb;
    --surface: #ffffff;
    --surface2: #edf0f7;
    --border:  #dce1ef;
    --text:    #111827;
    --muted:   #6b7289;
    color-scheme: light;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Layout ── */
.app-container {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 1rem 5rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 0;
  padding-top: max(env(safe-area-inset-top), 1.1rem);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; width: 100%; }

.app-header-detail {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
}
.detail-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger:hover { opacity: 0.85; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.875rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border); }

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}
.btn-icon:hover { color: var(--text); }

.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.btn-back:hover { text-decoration: underline; }

.select-deal-type { font-size: 0.82rem; font-weight: 600; }

.btn-danger-sm {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger-sm:hover { background: rgba(248,113,113,0.1); }

.btn-delete-item {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.btn-delete-item:hover { color: var(--red); background: rgba(248,113,113,0.1); }

/* ── Section ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.item-actions { display: flex; gap: 0.4rem; align-items: center; }

.section-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

/* ── Summary card ── */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.summary-oop-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.summary-oop-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--red);
  letter-spacing: -0.02em;
}

.summary-oop-sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.summary-oop-breakdown {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 0.6rem;
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
}

.summary-oop-partner {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.summary-oop-partner-val {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.summary-oop-sep {
  width: 1px;
  height: 2rem;
  background: var(--border);
  margin: 0 1rem;
  flex-shrink: 0;
}

.summary-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.summary-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.summary-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-value.shared { color: var(--purple); }

.summary-sep {
  height: 1px;
  background: var(--border);
  margin: 0.1rem 0;
}

.summary-divider {
  width: 1px;
  height: 2.5rem;
  background: var(--border);
  margin: 0 1.1rem;
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .summary-row { flex-wrap: wrap; gap: 0.75rem; }
  .summary-divider { display: none; }
  .summary-stat { min-width: 30%; }
}

/* ── List toolbar (sort + new deal) ── */
.list-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.select-sort {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}

.btn-sort-dir {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}
.btn-sort-dir:hover { background: var(--border); }

/* ── Date fields ── */
.date-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.date-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.date-field label {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-date {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.3rem;
  border-radius: 6px;
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  color-scheme: dark;
  width: 100%;
  min-width: 0;
}
.input-date:focus { border-color: var(--accent); }

.stat-date { font-size: 0.85rem; }

/* ── Deal list cards ── */
.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.deal-card:hover { border-color: var(--accent); background: var(--surface2); }
.deal-card:active { border-color: var(--accent); background: var(--surface2); transform: scale(0.995); }

.deal-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

.deal-name-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.deal-name { font-weight: 600; font-size: 1rem; }

.deal-init-cost {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.days-ok     { color: var(--text); }
.days-orange { color: var(--yellow); font-weight: 600; }
.days-red    { color: var(--red);    font-weight: 700; }

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-active  { background: rgba(79,126,248,0.15); color: var(--accent); }
.badge-sold    { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-solo    { background: rgba(251,191,36,0.15); color: var(--yellow); }

.deal-card-cover { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex-shrink: 0; align-self: center; }
.deal-card-stats { display: flex; flex-wrap: wrap; gap: 0.9rem 2rem; }

.photos-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.photo-thumb { position: relative; width: 80px; height: 80px; border-radius: 6px; overflow: hidden; background: var(--surface2); flex-shrink: 0; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn-remove-photo { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); border: none; color: #fff; font-size: 0.65rem; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; line-height: 1; padding: 0; }
.photo-thumb:hover .btn-remove-photo { opacity: 1; }
.stat { display: flex; flex-direction: column; gap: 0.1rem; }
.stat-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 0.95rem; font-weight: 600; }

.positive { color: var(--green); }
.negative { color: var(--red); }

/* ── Deal detail header inputs ── */
.deal-title-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding: 0.45rem 0.75rem;
  outline: none;
  letter-spacing: -0.02em;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.deal-title-input:focus { border-color: var(--accent); }

.select-status {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}

/* ── Gross profit hero ── */
.gross-profit-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.gph-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.2rem;
}
.gph-value {
  font-size: 2.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}
.gph-empty { color: var(--muted); }
.gross-profit-hero.positive .gph-value { color: var(--green); }
.gross-profit-hero.negative .gph-value { color: var(--red); }
.gph-margin {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.gph-hint { font-size: 0.78rem; color: var(--muted); }

/* ── Partner strip ── */
.partner-strip {
  margin-bottom: 1rem;
  padding: 0.55rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ps-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ps-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  flex-shrink: 0;
}
.ps-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.45rem 0.15rem 0.25rem;
  font-size: 0.8rem;
  font-weight: 500;
}
.ps-chip-avatar {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ps-chip.pending .ps-chip-avatar { background: var(--yellow); }
.ps-chip-remove {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.65rem; padding: 0 0.1rem;
  line-height: 1; display: flex; align-items: center;
  transition: color 0.15s;
}
.ps-chip-remove:hover { color: var(--red); }
.ps-empty { font-size: 0.82rem; color: var(--muted); font-style: italic; }

/* ── Initial cost inline (inside profit panel) ── */
.initial-cost-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.ici-label { font-size: 1rem; font-weight: 600; color: var(--text); flex: 1; min-width: 120px; }

/* ── Items cost cell ── */
.item-cost-cell { display: flex; align-items: center; gap: 0.15rem; }
.item-cost-sym  { color: var(--muted); font-size: 0.82rem; font-weight: 600; flex-shrink: 0; }

/* ── Items breakdown below table ── */
.items-breakdown {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.25rem 0;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--border);
  margin-top: 0.1rem;
}

/* ── Profit panel ── */
.profit-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.sale-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
  padding-bottom: 0.65rem;
}
.sale-price-row label { font-weight: 600; font-size: 1rem; }

.price-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  transition: border-color 0.15s;
}
.price-input-wrap:focus-within { border-color: var(--accent); }

.currency-symbol { color: var(--muted); font-weight: 600; font-size: 1rem; }

.sale-price-input {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  width: 130px;
  text-align: right;
  outline: none;
}
/* hide number spinners */
.sale-price-input::-webkit-outer-spin-button,
.sale-price-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.sale-price-input[type=number] { -moz-appearance: textfield; }

.profit-grid { display: flex; flex-direction: column; gap: 0.45rem; }

.profit-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
}
.profit-row.indent {
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.83rem;
}
.profit-row.total-costs { font-weight: 600; }
.profit-row.gross {
  font-weight: 700;
  font-size: 1rem;
}
.profit-row.net-each { color: var(--muted); font-size: 0.85rem; }
.profit-row span:last-child { font-variant-numeric: tabular-nums; }

.profit-divider { height: 1px; background: var(--border); margin: 0.4rem 0; }

.payout-block {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
}
.payout-block + .payout-block { margin-top: 0.5rem; }

.payout-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.payout-name { font-weight: 600; font-size: 0.9rem; }
.payout-amount { font-weight: 700; font-size: 1.15rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.payout-amount.negative { color: var(--red); }
.payout-breakdown { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

/* ── Items table ── */
.items-table { width: 100%; border-collapse: collapse; }

.items-table th {
  text-align: left;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.col-sort { cursor: pointer; user-select: none; transition: color 0.15s; }
.col-sort:hover { color: var(--text); }
.items-table th.col-cost  { text-align: right; width: 100px; }
.items-table th.col-paid  { width: 120px; }
.items-table th.col-del   { width: 32px; }

.items-table td {
  padding: 0.35rem 0.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.items-table tr:last-child td { border-bottom: none; }

.input-inline {
  background: none;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.28rem 0.4rem;
  border-radius: 4px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input-inline:focus { border-color: var(--accent); background: var(--surface2); }
.input-inline::-webkit-outer-spin-button,
.input-inline::-webkit-inner-spin-button { -webkit-appearance: none; }
.input-inline[type=number] { -moz-appearance: textfield; }
.input-money { text-align: right; font-variant-numeric: tabular-nums; }

.select-inline {
  background: var(--surface2);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.28rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.select-inline:focus { border-color: var(--accent); }

.paid-you     { color: var(--accent); }
.paid-partner { color: var(--yellow); }
.paid-split   { color: var(--green); }

/* items table footer totals */
.items-table tfoot td {
  border-top: 1px solid var(--border);
  border-bottom: none;
  padding-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.items-table tfoot .total-label { font-size: 0.78rem; color: var(--muted); }
.items-table tfoot .total-val   { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); font-size: 0.875rem; text-align: right; padding-right: 0.65rem; }

/* ── Notes ── */
.notes-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  overflow: hidden;
  min-height: 48px;
  outline: none;
  transition: border-color 0.15s;
}
.notes-input:focus { border-color: var(--accent); }

.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-group { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.text-input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.5rem 0.65rem; color: var(--text); font-size: 0.875rem;
  outline: none; transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--accent); }

/* ── Settings ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.threshold-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.input-field {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.input-field:focus { border-color: var(--accent); }

/* ── Misc ── */
.empty {
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 1.5rem 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1rem 2.5rem;
  gap: 0.5rem;
  text-align: center;
}
.empty-icon { font-size: 2.8rem; line-height: 1; margin-bottom: 0.25rem; }
.empty-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.empty-sub { font-size: 0.875rem; color: var(--muted); max-width: 260px; line-height: 1.55; margin-bottom: 0.75rem; }

.section-spacer { margin-top: 2rem; }
.sold-toggle-header { cursor: pointer; user-select: none; }
.sold-toggle-header:active { opacity: 0.7; }
.sold-count { font-weight: 400; opacity: 0.7; }
.btn-toggle-sold {
  font-size: 0.7rem;
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 500px) {
  .sale-price-input { width: 100px; }
  .items-table th.col-paid { width: 90px; }
}

/* ── Header logo ── */
.header-logo {
  width: 200px;
  height: 56px;
  object-fit: contain;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.user-greeting {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.btn-signout {
  font-size: 1rem;
  opacity: 0.6;
}
.btn-signout:hover { opacity: 1; color: var(--red); }

.btn-signout-text {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-signout-text:hover { color: var(--red); border-color: var(--red); }

/* ── Sold lock ── */
.deal-locked {
  opacity: 0.65;
  pointer-events: none;
}

/* ── Sell / Undo Sold buttons ── */
.btn-sell {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-sell:hover { opacity: 0.75; }

.btn-undo-sold {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-undo-sold:hover { opacity: 0.75; }

/* ── Loading screen ── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1.5rem;
}

.loading-logo {
  width: 192px;
  height: 192px;
  border-radius: 16px;
  opacity: 0.85;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login screen ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.login-logo {
  width: 192px;
  height: 192px;
  border-radius: 20px;
  object-fit: cover;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 0.25rem;
}

.login-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.btn-google {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: box-shadow 0.15s, background 0.15s;
}
.btn-google:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.25); background: #f8f8f8; }

.google-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Partner UI ── */
.partner-card { margin-bottom: 1rem; }

.partner-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.25rem; }

.partner-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.partner-row:last-child { border-bottom: none; }

.partner-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: var(--muted);
  flex-shrink: 0;
}

.partner-name  { font-size: 0.875rem; font-weight: 500; }
.partner-email-sub { font-size: 0.72rem; color: var(--muted); display: block; }
.partner-info  { display: flex; flex-direction: column; gap: 0.1rem; flex: 1; }

/* ── Name tag (partner color bubble) ── */
.name-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.45rem;
  border-radius: 20px;
  font-size: inherit;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Partner color swatches (settings) ── */
.partner-colors { display: flex; gap: 0.3rem; margin-top: 0.4rem; flex-wrap: wrap; align-items: center; }
.color-swatch {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, border-color 0.12s;
  padding: 0;
}
.color-swatch:hover { transform: scale(1.25); }
.color-swatch.active { border-color: var(--text); }
.color-swatch-custom {
  background: var(--surface2) !important;
  border: 1.5px dashed var(--border) !important;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.color-swatch-custom:hover { color: var(--text); border-color: var(--text) !important; }
.color-swatch-clear {
  background: none !important;
  width: auto; height: auto;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.65rem;
  padding: 0.05rem 0.3rem;
  line-height: 1.4;
}

.badge-shared  { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-pending { background: rgba(251,191,36,0.15);  color: var(--yellow); }

.btn-remove-partner, .btn-remove-known-partner {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.8rem; padding: 0.2rem 0.4rem;
  border-radius: 4px; margin-left: auto; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.btn-remove-partner:hover, .btn-remove-known-partner:hover {
  color: var(--red); background: rgba(248,113,113,0.1);
}

.invite-form {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.85rem;
  margin-top: 0.75rem;
}

.invite-error {
  color: var(--red);
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

.invite-type-toggle {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.1rem;
}

.btn-type-tab {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-type-tab.active {
  background: rgba(79,126,248,0.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.btn-type-tab:hover:not(.active) { background: var(--border); color: var(--text); }

.invite-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.known-partner-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.btn-pick-partner {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-pick-partner:hover { background: rgba(79,126,248,0.15); border-color: var(--accent); color: var(--accent); }

.invite-or {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.4rem 0;
}

.settings-name-display {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.5rem 0;
}

.login-error {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--red);
  font-size: 0.8rem;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  width: 100%;
  text-align: left;
}

/* ── Login tabs ── */
.login-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.25rem;
  width: 100%;
}

.btn-login-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-login-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.btn-login-tab:hover:not(.active) { color: var(--text); }

/* ── Login form ── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}

.login-form .input-field {
  text-align: left;
}

/* ── Login divider (OR separator) ── */
.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  color: var(--muted);
  font-size: 0.78rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Forgot password link ── */
.btn-forgot {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  text-align: right;
  align-self: flex-end;
  transition: color 0.15s;
}
.btn-forgot:hover { color: var(--accent); }

/* ── Login success message ── */
.login-success {
  background: rgba(62,207,142,0.12);
  border: 1px solid rgba(62,207,142,0.3);
  color: var(--green);
  font-size: 0.8rem;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  width: 100%;
  text-align: left;
}

/* ── Connected account indicator (Settings) ── */
.connected-account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(62,207,142,0.1);
  border: 1px solid rgba(62,207,142,0.25);
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  width: 100%;
}

/* ── Share Listing Modal ───────────────────────────────────────────────────── */
.share-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.share-modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.share-card {
  background: #fff; color: #111; border-radius: 10px;
  padding: 24px; margin-bottom: 16px;
}
.sc-name  { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.sc-price { font-size: 1.1rem; font-weight: 600; color: #1a7f4f; margin-bottom: 14px; }
.sc-desc  { font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; color: #333; margin-bottom: 18px; }
.sc-contact-block { border-top: 1px solid #e5e7eb; padding-top: 12px; margin-bottom: 16px; }
.sc-contact-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .07em; color: #999; margin-bottom: 3px; }
.sc-contact-name  { font-weight: 600; font-size: 0.9rem; color: #111; }
.sc-contact-info  { font-size: 0.85rem; color: #555; }
.sc-footer { border-top: 1px solid #e5e7eb; padding-top: 10px; margin-top: 20px; display: flex; align-items: center; gap: 6px; }
.sc-watermark-label { font-size: 0.65rem; color: #aaa; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.sc-logo   { height: 14px; object-fit: contain; opacity: 0.6; }
.share-modal-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.share-modal-actions .btn-danger-sm { margin-left: auto; }

/* ── Settlement section ── */
.settle-header-row,
.settle-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 90px;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.3rem 0;
}
.settle-header-row {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
  padding-bottom: 0.4rem;
}
.sr-name  { font-weight: 500; }
.sr-paid, .sr-share, .sr-balance { text-align: right; font-variant-numeric: tabular-nums; }
.sr-balance { font-weight: 600; }
.settle-header-row span:not(:first-child) { text-align: right; }
.settle-moves { display: flex; flex-direction: column; gap: 0.4rem; }
.settle-move {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.settle-move-amt { color: var(--accent); font-weight: 700; margin-left: auto; }
.extra-partner-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.extra-partner-row .ep-name { flex: 1.4; }
.ep-amount-wrap { flex: 1; display: flex; align-items: center; position: relative; }
.ep-amount-wrap .currency-symbol { position: absolute; left: 0.5rem; pointer-events: none; color: var(--muted); font-size: 0.85rem; }
.ep-amount-wrap .ep-amount { width: 100%; padding-left: 1.4rem; }
.btn-remove-ep {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 0.2rem 0.45rem; cursor: pointer; font-size: 0.75rem;
  transition: color 0.15s, border-color 0.15s; flex-shrink: 0;
}
.btn-remove-ep:hover { color: var(--red); border-color: var(--red); }

@media (max-width: 480px) {
  .settle-header-row,
  .settle-row { grid-template-columns: 1fr 68px 68px 76px; font-size: 0.8rem; }
}

/* ── Pull-to-refresh ── */
#ptr-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.ptr-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ptr-spin 0.7s linear infinite;
}

@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}

/* ── Notification bell ── */
.btn-notif-bell {
  position: relative;
}
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* ── Notification list ── */
.notif-perm-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  margin: 1rem 1rem 0.5rem;
}
.notif-perm-icon { font-size: 2rem; line-height: 1; }
.notif-perm-title { font-weight: 600; font-size: 0.95rem; color: var(--text); margin: 0; }
.notif-perm-sub { font-size: 0.8rem; color: var(--muted); margin: 0; line-height: 1.5; }
.notif-perm-notice .btn-primary { margin-top: 0.4rem; width: 100%; }

.notif-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
}
.notif-item.notif-unread {
  border-left: 3px solid var(--accent);
  background: var(--surface2);
}
.notif-item.notif-navable {
  cursor: pointer;
  align-items: center;
}
.notif-item.notif-navable:active {
  opacity: 0.7;
}
.notif-chevron {
  font-size: 1.25rem;
  color: var(--muted);
  margin-left: auto;
  flex-shrink: 0;
}
.notif-item.notif-invite {
  border-left: 3px solid var(--yellow);
  background: var(--surface2);
}
.notif-item.notif-ota-card {
  border-left: 3px solid var(--accent);
  background: var(--surface2);
}
.notif-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.notif-avatar-invite {
  background: var(--yellow);
  color: #000;
  font-weight: 700;
  font-size: 0.875rem;
}
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 0.15rem; }
.notif-sub   { font-size: 0.8rem;   color: var(--muted); }
.notif-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* ── Developer section ── */
.dev-section { border: 1px solid var(--purple); }
.dev-section h3 { color: var(--purple); }

/* ── In-app push banner ── */
#push-banner {
  position: fixed;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 9998;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: push-slide-in 0.25s ease;
}
.push-banner-inner { flex: 1; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.875rem; }
.push-banner-inner strong { font-weight: 600; }
.push-banner-inner span   { color: var(--muted); font-size: 0.8rem; }
@keyframes push-slide-in { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
#push-banner > button {
  background: none; border: none; color: var(--muted);
  font-size: 1rem; cursor: pointer; flex-shrink: 0;
}


/* ── Custom Color Picker ─────────────────────────────────────────────────── */
.cp-wrap { position: relative; display: inline-block; }
.cp-trigger {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.cp-trigger:hover, .cp-trigger.cp-open { border-color: var(--accent); transform: scale(1.08); }
.cp-plus { color: var(--muted); font-size: 17px; font-weight: 300; line-height: 1; margin-top: -1px; }
.cp-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 300;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  width: 176px;
}
.cp-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px;
  margin-bottom: 10px;
}
.cp-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.cp-swatch:hover { transform: scale(1.18); }
.cp-swatch.cp-active { border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.35); }
.cp-footer {
  display: flex; align-items: center; gap: 5px;
  border-top: 1px solid var(--border); padding-top: 9px;
}
.cp-hash { color: var(--muted); font-size: 13px; font-family: monospace; flex-shrink: 0; }
.cp-hex-input {
  flex: 1; min-width: 0; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 6px; font-size: 12px; font-family: monospace;
  color: var(--text); outline: none; text-transform: uppercase;
}
.cp-hex-input:focus { border-color: var(--accent); }
.cp-clear-btn {
  font-size: 11px; color: var(--muted); background: none;
  border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 7px; cursor: pointer; flex-shrink: 0;
  transition: color 0.1s;
}
.cp-clear-btn:hover { color: var(--text); }


/* ── OTA loading / update screen ───────────────────────────────────────────── */
.ota-loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1.25rem;
  padding: 2rem 1.5rem;
}
.ota-loading-label {
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.ota-tip-card {
  margin-top: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
}
.ota-tip-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.ota-tip-text {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
  transition: opacity 0.35s ease;
}

/* ── Theme toggle ────────────────────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.btn-theme-opt {
  flex: 1;
  padding: 0.45rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-theme-opt.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}
