:root {
  /* NI Systems defaults — accent from Settings; borders stay neutral so green/blue themes stay readable */
  --accent: #3b82f6;
  --accent-dim: #60a5fa;
  --accent-muted: rgba(59, 130, 246, 0.15);
  --gold: var(--accent);
  --gold-dim: var(--accent-dim);
  --gold-muted: var(--accent-muted);
  --bg: #0a0e1a;
  --bg-card: #141b2d;
  --bg-card-hover: #1a2438;
  --bg-input: #141b2d;
  --input-text: #f3f4f6;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --nav-bg: #0d1220;
  --btn-on-accent: #ffffff;
  --purple: #a78bfa;
  --pink: #f472b6;
  --cyan: #22d3ee;
  --danger: #f87171;
  --success: #34d399;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "DM Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

.hidden { display: none !important; }

/* Header */
.app-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg) 80%, transparent);
}

.app-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.app-brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-transform: uppercase;
}

.app-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.page-wrap {
  padding: 0 1rem 1.5rem;
  max-width: 640px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .page-wrap--wide {
    max-width: min(1180px, calc(100% - 2.5rem));
  }

  .modal-sheet--wide {
    max-width: min(520px, calc(100% - 2rem));
    border-radius: 16px;
    margin-bottom: 10vh;
  }

  .modal-backdrop.modal-backdrop--center {
    align-items: center;
    padding: 1rem;
  }

  .invoice-edit-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .invoice-billing-card {
    grid-column: 1 / -1;
  }

  .project-customer-card {
    margin-bottom: 1rem;
  }

  .project-customer-card .hidden {
    display: none;
  }

  .invoice-lines-wrap .invoice-lines input[type="text"] {
    min-width: 200px;
  }
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 1rem;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  text-align: center;
  position: relative;
}

.stat-card--link {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.stat-card--link:hover,
.stat-card--link:focus {
  border-color: var(--accent);
  outline: none;
}

.stat-card-chevron {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.1;
}

.stat-card span {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

.time-report-summary {
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.time-report-date-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}

.time-report-row {
  margin-bottom: 0.5rem;
  padding: 0.85rem 1rem;
}

.time-report-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  justify-content: space-between;
}

.time-report-date {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.time-report-project {
  font-weight: 600;
  font-size: 0.95rem;
}

.time-report-hours {
  color: var(--gold);
  font-size: 1rem;
  flex-shrink: 0;
}

.time-report-notes {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Chips */
.chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chip.active {
  background: var(--gold);
  color: #0a0e1a;
  font-weight: 600;
}

/* List rows */
.list-section {
  margin-bottom: 1rem;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  gap: 1rem;
}

.list-row-end {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.list-row:active { opacity: 0.7; }

.list-row-title {
  font-weight: 600;
  color: var(--gold);
}

.list-row-title.purple { color: var(--purple); }
.list-row-title.pink { color: var(--pink); }
.list-row-title.cyan { color: var(--cyan); }

.list-row-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  height: 2.35rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  font-weight: 700;
  text-align: center;
}

.chevron {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
}

.card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--input-text);
  font-family: inherit;
  font-size: 0.95rem;
}

.form-group textarea {
  min-height: 90px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.checkbox-row input { width: auto; }

/* Buttons */
.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-gold {
  background: var(--gold);
  color: var(--btn-on-accent);
}

.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-block { width: 100%; }

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

/* Status pills */
.status {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-draft { background: rgba(156,163,175,0.2); color: var(--text-muted); }
.status-sent { background: rgba(34,211,238,0.15); color: var(--cyan); }
.status-paid { background: rgba(52,211,153,0.15); color: var(--success); }
.status-partial { background: rgba(251,191,36,0.15); color: #fbbf24; }
.invoice-payment-card { margin-top: 1rem; }
.invoice-payment-card .payment-row { display: flex; justify-content: space-between; margin: 0.35rem 0; font-size: 0.95rem; }
.invoice-payment-card .payment-row strong { color: var(--gold); }
.invoice-payment-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
.invoice-payment-actions input[type="number"] { width: 7rem; padding: 0.5rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.status-active { background: var(--gold-muted); color: var(--gold); }
.status-draft { background: rgba(251,191,36,0.15); color: #fbbf24; }
.status-completed { background: rgba(52,211,153,0.15); color: var(--success); }
.status-on_hold { background: rgba(167,139,250,0.15); color: var(--purple); }

.admin-draft-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(251,191,36,0.35);
  background: rgba(251,191,36,0.08);
  color: var(--text);
}

.admin-draft-banner--submitted {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}

.identity-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1rem;
}

.identity-submit-status {
  margin: 1rem 0 0;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.85rem;
  border: 1px solid rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.1);
  color: var(--text);
}

.identity-actions-hint {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.identity-color-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.identity-color-row input[type="color"] {
  width: 3rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}

.identity-color-preview {
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  overflow: hidden;
}

.identity-color-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.identity-logo-preview {
  display: block;
  max-width: 5rem;
  max-height: 5rem;
  border-radius: 12px;
  object-fit: cover;
  margin-bottom: 0.35rem;
}

/* Flash */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.flash-ok {
  background: rgba(52,211,153,0.12);
  border: 1px solid rgba(52,211,153,0.3);
  color: var(--success);
}

.flash-bad {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
}

.email-test-result {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.email-test-result--idle {
  border-color: var(--border);
}

.email-test-result--pending {
  border-color: rgba(26, 126, 232, 0.45);
  background: rgba(26, 126, 232, 0.08);
}

.email-test-result--ok {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.1);
}

.email-test-result--bad {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.12);
}

.email-test-result-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.email-test-result--ok .email-test-result-title {
  color: var(--success);
}

.email-test-result--bad .email-test-result-title {
  color: var(--danger);
}

.email-test-result-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.email-test-detail,
.email-test-details pre {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 240px;
}

.email-test-details {
  margin-top: 0.65rem;
  font-size: 0.82rem;
}

.email-test-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.email-settings-link-card {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.settings-section-title {
  color: var(--accent);
  font-size: 0.9rem;
  margin: 1.5rem 0 0.75rem;
}

.settings-section-title:first-child {
  margin-top: 0;
}

.theme-color-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.theme-color-input input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  cursor: pointer;
  flex-shrink: 0;
}

.theme-color-input input[type="text"] {
  flex: 1;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: radial-gradient(ellipse at top, #1a2744 0%, var(--bg) 60%);
}

.login-logo {
  width: min(260px, 86vw);
  height: auto;
  max-height: 72px;
  object-fit: contain;
  margin-bottom: 1.25rem;
}

.login-logo-wordmark {
  max-height: 56px;
  margin-bottom: 0.75rem;
}

.portal-header-min .app-sub {
  display: none;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

.login-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.35rem 0 2rem;
}

.login-form {
  width: 100%;
  max-width: 360px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.62rem;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: var(--gold);
}

.nav-item.active svg {
  stroke: var(--gold);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem 1rem calc(1.5rem + var(--safe-b));
}

.modal-sheet h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: var(--gold);
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

/* Install page */
.install-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
}

.install-steps li {
  counter-increment: step;
  padding: 0.75rem 0 0.75rem 2.5rem;
  position: relative;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.install-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.75rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--gold-muted);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.install-banner {
  background: linear-gradient(135deg, rgba(255,204,51,0.12), rgba(212,168,83,0.08));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.install-banner img {
  width: 64px;
  height: 64px;
  margin-bottom: 0.75rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.quick-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
}

.quick-link {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  text-align: center;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.quick-link span {
  display: block;
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.invoice-total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  text-align: right;
  margin: 1rem 0;
}

.line-items {
  font-size: 0.82rem;
}

.line-items .list-row { cursor: default; }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .form-row-2 { grid-template-columns: 1fr; }
}

.invoice-lines-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
}

.invoice-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.invoice-lines th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

.invoice-lines td {
  padding: 0.4rem;
  vertical-align: middle;
}

.invoice-lines input[type="text"],
.invoice-lines input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.55rem;
  font-size: 0.82rem;
}

.invoice-lines .col-qty {
  width: 5.5rem;
  text-align: center;
}

.invoice-lines .col-rate {
  width: 5rem;
  text-align: right;
}

.invoice-lines .col-amount {
  width: 7rem;
  text-align: right;
}

.invoice-lines .line-rate-cell {
  text-align: right;
  white-space: nowrap;
  width: 6.5rem;
}

.invoice-lines .line-rate-input {
  width: 100%;
  text-align: right;
  font-size: 0.88rem;
}

.invoice-lines .line-amount {
  display: block;
  font-weight: 600;
  color: var(--gold);
  text-align: right;
  font-size: 0.88rem;
}

.invoice-pdf-frame {
  width: 100%;
  height: calc(100dvh - 9rem);
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.page-wrap--pdf {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.invoice-lines .line-qty-cell {
  width: 5.5rem;
}

.invoice-lines .line-amount-cell {
  width: 7rem;
}

.invoice-lines .remove-line {
  min-width: 2rem;
  padding: 0.25rem 0.5rem;
}

.invoice-edit-totals {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.35rem;
  max-width: 220px;
  margin-left: auto;
  text-align: right;
  font-size: 0.88rem;
}

.invoice-edit-totals > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.invoice-edit-totals .invoice-total-row {
  font-size: 1.05rem;
  color: var(--gold);
  margin-top: 0.25rem;
}

.invoice-settings-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.invoice-settings-summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 12rem;
}

.invoice-due-preview {
  font-size: 0.82rem;
  color: var(--gold);
  margin-top: 0.35rem;
}

.radio-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}

.invoice-edit-totals .totals-vat-row.hidden,
.invoice-edit-totals .totals-subtotal-row.hidden {
  display: none !important;
}

.invoice-settings-bar .invoice-vat-toggle {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.home-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.home-requests-card {
  margin-bottom: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.home-requests-card:hover,
.home-requests-card:focus {
  border-color: var(--accent);
  outline: none;
}

.home-requests-card-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.home-requests-card-text {
  flex: 1;
  min-width: 0;
}

.home-requests-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.home-requests-sub {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.home-requests-badge {
  flex-shrink: 0;
  font-size: 0.95rem;
}

.home-requests-chevron {
  flex-shrink: 0;
  font-size: 1.25rem;
  color: var(--text-muted);
}

.project-request-card {
  margin-bottom: 0.75rem;
}

.project-request-details {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.88rem;
}

.project-request-details strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.project-request-details p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.project-request-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.65rem 0 0;
}

.project-request-thumb {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.project-request-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-request-file-link {
  display: inline-block;
  padding: 0.4rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--accent);
}

.project-request-actions {
  flex-direction: column;
  align-items: stretch;
  margin-top: 0.85rem !important;
  gap: 0.5rem;
}

.project-request-actions .btn {
  width: 100%;
  margin: 0;
}

.workspace-grid { display: grid; gap: 1rem; }
@media (min-width: 720px) {
  .workspace-grid { grid-template-columns: 1fr 1fr; }
  .workspace-chat { grid-column: 1 / -1; }
}
.workspace-panel h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.todo-list .todo-row { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

.feature-list .feature-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.feature-row--done .feature-title {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(34, 197, 94, 0.55);
}

.feature-row--done .feature-check input {
  accent-color: #22c55e;
}

.feature-notes {
  margin: 0.35rem 0 0 1.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.todo-done .todo-title { text-decoration: line-through; opacity: 0.65; }
.todo-lock { font-size: 0.75rem; color: var(--gold); }
.note-row, .file-row { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.note-meta { font-size: 0.75rem; color: var(--text-muted); }
/* SMS-style project chat */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.chat-fullscreen #bottom-nav { display: none !important; }
body.chat-fullscreen #app { padding-bottom: 0; }

.chat-page {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - env(safe-area-inset-top));
  max-height: 100dvh;
  background: var(--bg);
  margin: calc(-1 * var(--page-pad, 1rem));
}

.chat-flash-wrap { padding: 0.5rem 1rem 0; flex-shrink: 0; }
.chat-flash-wrap .flash { margin: 0; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-info p {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 0.85rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--bg);
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem 1rem;
}

.chat-row { display: flex; width: 100%; }
.chat-row--mine { justify-content: flex-end; }
.chat-row--theirs { justify-content: flex-start; }

.chat-bubble {
  max-width: min(82%, 320px);
  padding: 0.45rem 0.65rem 0.35rem;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-row--mine .chat-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-row--theirs .chat-bubble {
  background: var(--bg-elevated);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-dim);
  margin-bottom: 0.15rem;
}

.chat-row--mine .chat-bubble-name { color: rgba(255, 255, 255, 0.85); }

.chat-bubble-text { white-space: pre-wrap; }

.chat-bubble-time {
  font-size: 0.65rem;
  opacity: 0.75;
  text-align: right;
  margin-top: 0.2rem;
}

.chat-row--theirs .chat-bubble-time { color: var(--text-muted); }

.chat-attach-img {
  display: block;
  margin: 0.15rem 0 0.25rem;
  border-radius: 12px;
  overflow: hidden;
  max-width: 220px;
}

.chat-attach-img img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
}

.chat-attach-file {
  display: inline-block;
  margin: 0.2rem 0;
  font-size: 0.85rem;
  text-decoration: underline;
}

.chat-row--mine .chat-attach-file { color: #fff; }

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-attach {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
}

.chat-attach:active { color: var(--accent); }

.chat-input-wrap {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 0.35rem 0.85rem;
}

.chat-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  line-height: 1.35;
  padding: 0.15rem 0;
}

.chat-input:focus { outline: none; }

.chat-pending {
  display: block;
  font-size: 0.72rem;
  color: var(--accent-dim);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.chat-send:disabled { opacity: 0.5; cursor: wait; }

.workspace-chat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0;
  text-decoration: none;
  color: inherit;
}

.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@media (min-width: 520px) {
  .theme-preset-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 720px) {
  .theme-preset-grid { grid-template-columns: repeat(5, 1fr); }
}

.theme-preset-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  color: var(--text);
  text-align: center;
}

.theme-preset-card:hover,
.theme-preset-card:focus {
  border-color: var(--accent);
  outline: none;
}

.theme-preset-swatch {
  display: block;
  height: 36px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.theme-preset-hint {
  font-size: 0.82rem;
  color: var(--accent-dim);
  margin: 0 0 1rem;
}

@media (min-width: 768px) {
  .modal-backdrop { align-items: center; padding: 1rem; }
  .modal-sheet { border-radius: 16px; max-height: 85vh; }
}

/* Hub rows — matches client portal layout */
.admin-hub-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
}

.admin-hub-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.95rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.admin-hub-row:hover,
.admin-hub-row:focus {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  outline: none;
}

.admin-hub-row--alert {
  border-color: rgba(212, 168, 83, 0.4);
}

.admin-hub-row--alert:hover,
.admin-hub-row--alert:focus {
  border-color: rgba(212, 168, 83, 0.65);
}

.admin-hub-row--alert .admin-hub-icon {
  background: var(--gold-muted);
  color: var(--gold);
}

.admin-home-new-project {
  margin-top: 0.25rem;
}

.admin-hub-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-hub-icon svg {
  width: 22px;
  height: 22px;
}

.admin-hub-icon--blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.admin-hub-icon--green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.admin-hub-icon--yellow { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.admin-hub-icon--red { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.admin-hub-icon--teal { background: rgba(45, 212, 191, 0.15); color: #2dd4bf; }
.admin-hub-icon--purple { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
.admin-hub-icon--cyan { background: rgba(34, 211, 238, 0.15); color: #22d3ee; }
.admin-hub-icon--gold { background: var(--accent-muted); color: var(--accent); }

.admin-hub-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.admin-hub-title {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.25;
}

.admin-hub-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.admin-hub-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.admin-hub-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.admin-hub-chevron {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
}

.admin-home-intro {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.admin-section-label {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.admin-project-header {
  margin-bottom: 1rem;
}

.admin-project-header .status {
  margin-bottom: 0.35rem;
}

.admin-project-brief {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.admin-project-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem 0 0.5rem;
  text-align: center;
}

.admin-project-brand-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
}

.admin-project-brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-project-home {
  padding-bottom: 0.5rem;
}

.admin-project-client-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.85rem;
}

.admin-project-client-chip-label {
  color: var(--text-muted);
}

.admin-project-client-chip-label strong {
  color: var(--text);
}

.project-customer-modes label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  cursor: pointer;
}

.admin-sub-panel {
  padding-bottom: 1rem;
}

.admin-sub-back {
  margin-bottom: 0.85rem;
}

.admin-sub-panel .workspace-panel {
  margin-bottom: 0.75rem;
}

.signup-via {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-muted);
  color: var(--accent);
  text-transform: capitalize;
}

.stats-grid .stat-card strong {
  color: var(--text);
}

.stat-card--link:hover strong,
.stat-card--link:focus strong {
  color: var(--accent);
}

.list-row-title {
  font-weight: 600;
  color: var(--text);
}

.list-row-title.gold { color: var(--accent); }
.list-row-title.purple { color: var(--purple); }
.list-row-title.cyan { color: var(--cyan); }

.badge {
  border-color: var(--border-strong);
  color: var(--text);
}

.workspace-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.feature-list .feature-row,
.todo-list .todo-row {
  border-bottom-color: var(--border);
}

.note-row, .file-row {
  border-bottom-color: var(--border);
}

/* Admin home — gold dashboard (Larkfield-style) */
body.admin-body .app-brand {
  color: #ffffff;
}

body.admin-body .btn-gold {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: var(--btn-on-accent);
  font-weight: 600;
}

body.admin-body .nav-item.active {
  color: var(--gold);
}

body.admin-body .nav-item.active svg {
  stroke: var(--gold);
}

body.admin-body .nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  background: var(--gold);
  border-radius: 1px;
}

body.admin-body .nav-item.active {
  position: relative;
}

.admin-home-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.admin-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 4.75rem;
  padding: 0.85rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid rgba(212, 168, 83, 0.28);
  border-radius: 12px;
  cursor: default;
  font: inherit;
  color: inherit;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

button.admin-stat-card {
  cursor: pointer;
}

button.admin-stat-card:hover,
button.admin-stat-card:focus {
  border-color: rgba(212, 168, 83, 0.55);
  background: var(--bg-card-hover);
  outline: none;
}

.admin-stat-card--highlight {
  border-color: rgba(212, 168, 83, 0.55);
  box-shadow: 0 0 0 1px rgba(212, 168, 83, 0.08);
}

.admin-stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--gold);
}

.admin-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* Server health (More → admin only) */
.health-page .page-title {
  margin-bottom: 0;
}

.health-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.health-updated {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.health-overall {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.15rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.92rem;
}

.health-overall-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-overall--ok .health-overall-dot { background: #34d399; }
.health-overall--warn .health-overall-dot { background: #fbbf24; }
.health-overall--bad .health-overall-dot { background: #f87171; }

.health-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.health-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 5.5rem;
  padding: 0.85rem 0.55rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: center;
}

.health-stat--ok { border-color: rgba(52, 211, 153, 0.25); }
.health-stat--warn { border-color: rgba(251, 191, 36, 0.35); }
.health-stat--bad { border-color: rgba(248, 113, 113, 0.35); }

.health-stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--gold);
}

.health-stat-value--text {
  font-size: 0.92rem;
  line-height: 1.25;
}

.health-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
}

.health-stat-sub {
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--text-muted);
  min-height: 1rem;
}

.health-note,
.health-section-note {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.health-section-note {
  margin: 0.65rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.health-section {
  margin-bottom: 0.85rem;
}

.health-section h3 {
  margin-bottom: 0.65rem;
}

.health-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
}

.health-row:last-child {
  border-bottom: none;
}

.health-row-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.health-row-value {
  text-align: right;
  word-break: break-word;
  max-width: 62%;
}

.health-row--ok .health-row-value { color: var(--text); }
.health-row--warn .health-row-value { color: #fbbf24; }
.health-row--bad .health-row-value { color: #f87171; }

.health-system-row {
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.health-system-row:last-of-type {
  border-bottom: none;
}

.health-system-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.health-system-label {
  font-weight: 600;
  color: var(--text);
}

.health-system-value {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
}

.health-system-row--warn .health-system-value {
  color: #fbbf24;
}

.health-system-bar {
  margin-top: 0.35rem;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.health-system-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.85), rgba(56, 189, 248, 0.75));
}

.health-system-path {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.75;
}

.admin-home-section {
  margin-bottom: 1.35rem;
  scroll-margin-top: 1rem;
}

.admin-home-section-title {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.admin-home-empty {
  margin: 0;
  padding: 0.85rem 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.admin-submitted-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.admin-submitted-card {
  background: var(--bg-card);
  border: 1px solid rgba(212, 168, 83, 0.22);
  border-radius: 14px;
  overflow: hidden;
}

.admin-submitted-head {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.admin-submitted-head:hover,
.admin-submitted-head:focus {
  background: var(--bg-card-hover);
  outline: none;
}

.admin-submitted-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
}

.admin-submitted-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-submitted-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 1rem 0.85rem;
}

.admin-submitted-actions .btn {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  font-size: 0.78rem;
}

.admin-hub-icon--gold {
  background: var(--gold-muted);
  color: var(--gold);
}
