:root {
  --bg: #F2F4F7;
  --bg-deep: #E5E9EF;
  --card: #FFFFFF;
  --line: rgba(10, 37, 64, 0.1);
  --line-strong: rgba(10, 37, 64, 0.16);
  --text: #333333;
  --muted: #6c7a89;
  --brand: #0A2540;
  --accent: #199B7E;
  --accent-hover: #148d70;
  --accent-subtle: rgba(25, 155, 126, 0.1);
  --accent-ring: rgba(25, 155, 126, 0.18);
  --danger: #e67a70;
  --shadow: 0 2px 12px rgba(10, 37, 64, 0.07);
  --shadow-lg: 0 8px 40px rgba(10, 37, 64, 0.1);
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 8px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}

/* ─── DARK THEME ──────────────────────────────── */

[data-theme="dark"] {
  --bg: #0e1824;
  --bg-deep: #090f18;
  --card: #172030;
  --line: rgba(138, 215, 192, 0.09);
  --line-strong: rgba(138, 215, 192, 0.15);
  --text: #dce4ed;
  --muted: #7a95aa;
  --brand: #e2eaf2;
  --accent: #1aad8c;
  --accent-hover: #159d7e;
  --accent-subtle: rgba(26, 173, 140, 0.14);
  --accent-ring: rgba(26, 173, 140, 0.22);
  --danger: #f09080;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 16px;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  text-align: right;
  background-color: var(--bg);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* ─── HEADER ──────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.75rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 0.05rem;
}

.brand-copy strong {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}

.brand-copy span {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.2;
}

.site-nav {
  display: flex;
  gap: 0.1rem;
  flex-wrap: wrap;
}

.site-nav a {
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 130ms, color 130ms;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: var(--bg);
  color: var(--brand);
}

/* ─── PAGE SHELL ──────────────────────────────── */

.page-shell {
  width: 100%;
  padding: 2.5rem 1rem;
  min-height: calc(100vh - 3.9rem);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

main.page-shell:has(> .admin-shell) {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 1.25rem 20px 2rem;
}

/* ─── SHELLS ──────────────────────────────────── */

.auth-shell {
  width: 100%;
  max-width: 420px;
}

.auth-copy {
  display: none;
}

.panel-shell {
  width: 100%;
}

/* ─── CARDS ───────────────────────────────────── */

.auth-card,
.panel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2.25rem 2rem;
}

.panel-card {
  max-width: 620px;
  min-height: 380px;
  margin: 0 auto;
  padding: 2.75rem 3rem;
  display: flex;
  flex-direction: column;
}

/* ─── CARD BRAND ──────────────────────────────── */

.card-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.card-mark {
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  object-fit: contain;
}

.card-brand-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand);
}

/* ─── AUTH HEADER ─────────────────────────────── */

.auth-header {
  margin-bottom: 1.5rem;
}

.auth-header h2 {
  margin: 0 0 0.3rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.3;
}

.auth-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ─── PANEL CARD TEXT ─────────────────────────── */

.panel-card h1 {
  margin: 0 0 0.6rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
}

.lede {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.7;
  text-align: center;
  white-space: nowrap;
}

/* ─── FORMS ───────────────────────────────────── */

.auth-form,
.stack {
  display: grid;
  gap: 1rem;
}

.stack.horizontal {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.panel-card > .stack.horizontal {
  margin-top: auto;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field > span:first-child {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.875rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 130ms, box-shadow 130ms, background 130ms;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: var(--card);
}

/* ─── CHECK ROW ───────────────────────────────── */

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ─── BUTTONS ─────────────────────────────────── */

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 130ms;
}

.primary-action {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.primary-action:hover {
  background: var(--accent-hover);
}

.inline-action {
  width: fit-content;
}

.secondary-action {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--line-strong);
}

.secondary-action:hover {
  background: var(--bg-deep);
}

/* ─── FOCUS RINGS ─────────────────────────────── */

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.primary-action:focus-visible,
.secondary-action:focus-visible,
.site-nav a:focus-visible,
.choice-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── HELPER LINKS ────────────────────────────── */

.helper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  justify-content: center;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--line);
}

.helper-links a {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.helper-links a:hover {
  text-decoration: underline;
}

/* ─── VALIDATION ──────────────────────────────── */

.validation-summary,
.field-error {
  color: var(--danger);
  font-size: 0.82rem;
}

/* ─── STATUS BANNER ───────────────────────────── */

.status-banner {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  background: var(--accent-subtle);
  border: 1px solid rgba(25, 155, 126, 0.22);
  color: #0c6b55;
  font-size: 0.875rem;
  line-height: 1.6;
}

[data-theme="dark"] .status-banner {
  color: var(--accent);
}

[data-theme="dark"] .brand-mark,
[data-theme="dark"] .card-mark {
  background: #ffffff;
  border-radius: 6px;
  padding: 2px;
}

/* ─── THEME TOGGLE ────────────────────────────── */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 130ms, color 130ms, border-color 130ms;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg);
  color: var(--brand);
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none;  }

[data-theme="dark"] .theme-toggle .icon-moon { display: none;  }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

/* ─── MICRO COPY ──────────────────────────────── */

.micro-copy,
.request-id,
.identity-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ─── CHOICE GRID (Register) ──────────────────── */

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}

.choice-card {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--line-strong);
  background: var(--bg);
  transition: all 130ms;
  text-align: right;
}

.choice-card strong {
  font-size: 0.9rem;
  color: var(--brand);
  font-weight: 700;
}

.choice-card span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.choice-card:hover,
.choice-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

/* ─── IDENTITY CARD ───────────────────────────── */

.identity-card {
  display: grid;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--line);
  margin-bottom: 1rem;
}

.identity-label {
  color: var(--muted);
  font-size: 0.78rem;
}

/* ─── RESPONSIVE ──────────────────────────────── */

@media (max-width: 600px) {
  .site-header {
    padding: 0.75rem 1rem;
    align-items: flex-start;
    flex-direction: column;
    gap: 0.6rem;
  }

  .page-shell {
    padding: 1.5rem 0.875rem;
    align-items: flex-start;
  }

  .auth-card,
  .panel-card {
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.25rem;
    min-height: 0;
  }

  .panel-card h1,
  .panel-card .lede {
    white-space: normal;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }
}

.admin-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  direction: rtl;
  display: grid;
  gap: 1.25rem;
}

.admin-hero,
.admin-page-header,
.filter-card,
.editor-card,
.data-card,
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.admin-hero,
.admin-page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.admin-hero > :first-child,
.admin-page-header > :first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.admin-actions {
  min-width: 0;
  flex: 0 1 auto;
}

.admin-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.admin-shell h1,
.editor-card h2,
.data-card h2 {
  margin: 0 0 0.75rem;
  color: var(--brand);
}

.admin-actions,
.split-grid,
.stats-grid,
.check-grid {
  display: grid;
  gap: 0.75rem;
}

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

.stat-card strong {
  font-size: 1.6rem;
  color: var(--brand);
}

.stat-card span {
  display: block;
}

.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

.split-grid {
  grid-template-columns: 1.4fr 1fr;
}

.filter-card {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
}

.filter-card .field {
  min-width: 240px;
  flex: 1 1 240px;
}

.filter-card .field-compact {
  min-width: 140px;
  flex: 0 0 140px;
}

.editor-card,
.data-card {
  display: grid;
  gap: 0.9rem;
}

.check-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 0.85rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: right;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.table-subtext {
  color: var(--muted);
  font-size: 0.8rem;
}

.table-toolbar,
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.table-summary {
  color: var(--muted);
  font-size: 0.84rem;
}

.pagination-links {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 1.4rem 0.75rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  margin-left: 0.35rem;
  background: var(--bg);
}

.status-ok {
  color: #0c6b55;
  background: var(--accent-subtle);
}

.status-warn {
  color: #8a4b09;
  background: rgba(230, 163, 70, 0.16);
}

.status-muted {
  color: var(--muted);
}

.detail-list {
  display: grid;
  gap: 0.6rem;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.detail-list span {
  color: var(--muted);
}

.simple-list {
  margin: 0;
  padding-right: 1rem;
}

@media (max-width: 900px) {
  .stats-grid,
  .split-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .admin-hero,
  .admin-page-header {
    flex-direction: column;
  }
}
