/* Alert design system: semantic RTL tokens and accessible interaction states. */
@font-face { font-family: "IRANSans"; src: url("/fonts/IRANSansWeb(FaNum).woff2") format("woff2"), url("/fonts/IRANSansWeb(FaNum).woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("/fonts/IRANSansWeb_Medium.woff2") format("woff2"), url("/fonts/IRANSansWeb_Medium.woff") format("woff"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("/fonts/IRANSansWeb_Bold.woff2") format("woff2"), url("/fonts/IRANSansWeb_Bold.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("/fonts/IRANSansWeb_UltraLight.woff2") format("woff2"), url("/fonts/IRANSansWeb_UltraLight.woff") format("woff"); font-weight: 200; font-style: normal; font-display: swap; }
:root {
  --color-primary: #5b2a86;
  --color-primary-hover: #48206f;
  --color-primary-soft: #f0e9f8;
  --color-accent: #8f52cc;
  --color-surface: #ffffff;
  --color-surface-muted: #faf8fd;
  --color-page: #f6f5fa;
  --color-border: #e7e0ef;
  --color-text: #26183b;
  --color-text-muted: #766c84;
  --color-danger: #b42318;
  --color-danger-soft: #fde8e7;
  --color-success: #147a42;
  --color-success-soft: #e5f7ed;
  --color-warning: #946200;
  --color-warning-soft: #fff3d6;
  --color-info: #1f5f9c;
  --color-info-soft: #e2f0ff;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 10px rgba(59, 35, 80, .06);
  --shadow-md: 0 8px 28px rgba(59, 35, 80, .10);
  --focus-ring: 0 0 0 3px rgba(143, 82, 204, .28);
  --p: var(--color-primary);
  --p2: var(--color-accent);
  --bg: var(--color-page);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --card: var(--color-surface);
  --danger: var(--color-danger);
}

html { background: var(--color-page); }
body {
  color: var(--color-text);
  font-family: "IRANSans", Tahoma, Arial, sans-serif;
  line-height: 1.6;
}

button, input, select, textarea { min-height: 40px; font: inherit; }
form { margin: 0; }
#loginForm { display: grid; gap: 6px; }
#loginForm h2 { margin-block-start: 0; }
button { transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
  border-color: var(--color-accent);
}
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .58; }

main { min-width: 0; }
.card { border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); }
.card:hover { box-shadow: var(--shadow-md); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 5px 10px 5px 6px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); color: var(--color-text); text-align: right; }
.profile-button-copy { display: grid; gap: 0; line-height: 1.35; }
.profile-button-copy small { color: var(--color-text-muted); font-size: 10px; }
.profile-avatar { display: inline-grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary); font-weight: 800; }
.profile-avatar-large { width: 58px; height: 58px; font-size: 24px; }
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr); gap: 16px; }
.profile-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.profile-heading h3 { margin: 4px 0 0; color: var(--color-primary); font-size: 22px; }
.profile-heading p { margin: 4px 0 0; }
.profile-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.profile-details > div { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); }
.profile-details span { color: var(--color-text-muted); font-size: 11px; }
.profile-details b { font-size: 13px; }
.stack-form { display: grid; gap: 10px; }
.stack-form input { width: 100%; }
.muted { line-height: 1.8; }
table { width: 100%; min-width: 680px; border-collapse: collapse; table-layout: auto; }
.card { overflow: visible; }
.card > h3, .card > h2 { color: var(--color-primary); }
th { white-space: nowrap; }
td { vertical-align: top; }

/* Keep horizontal scrolling local to wide data tables without changing the
   table formatting context. Applying display:block directly to a table makes
   its columns behave like unrelated block content and breaks the project,
   checks and other list pages. */
.card:has(> table) { overflow-x: auto; overflow-y: hidden; }
.card > table,
.table-scroll > table { display: table; width: 100%; min-width: 680px; max-width: none; overflow: visible; }
.table-scroll { display: block; width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; overscroll-behavior-inline: contain; }

/* Date fields must stay inside their grid cell. The calendar itself is an
   overlay and must not be clipped by the horizontal table-card behavior. */
.formgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.formgrid > * { min-width: 0; }
.datefield { min-width: 0; z-index: 1; }
.datefield:focus-within { z-index: 20; }
.datecontrols { width: 100%; min-width: 0; align-items: stretch; }
.datecontrols input { width: 0; min-width: 0; flex: 1 1 auto; }
.datecontrols button, .calendar-badge { flex: 0 0 auto; }
.calendar-popover { box-sizing: border-box; max-width: calc(100vw - 24px); }

input, select, textarea { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
textarea { min-height: 96px; resize: vertical; }
button.primary { background: var(--color-primary); }
button.primary:hover:not(:disabled) { background: var(--color-primary-hover); }
button.danger { background: var(--color-danger); }
.badge { background: var(--color-primary-soft); }
.link-button { min-height: auto; }
.field-label { color: var(--color-text-muted); line-height: 1.5; }
.field-label input, .field-label select, .field-label textarea { margin-block-start: 4px; }
.health-on_track { background: var(--color-success-soft); color: var(--color-success); }
.health-at_risk { background: var(--color-warning-soft); color: var(--color-warning); }
.health-off_track { background: var(--color-danger-soft); color: var(--color-danger); }
.health-complete { background: var(--color-info-soft); color: var(--color-info); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media (max-width: 900px) {
  main { padding: 16px; }
  .card { border-radius: var(--radius-md); }
  .top { align-items: flex-start; }
  .profile-grid { grid-template-columns: 1fr; }
}
