.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: 0.35rem;
}

.auth-card__lead {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.auth-form .form-group {
  margin-bottom: 1rem;
}

.auth-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.auth-form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.auth-form input:focus {
  outline: 2px solid rgba(180, 83, 9, 0.35);
  border-color: var(--accent);
}

.auth-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.auth-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.auth-form .btn {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-switch {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-free-badge {
  display: inline-block;
  background: #ecfdf5;
  color: #166534;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

/* Dashboard */
.dash-layout {
  padding: 2.5rem 0 3rem;
  min-height: 100vh;
}

.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dash-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
}

.dash-header__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dash-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  align-items: start;
}

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

.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.dash-panel__head {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-list {
  list-style: none;
}

.customer-list-item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}

.customer-list-item .customer-drop {
  flex: 1;
  min-width: 0;
}

.dash-list > li > button:not(.customer-delete-btn),
.dash-list > li > a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.7rem 1rem;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.customer-list-item .customer-drop {
  border-bottom: none;
}

.customer-delete-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  padding: 0;
  margin: 0;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1;
  color: #a8a29e;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.customer-delete-btn:hover,
.customer-delete-btn:focus-visible {
  background: #fef2f2;
  color: #b91c1c;
  outline: none;
}

.dash-list > li > button:not(.customer-delete-btn):hover,
.dash-list > li > a:hover {
  background: #faf8f4;
}

.dash-list button.active {
  background: #fff7ed;
  color: var(--accent);
  font-weight: 600;
}

.estimate-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.65rem 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.estimate-row__spacer {
  width: 1.25rem;
}

.estimate-row__main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.estimate-row__actions--primary {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.estimate-drag-handle,
.estimate-row__spacer {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  margin-top: 0.15rem;
}

.estimate-row__controls {
  grid-column: 2 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 1rem;
  padding-top: 0.65rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--border);
}

.estimate-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 9rem;
  min-width: 0;
  max-width: 14rem;
}

.estimate-field--status {
  flex: 0 1 11rem;
  max-width: 11rem;
}

.estimate-field__label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.estimate-row.is-dragging {
  opacity: 0.45;
}

.estimate-drag-handle {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  user-select: none;
  opacity: 0.55;
  cursor: grab;
  padding: 0.25rem;
}

.estimate-drag-handle:active {
  cursor: grabbing;
}

.estimate-row--draggable:hover .estimate-drag-handle {
  opacity: 1;
}

.estimate-customer-select {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

.estimate-customer-select:focus {
  outline: 2px solid rgba(180, 83, 9, 0.35);
  border-color: var(--accent);
}

.customer-drop.drop-target {
  background: #fff7ed !important;
  color: var(--accent) !important;
  font-weight: 600;
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.drag-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  align-self: center;
}

.dash-filters {
  align-items: center;
}

.estimate-row__actions--secondary {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-left: auto;
  align-self: flex-end;
}

@media (max-width: 900px) {
  .estimate-row {
    grid-template-columns: 1fr auto;
  }

  .estimate-drag-handle,
  .estimate-row__spacer {
    display: none;
  }

  .estimate-row__main {
    grid-column: 1;
  }

  .estimate-row__actions--primary {
    grid-column: 2;
  }

  .estimate-row__controls {
    grid-column: 1 / -1;
  }

  .estimate-row__actions--secondary {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }
}

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

  .estimate-row__main,
  .estimate-row__actions--primary {
    grid-column: 1;
  }

  .estimate-row__actions--primary {
    justify-self: start;
    margin-top: 0.35rem;
  }

  .estimate-field,
  .estimate-field--status {
    max-width: none;
    flex: 1 1 100%;
  }
}

.estimate-row__title {
  font-weight: 600;
  font-size: 0.95rem;
}

.estimate-row__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.estimate-sent-track {
  font-size: 0.78rem;
  color: var(--accent);
  margin-top: 0.35rem;
  font-weight: 600;
}

.estimate-sent-track--expired {
  color: #b45309;
}

.status-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge--draft { background: #f3f4f6; color: #4b5563; }
.status-badge--sent { background: #dbeafe; color: #1d4ed8; }
.status-badge--awaiting_signature { background: #fef3c7; color: #b45309; }
.status-badge--finalized { background: #d1fae5; color: #047857; }

.estimate-row__actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.estimate-row__actions .btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
}

.estimate-status-select {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  width: 100%;
  cursor: pointer;
}

.estimate-status-select:focus {
  outline: 2px solid rgba(180, 83, 9, 0.35);
  border-color: var(--accent);
}

.dash-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dash-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.dash-filters select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.user-dropdown {
  position: relative;
}

.user-dropdown__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem 0.35rem 0.4rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  max-width: 15rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.user-dropdown__toggle:hover {
  border-color: var(--text-muted);
  box-shadow: var(--shadow);
}

.user-dropdown__toggle svg {
  flex-shrink: 0;
  opacity: 0.55;
}

.user-dropdown__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-dropdown__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.user-dropdown__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 13.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  z-index: 200;
}

.user-dropdown__section + .user-dropdown__section {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.user-dropdown__links a,
.user-dropdown__menu a,
.user-dropdown__menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}

.user-dropdown__links a:hover,
.user-dropdown__menu a:hover {
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
}

.user-dropdown__cta {
  display: block;
  text-align: center !important;
  font-weight: 600 !important;
  color: #fff !important;
  background: var(--accent) !important;
}

.user-dropdown__cta:hover {
  background: var(--accent-hover) !important;
  color: #fff !important;
}

.user-dropdown__signout {
  color: #991b1b !important;
}

.user-dropdown__signout:hover {
  color: #7f1d1d !important;
  background: #fef2f2 !important;
}

/* Admin */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.admin-stat strong {
  display: block;
  font-size: 1.5rem;
  color: var(--accent);
}

.admin-stat span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.feedback-admin-item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.feedback-admin-delete {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  color: #a8a29e;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.feedback-admin-delete:hover,
.feedback-admin-delete:focus-visible {
  background: #fef2f2;
  color: #b91c1c;
  outline: none;
}

.feedback-admin-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.feedback-admin-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.feedback-admin-item__date {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.feedback-admin-item__message {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0;
  white-space: pre-wrap;
}

.feedback-admin-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #faf9f7;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
  line-height: 1.5;
}

.account-danger-zone {
  border-color: #fecaca;
  background: #fffbfb;
}

.account-danger-zone__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #991b1b;
}

.account-danger-zone__text {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: 1px solid #dc2626;
}

.btn-danger:hover,
.btn-danger:focus-visible {
  background: #b91c1c;
  border-color: #b91c1c;
  outline: none;
}

.btn-danger:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.app-save-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.app-save-bar select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.app-save-bar__status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}