:root {
  --bg-main: #f5f5f7;
  --bg-soft: #fafafb;
  --surface: #ffffff;
  --text-primary: #111111;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-light: #e5e7eb;
  --border-soft: #eceef2;
  --gold-primary: #c9a227;
  --gold-light: #e5c76b;
  --gold-deep: #a8831f;
  --action-primary: #0f172a;
  --action-primary-hover: #111827;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --radius-input: 16px;
  --radius-button: 18px;
  --radius-card: 24px;
  --radius-panel: 24px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.06);
  --font-fa: Vazirmatn, IRANSans, "Segoe UI", Tahoma, sans-serif;
  --font-en: Manrope, Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-main);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-fa);
  font-size: 15px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
p {
  margin: 0;
}

.auth-shell,
.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.card,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
}

.auth-card {
  width: min(100%, 420px);
  padding: 24px;
}

.auth-card h1,
.topbar h1 {
  font-size: 28px;
  font-weight: 800;
}

.muted {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  color: var(--gold-deep);
  font-family: var(--font-en);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-heading h2 {
  font-size: 20px;
  font-weight: 800;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-input);
  background: var(--bg-soft);
  color: var(--text-primary);
  padding: 13px 16px;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}

.field textarea {
  min-height: 132px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  background: #fff;
  border-color: rgba(201, 162, 39, 0.72);
  box-shadow: 0 0 0 4px rgba(201, 162, 39, 0.12);
}

.btn {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-button);
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 180ms ease, background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--action-primary);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.btn-primary:hover {
  background: var(--action-primary-hover);
}

.btn-secondary {
  background: #f0f2f5;
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-small {
  min-height: 42px;
  border-radius: 15px;
  padding: 0 14px;
  font-size: 13px;
}

.btn-wide {
  width: 100%;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.alert {
  border-radius: 18px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border-soft);
  font-size: 14px;
  font-weight: 700;
}

.alert-success {
  color: #15803d;
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.2);
}

.alert-warning {
  color: #92400e;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.22);
}

.alert-error {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.admin-stats {
  grid-template-columns: 1fr;
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-en);
  font-size: 30px;
  line-height: 1.2;
}

.primary-form-card,
.quiet-list-card,
.toolbar-card,
.customers-card,
.composer-card,
.settings-card {
  padding: 20px;
  margin-bottom: 16px;
}

.quiet-list-card {
  box-shadow: var(--shadow-sm);
}

.customer-list {
  display: grid;
  gap: 10px;
}

.customer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.customer-row:last-child {
  border-bottom: 0;
}

.customer-row strong,
.mobile-customer-card strong {
  display: block;
  font-size: 15px;
}

.customer-row span,
.customer-row time,
.mobile-customer-card small,
.mobile-customer-card time {
  color: var(--text-secondary);
  font-family: var(--font-en);
  font-size: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  margin-bottom: 16px;
  background: #eceef2;
  border-radius: 20px;
}

.tabs a {
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--text-secondary);
  font-weight: 800;
  transition: background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

.tabs a.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.search-form {
  display: grid;
  gap: 12px;
}

.select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--action-primary);
  cursor: pointer;
}

.table-shell {
  display: none;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: right;
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  font-weight: 700;
}

.mobile-customer-list {
  display: grid;
  gap: 10px;
}

.mobile-customer-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  background: var(--bg-soft);
  cursor: pointer;
}

.mobile-customer-card time {
  grid-column: 2;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state strong {
  color: var(--text-primary);
  font-size: 17px;
}

.composer-card {
  position: sticky;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 5;
}

.action-row {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.note-box {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-radius: 18px;
  background: rgba(201, 162, 39, 0.08);
}

.note-box strong {
  font-size: 14px;
}

.note-box span {
  color: var(--text-secondary);
  font-size: 13px;
}

@media (max-width: 420px) {
  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions .btn {
    flex: 1;
  }

}

@media (min-width: 680px) {
  .auth-shell,
  .app-shell {
    padding: 32px 24px 48px;
  }

  .form-grid,
  .search-form,
  .action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
  }

  .admin-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .table-shell {
    display: block;
  }

  .mobile-customer-list {
    display: none;
  }

  .composer-card {
    position: static;
  }
}

@media (min-width: 980px) {
  .app-shell {
    padding-top: 40px;
  }

  .register-page .app-shell {
    max-width: 760px;
  }

  .admin-shell {
    max-width: 1240px;
  }

  .primary-form-card,
  .quiet-list-card,
  .toolbar-card,
  .customers-card,
  .composer-card,
  .settings-card {
    padding: 24px;
  }
}
