:root {
  --color-primary: #ce0f69;
  --color-secondary-teal: #009ca6;
  --color-secondary-purple: #68478d;
  --color-tertiary-gold: #ffb81c;
  --color-tertiary-black: #000000;
}

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

/* Several elements below set `display` via a class of equal specificity
   to the UA [hidden] rule, which would otherwise silently win by source
   order and keep them visible while "hidden". Force it explicitly. */
[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f5f7;
  color: var(--color-tertiary-black);
}

a {
  color: inherit;
}

/* ---------------------------------------------------------------------
   App shell / nav
   --------------------------------------------------------------------- */

.app-shell {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-shell.narrow {
  max-width: 560px;
}

.nav-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border-radius: 16px;
  padding: 14px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: #f4f5f7;
  color: var(--color-tertiary-black);
}

.nav-link.active {
  color: var(--color-primary);
  background: rgba(206, 15, 105, 0.08);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-email {
  font-size: 0.8rem;
  color: #6b7280;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b7280;
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-logout:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */

.card {
  width: 100%;
  background: #ffffff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.card.accent {
  border-top: 6px solid transparent;
  border-image: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-secondary-teal),
    var(--color-secondary-purple),
    var(--color-tertiary-gold)
  );
  border-image-slice: 1;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  margin-bottom: 4px;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

h2 {
  font-size: 1.1rem;
}

.subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  line-height: 1.4;
}

.status {
  font-size: 0.9rem;
  color: #6b7280;
  text-align: center;
  padding: 40px 0;
}

.status.error {
  color: var(--color-primary);
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--color-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
  text-decoration: none;
}

.btn-primary:hover {
  box-shadow: 0 0 0 3px rgba(206, 15, 105, 0.12);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-tertiary-black);
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
  text-decoration: none;
}

.btn-secondary:hover {
  border-color: var(--color-primary);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-danger {
  color: var(--color-primary);
}

.btn-text {
  display: inline-block;
  padding: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
  text-decoration: none;
}

.btn-text:hover {
  color: var(--color-tertiary-black);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
  color: #6b7280;
  background: #f9fafb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
  background: rgba(206, 15, 105, 0.1);
  color: var(--color-primary);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

@media (max-width: 620px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.input-group {
  margin-bottom: 20px;
}

.input-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}

.field-hint {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 6px;
  line-height: 1.4;
}

.text-input,
.text-select,
textarea.text-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-tertiary-black);
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea.text-input {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.text-input:focus,
.text-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(206, 15, 105, 0.12);
}

.text-select {
  cursor: pointer;
}

.form-error {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
}

.form-success {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-secondary-teal);
}

.panel {
  padding: 18px;
  background: #f9fafb;
  border-radius: 10px;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.panel-hint {
  font-size: 0.85rem;
  color: #6b7280;
  line-height: 1.4;
  margin-bottom: 12px;
}

.panel label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.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;
}

/* ---------------------------------------------------------------------
   Auth gate
   --------------------------------------------------------------------- */

.auth-shell {
  width: 100%;
  max-width: 400px;
  margin: 40px auto;
}

/* ---------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-paid {
  color: var(--color-secondary-teal);
  background: rgba(0, 156, 166, 0.12);
}

.badge-unpaid {
  color: var(--color-tertiary-gold);
  background: rgba(255, 184, 28, 0.16);
}

.badge-overdue {
  color: var(--color-primary);
  background: rgba(206, 15, 105, 0.1);
}

.badge-toggle {
  border: none;
  cursor: pointer;
  font-family: inherit;
}

/* ---------------------------------------------------------------------
   Tables (invoice list, client list)
   --------------------------------------------------------------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
  padding: 0 14px 10px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid #f0f1f3;
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr.row-link {
  cursor: pointer;
  transition: background 0.15s ease;
}

.data-table tr.row-link:hover {
  background: #f9fafb;
}

.cell-strong {
  font-weight: 600;
}

.cell-muted {
  color: #6b7280;
}

.cell-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.cell-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #6b7280;
}

.empty-state p {
  font-size: 0.9rem;
  margin-top: 6px;
}

/* ---------------------------------------------------------------------
   Line items editor
   --------------------------------------------------------------------- */

.line-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line-item-row {
  display: grid;
  grid-template-columns: 1fr 80px 110px 100px 32px;
  gap: 8px;
  align-items: center;
}

.line-item-head {
  display: grid;
  grid-template-columns: 1fr 80px 110px 100px 32px;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
  padding: 0 2px;
}

@media (max-width: 620px) {
  .line-item-row,
  .line-item-head {
    grid-template-columns: 1fr;
  }
  .line-item-head {
    display: none;
  }
  .line-item-row {
    background: #f9fafb;
    border-radius: 10px;
    padding: 12px;
    gap: 8px;
  }
}

.line-item-total {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.line-item-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 1rem;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.line-item-remove:hover {
  background: rgba(206, 15, 105, 0.1);
  color: var(--color-primary);
}

.totals-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  margin-top: 10px;
}

.totals-row {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.9rem;
  width: 100%;
  max-width: 300px;
  justify-content: space-between;
}

.totals-row.total {
  font-size: 1.15rem;
  font-weight: 700;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.totals-row .vat-input {
  width: 90px;
  padding: 8px 10px;
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------
   Status toggle
   --------------------------------------------------------------------- */

.status-toggle {
  display: flex;
  gap: 8px;
}

.status-toggle button {
  flex: 1;
  padding: 12px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.status-toggle button.active[data-status="unpaid"] {
  color: var(--color-tertiary-gold);
  border-color: var(--color-tertiary-gold);
  background: rgba(255, 184, 28, 0.1);
}

.status-toggle button.active[data-status="paid"] {
  color: var(--color-secondary-teal);
  border-color: var(--color-secondary-teal);
  background: rgba(0, 156, 166, 0.1);
}

/* ---------------------------------------------------------------------
   Dashboard summary stats
   --------------------------------------------------------------------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

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

.stat-tile {
  background: #f9fafb;
  border-radius: 10px;
  padding: 16px 18px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
  margin-bottom: 6px;
}

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

.stat-value.warn {
  color: var(--color-primary);
}

/* ---------------------------------------------------------------------
   Misc
   --------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.divider {
  height: 1px;
  background: #f0f1f3;
  margin: 20px 0;
}

.powered-by a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #6b7280;
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.powered-by a:hover {
  color: var(--color-tertiary-black);
}

.powered-by-logo {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.powered-by strong {
  color: var(--color-primary);
  font-weight: 700;
}
