/* RASTA / RastaChoob adaptation of CHIDA Design System 2.
   A light, neutral operational theme with restrained green-gray accents. */

@font-face {
  font-family: "IRANYekanXFaNum";
  src: url("/assets/fonts/IRANYekanXVFaNumVF.woff2") format("woff2-variations");
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
}

:root {
  color-scheme: light;

  --bg-canvas: #f7f7f5;
  --bg-surface: #f3f4f2;
  --bg-raised: #ffffff;
  --bg-overlay: #ffffff;
  --bg-hover: #f0f2f0;
  --bg-active: #e8ece9;
  --bg-inset: #ffffff;
  --bg-sidebar: #ffffff;

  --text-strong: #1f2522;
  --text-primary: #303633;
  --text-secondary: #5d6662;
  --text-muted: #7c8581;
  --text-disabled: #a6ada9;
  --text-on-accent: #ffffff;

  --accent: #3b6258;
  --accent-hover: #31564d;
  --accent-active: #284a42;
  --accent-subtle: #edf3f1;
  --accent-hover-subtle: #e3ece9;
  --accent-border: #bed0ca;
  --accent-text: #345b51;
  --accent-focus: rgba(59, 98, 88, 0.12);

  --border-subtle: #e3e6e3;
  --border-default: #d4d9d5;
  --border-strong: #b9c1bc;
  --border-focus: var(--accent);

  --success: #3f715d;
  --success-surface: #eef6f2;
  --success-border: #cde1d7;
  --warning: #8a6426;
  --warning-surface: #faf5e9;
  --warning-border: #eadab9;
  --danger: #a14e49;
  --danger-surface: #fbefee;
  --danger-border: #e9c7c4;
  --info: #4b6b78;
  --info-surface: #eef3f5;
  --info-border: #ccdbe0;

  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(25, 31, 28, 0.04);
  --shadow-sm: 0 1px 3px rgba(25, 31, 28, 0.06);
  --shadow-md: 0 4px 12px rgba(25, 31, 28, 0.08);
  --shadow-lg: 0 10px 24px rgba(25, 31, 28, 0.10);
  --shadow-xl: 0 20px 48px rgba(25, 31, 28, 0.14);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.55);

  --font-sans: "IRANYekanXFaNum", Tahoma, ui-sans-serif, system-ui, sans-serif;
  --font-display: "IRANYekanXFaNum", Tahoma, ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IRANYekanXFaNum", Tahoma, ui-monospace, monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 30px;
  --text-3xl: 38px;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-black: 800;
  --lh-tight: 1.2;
  --lh-snug: 1.4;
  --lh-normal: 1.65;
  --lh-relaxed: 1.9;
  --ls-tight: -0.01em;

  --sidebar-width: 264px;
  --topbar-height: 56px;
  --content-max: 1180px;
  --reading-max: 720px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 280ms;
  --z-sticky: 100;
  --z-overlay: 800;
  --z-modal: 900;
  --z-toast: 1000;
  --overlay-scrim: rgba(25, 31, 28, 0.28);
  --ring: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--accent);

  /* Compatibility aliases for the existing operational markup. */
  --bg: var(--bg-canvas);
  --surface: var(--bg-raised);
  --surface-subtle: var(--bg-surface);
  --ink: var(--text-primary);
  --muted: var(--text-muted);
  --line: var(--border-subtle);
  --brand: var(--accent);
  --brand-strong: var(--accent-active);
  --brand-soft: var(--accent-subtle);
  --danger-soft: var(--danger-surface);
  --success-soft: var(--success-surface);
  --warning-soft: var(--warning-surface);
  --shadow: var(--shadow-lg);
  --radius: var(--radius-lg);
  --sidebar: var(--sidebar-width);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  min-height: 100%;
  direction: rtl;
  background: var(--bg-canvas);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  color: var(--text-primary);
  background: var(--bg-canvas);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font-family: inherit; }
button { color: inherit; }

::selection {
  color: var(--text-strong);
  background: var(--accent-border);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  background-clip: content-box;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.login-page {
  padding: var(--space-6);
  background: var(--bg-canvas);
}

.login-card {
  width: min(100%, 432px);
  padding: var(--space-8);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: none;
}

.brand-lockup { gap: var(--space-3); }

.brand-mark {
  width: 44px;
  height: 44px;
  color: var(--text-on-accent);
  background: var(--accent);
  border-radius: var(--radius-lg);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--fw-black);
  letter-spacing: var(--ls-tight);
}

.brand-name {
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--fw-black);
  letter-spacing: var(--ls-tight);
}

.brand-caption {
  margin-top: 0;
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.login-card h1 {
  margin: var(--space-8) 0 var(--space-1);
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
}

.login-card > p {
  margin: 0 0 var(--space-6);
  color: var(--text-muted);
}

.form-stack { gap: var(--space-4); }

.field {
  gap: 6px;
  min-width: 0;
}

.field label,
.field-label {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
}

.required {
  margin-inline-start: 3px;
  margin-right: 0;
  color: var(--danger);
}

.input,
.select,
.textarea {
  color: var(--text-primary);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.input,
.select {
  height: 48px;
  padding: 0 var(--space-3);
}

.select { color-scheme: light; }

.textarea {
  min-height: 104px;
  padding: 11px 13px;
  line-height: var(--lh-normal);
}

.input::placeholder,
.textarea::placeholder { color: var(--text-disabled); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--border-strong); }

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-focus);
}

.input-wrap .input { padding-left: 48px; }

.icon-button {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  background: transparent;
  border-radius: var(--radius-md);
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.icon-button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.input-wrap .icon-button { top: 4px; left: 4px; }

.btn {
  min-height: 48px;
  gap: var(--space-2);
  padding: 0 var(--space-6);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  transition:
    transform var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
  user-select: none;
}

.btn-primary {
  color: var(--text-on-accent);
  background: var(--accent);
  border-color: transparent;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }

.btn-secondary {
  color: var(--text-primary);
  background: var(--bg-raised);
  border-color: var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-soft {
  color: var(--text-primary);
  background: var(--bg-raised);
  border-color: var(--border-default);
}

.btn-soft:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger-soft {
  color: var(--danger);
  background: transparent;
  border-color: var(--danger-border);
}

.btn-danger-soft:hover:not(:disabled) { background: var(--danger-surface); }

.login-submit { margin-top: var(--space-2); }

.form-error {
  gap: var(--space-2);
  padding: var(--space-3);
  color: var(--danger);
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.app-shell {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--bg-canvas);
}

.sidebar {
  z-index: var(--z-sticky);
  padding: 14px;
  gap: 6px;
  color: var(--text-primary);
  background: var(--bg-sidebar);
  border-inline-start: 1px solid var(--border-subtle);
}

.sidebar .brand-lockup { padding: 6px 6px var(--space-3); }

.sidebar .brand-mark {
  color: var(--text-on-accent);
  background: var(--accent);
}

.sidebar .brand-caption { color: var(--text-muted); }

.sidebar-nav {
  gap: 2px;
  margin-top: var(--space-2);
}

.nav-button {
  min-height: 38px;
  gap: 10px;
  padding: 0 var(--space-3);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: var(--fw-regular);
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.nav-button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-button.active {
  color: var(--text-strong);
  background: var(--bg-active);
  font-weight: var(--fw-semibold);
}

.sidebar-user {
  margin-top: auto;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--border-subtle);
}

.user-row { gap: 10px; }

.avatar {
  width: 36px;
  height: 36px;
  overflow: hidden;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
}

.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.profile-avatar-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
}

.profile-avatar-button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.user-copy strong {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
}

.user-copy span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.sidebar .icon-button { color: var(--text-muted); }

.sidebar .icon-button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.main {
  min-width: 0;
  padding: 0 0 var(--space-12);
  background: var(--bg-canvas);
}

.topbar {
  min-height: var(--topbar-height);
  height: var(--topbar-height);
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
}

.page-title {
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
}

.page-subtitle {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.header-date {
  gap: 6px;
  padding: 4px var(--space-2);
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-feature-settings: "tnum" 1;
}

.content {
  width: min(calc(100% - 48px), var(--content-max));
  margin: 28px auto 0;
}

.card {
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.card-header {
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.card-header h2 {
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}

.card-header p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.card-body { padding: var(--space-5); }
.lead-form { gap: var(--space-6); }
.form-grid { gap: var(--space-5); }

.request-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.check-card {
  min-height: 76px;
  gap: var(--space-3);
  padding: var(--space-3);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition:
    border-color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.check-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.check-card:has(input:checked) {
  color: var(--text-strong);
  background: var(--bg-raised);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.check-visual {
  width: 20px;
  height: 20px;
  color: transparent;
  background: var(--bg-inset);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
}

.check-card:has(input:checked) .check-visual {
  color: var(--text-on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.check-visual .icon { width: 13px; height: 13px; stroke-width: 3.5; }

.check-copy strong {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
}

.check-copy span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.form-actions {
  gap: var(--space-2);
  padding-top: var(--space-1);
}

.form-actions .btn-primary { min-width: 184px; }

.hint-row {
  gap: 6px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.stats-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  width: 100%;
  min-width: 0;
  gap: var(--space-3);
  padding: var(--space-5);
  color: inherit;
  font: inherit;
  text-align: right;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  appearance: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.stat-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stat-card:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.stat-card.is-active {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.stat-card.is-active .stat-icon {
  color: var(--accent-text);
  background: var(--bg-raised);
  border-color: var(--accent-border);
}

.stat-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.stat-copy span {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.stat-copy strong {
  margin-top: 0;
  color: var(--text-strong);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  line-height: 1.05;
  font-feature-settings: "tnum" 1;
}

.toolbar {
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.search-field .input { padding-right: 40px; }

.search-field .icon {
  right: var(--space-3);
  top: 15px;
  color: var(--text-muted);
}

.export-row { gap: var(--space-2); }

.export-row .btn {
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.table-wrap {
  scrollbar-color: var(--border-strong) transparent;
}

table { color: var(--text-primary); }

th,
td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

th {
  color: var(--text-muted);
  background: var(--bg-surface);
  font-size: var(--text-2xs);
  font-weight: var(--fw-semibold);
}

td { font-size: var(--text-xs); }
tbody tr { transition: background var(--dur-fast) var(--ease-out); }
tbody tr:hover { background: var(--bg-hover); }

.lead-row { cursor: pointer; }

.lead-row:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
  background: var(--bg-hover);
}

.primary-cell strong {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
}

.primary-cell span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
  font-feature-settings: "tnum" 1;
}

.badge-row { gap: var(--space-1); }

.badge {
  min-height: 24px;
  padding: 2px var(--space-2);
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--fw-semibold);
}

.badge-agency {
  color: var(--warning);
  background: var(--warning-surface);
  border-color: var(--warning-border);
}

.badge-expert {
  color: var(--success);
  background: var(--success-surface);
  border-color: var(--success-border);
}

.badge-contractor {
  color: var(--info);
  background: var(--info-surface);
  border-color: var(--info-border);
}

.badge-admin {
  color: var(--info);
  background: var(--info-surface);
  border-color: var(--info-border);
}

.badge-inactive {
  color: var(--danger);
  background: var(--danger-surface);
  border-color: var(--danger-border);
}

.table-empty,
.loading-state {
  min-height: 280px;
  padding: var(--space-8);
  color: var(--text-muted);
}

.empty-visual {
  width: 52px;
  height: 52px;
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.pagination {
  min-height: 64px;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.pagination-copy {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.pagination-actions { gap: 6px; }

.pagination-actions .btn {
  min-height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.split-layout { gap: 18px; }
.sticky-card { top: var(--space-6); }

.user-list-item {
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.user-list-item .avatar {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.user-list-copy strong {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
}

.user-list-copy span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.user-actions { gap: var(--space-1); }

.profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: var(--space-5);
  align-items: start;
}

.profile-photo-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.avatar-xl {
  width: 120px;
  height: 120px;
  font-size: var(--text-2xl);
  box-shadow: var(--shadow-sm);
}

.profile-photo-copy {
  display: grid;
  gap: 2px;
  margin-top: var(--space-4);
}

.profile-photo-copy strong {
  color: var(--text-strong);
  font-size: var(--text-md);
  font-weight: var(--fw-bold);
}

.profile-photo-copy span,
.field-help {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.profile-photo-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.profile-photo-body .form-error {
  width: 100%;
  margin-top: var(--space-4);
  text-align: right;
}

.profile-photo-body .field-help {
  margin: var(--space-3) 0 0;
}

.input[readonly] {
  color: var(--text-secondary);
  background: var(--bg-surface);
  cursor: default;
}

.profile-form-actions { margin-top: var(--space-2); }

.modal-backdrop {
  z-index: var(--z-overlay);
  padding: var(--space-5);
  background: var(--overlay-scrim);
  backdrop-filter: blur(3px);
  animation: fade-in var(--dur-fast) var(--ease-out);
}

.modal {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  animation: modal-in var(--dur-base) var(--ease-out);
}

.modal-header {
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  color: var(--text-strong);
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
}

.modal-header p {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.modal-body { padding: var(--space-5); }

.modal-actions {
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.duplicate-summary {
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.summary-item {
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.summary-item span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.summary-item strong {
  color: var(--text-primary);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
}

.record-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.record-detail-item {
  min-width: 0;
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.record-detail-item > span {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.record-detail-item > strong {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  overflow-wrap: anywhere;
}

.record-detail-wide { grid-column: 1 / -1; }
.record-detail-notes > strong { white-space: pre-wrap; }

.alert-icon {
  color: var(--warning);
  background: var(--warning-surface);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-lg);
}

.toast-region {
  z-index: var(--z-toast);
  left: var(--space-5);
  bottom: var(--space-5);
  gap: var(--space-2);
}

.toast {
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  animation: toast-in var(--dur-base) var(--ease-out);
}

.toast.success .toast-icon {
  color: var(--success);
  background: var(--success-surface);
}

.toast.error .toast-icon {
  color: var(--danger);
  background: var(--danger-surface);
}

.toast-icon {
  border: 1px solid currentColor;
  border-radius: var(--radius-md);
}

.toast-copy strong {
  color: var(--text-strong);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
}

.toast-copy span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.spinner {
  border-color: color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
}

.btn-secondary .spinner,
.btn-soft .spinner {
  border-color: var(--border-default);
  border-top-color: currentColor;
}

@media (max-width: 1020px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    padding: var(--space-2) var(--space-3);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-2);
    border-inline-start: 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .sidebar .brand-lockup { padding: 0; }
  .sidebar .brand-mark { width: 40px; height: 40px; }

  .sidebar-nav {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: 0;
    overflow-x: auto;
  }

  .nav-button {
    width: auto;
    min-height: 40px;
    padding: 0 var(--space-3);
    gap: 6px;
    font-size: var(--text-xs);
  }

  .sidebar-user {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sidebar-user .profile-avatar-button { display: none; }

  .main { padding: 0 0 var(--space-8); }

  .topbar {
    min-height: 72px;
    height: 72px;
    padding: 0 var(--space-4);
  }

  .content {
    width: calc(100% - 32px);
    margin-top: var(--space-5);
  }

  .form-grid,
  .request-options,
  .split-layout,
  .profile-layout { grid-template-columns: 1fr; }

  .field-span-2 { grid-column: auto; }
  .sticky-card { position: static; }
  .toolbar { grid-template-columns: 1fr; }
  .card-header, .card-body { padding-inline: var(--space-4); }
}

@media (max-width: 480px) {
  .login-page { padding: var(--space-4); }
  .login-card { padding: var(--space-6) var(--space-5); }
  .page-title { font-size: var(--text-base); }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }

  .stat-card {
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .stat-icon { width: 36px; height: 36px; }
  .stat-copy strong { font-size: var(--text-lg); }

  .form-actions,
  .modal-actions { flex-direction: column; }

  .form-actions .btn,
  .modal-actions .btn { width: 100%; }

  .duplicate-summary { grid-template-columns: 1fr; }
  .record-detail-grid { grid-template-columns: 1fr; }
  .record-detail-wide { grid-column: auto; }

  .toast-region {
    right: var(--space-3);
    left: var(--space-3);
    bottom: var(--space-3);
  }

  .toast { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
