/* Light is the product default; an explicit browser preference enables dark. */
:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-elevated: #fff;
  --surface: #fff;
  --surface-hover: #f0f3f9;
  --surface-strong: #e9eef7;
  --border: #dfe5ee;
  --border-strong: #c4cddd;
  --accent: #5145cd;
  --accent-soft: #5145cd;
  --accent2: #087b70;
  --danger: #bb2447;
  --warning: #89600a;
  --text: #202c42;
  --muted: #576780;
  --muted-soft: #63718a;
  --shadow-soft: 0 3px 16px rgba(37, 53, 83, .045);
  --shadow-deep: 0 16px 45px rgba(37, 53, 83, .14);
  --nav-bg: rgba(255, 255, 255, .96);
  --accent-wash: #eeecff;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1420;
  --bg-elevated: #192232;
  --surface: #151e2c;
  --surface-hover: #202d40;
  --surface-strong: #263348;
  --border: #2a374b;
  --border-strong: #46566f;
  --accent: #8d83ff;
  --accent-soft: #b2aaff;
  --accent2: #5cddc6;
  --danger: #ff869d;
  --warning: #ebc76e;
  --text: #edf2fc;
  --muted: #b1bfd5;
  --muted-soft: #9aaac2;
  --shadow-soft: 0 3px 16px rgba(0, 0, 0, .12);
  --shadow-deep: 0 16px 45px rgba(0, 0, 0, .4);
  --nav-bg: rgba(21, 30, 44, .97);
  --accent-wash: #302b4e;
}
body { background-image:none; padding-bottom:0; }
html { scroll-padding-top:150px; }
[hidden] { display:none!important; }
:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
input, textarea, select { accent-color:var(--accent); }
input::placeholder, textarea::placeholder { color:var(--muted-soft); opacity:1; }
.glass { backdrop-filter:none; -webkit-backdrop-filter:none; }
.glass::before { display:none; }
.container { padding-top:1.5rem; }
.btn-primary { background:#5145cd; color:#fff; box-shadow:0 3px 8px rgba(81,69,205,.15); text-decoration:none; }
.btn-primary:hover { background:#4336ba; }
.btn-secondary { background:var(--bg-elevated); }
.btn-secondary:hover { background:var(--surface-hover); }
.form-group input,.form-group select,.form-group textarea,.filter-form select,.compact-select,
.select-combobox-trigger,.jalali-date-control,.chat-composer textarea { background:var(--bg-elevated); }
.form-group select option,.filter-form select option,.compact-select option,
.select-combobox-popup,.jalali-calendar-popup,.modal,.time-dial-popup { background:var(--bg-elevated); color:var(--text); }
.modal { box-shadow:var(--shadow-deep); }
.select-combobox.has-choice .select-combobox-trigger { color:var(--accent2); }
.select-combobox-search { border:1px solid var(--border-strong); background:var(--bg); color:var(--text); }
.select-combobox-option:hover,.select-combobox-option.selected { background:#5145cd; color:#fff; }
.deal-card,.task-card { background:var(--bg-elevated); box-shadow:var(--shadow-soft); }
.month-day.calendar-today { background:var(--bg-elevated); box-shadow:inset 0 0 0 2px var(--accent); }
.month-day.calendar-today > strong { display:inline-grid; place-items:center; width:26px; height:26px; color:#fff; background:#5145cd; border-radius:50%; }
.month-today-label { font-size:.68rem; color:var(--accent); margin-inline-start:.4rem; }
.pipeline-column,.kanban-column { background:var(--surface-hover); }
.status-in_progress { color:var(--accent); }
.jalali-calendar-popup { border:1px solid var(--border-strong); box-shadow:var(--shadow-deep); backdrop-filter:none; max-height:calc(100dvh - 16px); overflow-y:auto; overscroll-behavior:contain; }
.jalali-calendar-head > button,.jalali-calendar-grid button,.jalali-calendar-choice-grid button,.jalali-calendar-today { color:var(--text); }
.jalali-calendar-weekdays,.jalali-calendar-title button::after { color:var(--muted); }
.jalali-calendar-weekdays { font-size:.62rem; letter-spacing:0; }
.jalali-calendar-head > button,.jalali-calendar-today { background:var(--surface-hover); border-color:var(--border); }
.jalali-date-trigger { color:var(--accent); }
.jalali-date-trigger:hover,.jalali-date-trigger:focus-visible { color:var(--accent); background:var(--accent-wash); }
.jalali-date-control .jalali-date::placeholder { color:var(--muted); }
.jalali-date-control { grid-template-columns:minmax(0,1fr) 44px; min-height:46px; border-color:var(--border); border-radius:10px; }
.jalali-date-control .jalali-date { width:100%; min-width:0; height:44px; padding:0 .8rem; font-size:.9rem; }
.jalali-date-control .jalali-date-trigger { width:44px; min-width:44px; height:44px; }
.inline-date-form .jalali-date-control { width:210px; max-width:100%; }
.jalali-calendar-grid button.today,.jalali-calendar-choice-grid button.today { color:var(--accent2); border-color:var(--accent2); box-shadow:inset 0 0 0 1px var(--accent2); }
.jalali-calendar-grid button.selected,.jalali-calendar-choice-grid button.selected { color:white; background:#5145cd; border-color:#5145cd; }
.jalali-calendar-grid button.selected.today { color:white; }
.time-dial-dial { background:radial-gradient(circle at center,var(--accent-wash) 0 31%,var(--surface-hover) 31.5% 100%); }
.time-dial-center { background:var(--accent-wash); color:var(--text); }
.time-dial-hour-label { color:var(--accent); }.time-dial-minute-label { color:var(--accent2); }
.time-dial-hour-label:hover,.time-dial-hour-label.active-hour,.time-dial-minute-label:hover,.time-dial-minute-label.active-minute { color:var(--text); text-shadow:none; }
.bale-link-code code { color:var(--accent2); background:var(--surface-hover); }
.chat-main,.chat-composer { background:var(--bg-elevated); }
.chat-avatar { color:#fff; }
.message-bubble { background:var(--surface-hover); box-shadow:none; }
.message-bubble small { color:var(--muted); }
.message-bubble.mine { color:#fff; background:#5145cd; }
.message-bubble.mine small { color:#e4e0ff; }
.message-bubble.mine .chat-file-attachment small { color:#e4e0ff; }
.chat-date-separator span { background:var(--surface-hover); color:var(--muted); box-shadow:none; }
.text-file-viewer { background:var(--bg-elevated); color:var(--text); }
:root[data-theme="light"] .letter-sheet { background:white; color:#202c42; box-shadow:var(--shadow-soft); }
:root[data-theme="light"] .letter-reference,:root[data-theme="light"] .letterhead-title { color:#576780; }

/* Desktop shell: stable primary destinations, grouped secondary modules. */
.app-header { position:sticky; top:0; z-index:200; background:var(--nav-bg); border-bottom:1px solid var(--border); backdrop-filter:blur(16px); }
.app-masthead,.app-navigation { max-width:1480px; width:calc(100% - 3rem); margin:auto; display:flex; align-items:center; justify-content:space-between; gap:1.5rem; }
.app-masthead { min-height:78px; }
.workspace-brand { display:flex; align-items:center; gap:.8rem; color:var(--text); text-decoration:none; min-width:0; }
.brand-mark { width:42px; height:42px; display:grid; place-items:center; border-radius:12px; color:#fff; background:#5145cd; flex:none; }
.brand-copy { display:grid; min-width:0; }.brand-copy strong { font-size:1rem; max-width:360px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.brand-copy small { font-size:.7rem; color:var(--muted); }
.header-tools { display:flex; align-items:center; gap:.45rem; flex:none; }
.header-tool { display:inline-flex; gap:.5rem; align-items:center; justify-content:center; min-height:40px; padding:.5rem .65rem; color:var(--muted); background:transparent; border:1px solid transparent; border-radius:9px; text-decoration:none; font:600 .8rem var(--font-fa); cursor:pointer; white-space:nowrap; }
.header-tool:hover { color:var(--accent); background:var(--surface-hover); }
.theme-icon-light,.theme-icon-dark { display:flex; }
.theme-icon-dark,:root[data-theme="dark"] .theme-icon-light { display:none; }
:root[data-theme="dark"] .theme-icon-dark { display:flex; }
.account-menu { position:relative; margin-inline-start:.5rem; padding-inline-start:.9rem; border-inline-start:1px solid var(--border); }
.app-header summary { list-style:none; cursor:pointer; }
.app-header summary::-webkit-details-marker,.module-guide summary::-webkit-details-marker,.guide-card summary::-webkit-details-marker { display:none; }
.account-menu > summary { display:flex; align-items:center; gap:.55rem; padding:.2rem; color:var(--text); font-size:.8rem; border-radius:9px; }
.account-avatar { width:35px; height:35px; display:grid; place-items:center; border-radius:50%; color:var(--accent); background:var(--accent-wash); font-weight:800; flex:none; }
.account-name { max-width:170px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.account-panel { position:absolute; top:calc(100% + 16px); inset-inline-end:0; width:275px; max-width:calc(100vw - 24px); background:var(--bg-elevated); border:1px solid var(--border); border-radius:14px; padding:1rem; box-shadow:var(--shadow-deep); display:grid; gap:.4rem; z-index:202; }
.account-panel > strong { overflow-wrap:anywhere; }.account-panel > small { color:var(--muted); padding-bottom:.6rem; border-bottom:1px solid var(--border); }
.account-panel > a { display:flex; align-items:center; gap:.6rem; padding:.65rem 0; color:var(--text); text-decoration:none; font-size:.85rem; }
.account-language-form { display:flex; align-items:center; justify-content:space-between; gap:1rem; font-size:.8rem; }
.account-language-form select { border:1px solid var(--border); padding:.5rem; color:var(--text); background:var(--bg-elevated); font:inherit; border-radius:7px; }
.account-logout { color:var(--danger); background:transparent; padding:.6rem 0 0; width:100%; text-align:start; border:0; border-top:1px solid var(--border); margin-top:.5rem; font:600 .85rem var(--font-fa); cursor:pointer; }
.app-navigation { position:relative; border-top:1px solid var(--border); gap:.7rem; min-height:54px; }
.primary-navigation { display:flex; align-items:center; gap:.45rem; min-width:0; overflow-x:auto; scrollbar-width:thin; padding:.3rem 0; }
.primary-navigation > a,.modules-menu > summary { display:flex; align-items:center; gap:.5rem; padding:.65rem .85rem; border-radius:8px; font-size:.82rem; font-weight:600; white-space:nowrap; text-decoration:none; color:var(--muted); }
.primary-navigation > a:hover,.modules-menu > summary:hover { background:var(--surface-hover); color:var(--text); }
.primary-navigation > a.active,.modules-menu > summary.active { background:var(--accent-wash); color:var(--accent); }
.primary-navigation svg { flex:none; }
.modules-menu { flex:none; }.modules-menu > summary { border-inline-start:1px solid var(--border); border-radius:0; }
.modules-menu[open] > summary { color:var(--accent); }
.modules-panel { position:absolute; inset-inline:0; top:calc(100% + 8px); background:var(--bg-elevated); border:1px solid var(--border); border-radius:16px; padding:1.3rem; box-shadow:var(--shadow-deep); max-height:calc(100dvh - 155px); overflow:auto; }
.modules-heading { display:flex; justify-content:space-between; gap:1rem; align-items:center; margin-bottom:1rem; padding-bottom:1rem; border-bottom:1px solid var(--border); }
.modules-heading strong { font-size:.9rem; }.modules-heading a { color:var(--accent); font-size:.8rem; text-decoration:none; }
.module-menu-groups { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:1.5rem; }
.module-menu-groups h2 { color:var(--muted-soft); font-size:.72rem; font-weight:600; padding:.2rem .65rem .65rem; }
.module-menu-link { display:flex; align-items:center; gap:.65rem; color:var(--text); padding:.6rem .65rem; border-radius:8px; text-decoration:none; font-size:.82rem; }
.module-menu-link svg { color:var(--muted); flex:none; }.module-menu-link:hover { background:var(--surface-hover); }
.module-menu-link.active { color:var(--accent); background:var(--accent-wash); }.module-menu-link.active svg { color:inherit; }
.skip-link { position:fixed; inset-inline-start:1rem; top:-100px; padding:.75rem 1.5rem; z-index:1500; color:#fff; background:#5145cd; border-radius:8px; }
.skip-link:focus { top:.75rem; }

/* A compact guide accompanies every module; the directory is searchable. */
.module-guide { border:1px solid var(--border); background:var(--bg-elevated); border-radius:10px; margin-bottom:1.4rem; }
.module-guide > summary { display:flex; align-items:center; gap:.6rem; padding:.7rem 1rem; list-style:none; cursor:pointer; font-size:.8rem; color:var(--muted); }
.module-guide > summary > svg:first-child { color:var(--accent); flex:none; }.module-guide summary strong { font-weight:600; color:var(--text); }
.guide-summary-hint { margin-inline-start:auto; font-size:.72rem; }.module-guide[open] > summary { border-bottom:1px solid var(--border); }
.module-guide[open] > summary > svg:last-child,.guide-card[open] > summary > svg { transform:rotate(180deg); }
.module-guide-body { padding:1.2rem; }.module-guide-body > p { font-size:.9rem; }.module-guide-body > a { display:inline-block; color:var(--accent); margin-top:.8rem; font-size:.82rem; }
.guide-steps { padding-inline-start:1.35rem; margin:1rem 0; display:grid; gap:.8rem; font-size:.87rem; line-height:1.9; }.guide-steps li { padding-inline-start:.3rem; }.guide-steps li::marker { color:var(--accent); font-weight:800; }
.guide-tip { font-size:.8rem!important; padding:.8rem 1rem; border-inline-start:3px solid var(--accent2); border-radius:4px; background:var(--surface-hover); color:var(--muted); }
.help-search { margin:1.5rem 0; max-width:600px; }.help-search label { font-size:.85rem; font-weight:600; }.help-search > div { display:flex; align-items:center; gap:.7rem; padding:.7rem 1rem; margin:.5rem 0; background:var(--bg-elevated); border:1px solid var(--border-strong); border-radius:10px; }.help-search svg { color:var(--muted); flex:none; }.help-search input { width:100%; min-width:0; border:0; outline:0; background:transparent; color:var(--text); font:inherit; font-size:.9rem; }.help-search > div:focus-within { outline:2px solid var(--accent); outline-offset:2px; }
.guide-directory { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem; align-items:start; }
.guide-card { scroll-margin-top:155px; }.guide-card > summary { display:flex; align-items:center; gap:.9rem; padding:1.3rem; list-style:none; cursor:pointer; }.guide-card > summary > span:nth-child(2) { flex:1; min-width:0; }.guide-card summary strong { display:block; font-size:1rem; }.guide-card summary small { display:block; margin-top:.25rem; font-size:.78rem; color:var(--muted); line-height:1.8; }.guide-card > summary > svg { flex:none; color:var(--muted); }
.guide-module-icon { width:46px; height:46px; display:grid; place-items:center; background:var(--accent-wash); color:var(--accent); border-radius:12px; flex:none; }
.guide-card-body { padding:0 1.4rem 1.4rem; }.guide-card-body .btn-primary { display:inline-block; margin-top:1rem; font-size:.8rem; }
.appearance-panel { display:flex; align-items:center; justify-content:space-between; gap:1.5rem; margin-bottom:1.5rem; padding:1.3rem 1.5rem; }.appearance-panel h2 { font-size:1rem; }.appearance-panel p { color:var(--muted); font-size:.85rem; margin-top:.3rem; }
.appearance-options { display:flex; gap:.35rem; padding:.3rem; background:var(--surface-hover); border:1px solid var(--border); border-radius:11px; }.appearance-options button { padding:.65rem 1.3rem; border:1px solid transparent; border-radius:8px; background:transparent; color:var(--muted); font:600 .85rem var(--font-fa); cursor:pointer; }.appearance-options button[aria-pressed="true"] { color:var(--accent); background:var(--bg-elevated); border-color:var(--border); box-shadow:var(--shadow-soft); }
@media(min-width:1000px) { .module-guide-body .guide-steps { grid-template-columns:repeat(3,minmax(0,1fr)); gap:2.5rem; padding-inline-start:1.4rem; } }
@media(max-width:1100px) { .account-name { display:none; }.brand-copy strong { max-width:280px; }.primary-navigation { gap:.1rem; }.primary-navigation > a { padding-inline:.65rem; }.app-masthead { gap:1rem; } }
@media(max-width:800px) {
  .app-masthead,.app-navigation { width:calc(100% - 2rem); }.app-masthead { min-height:68px; }.brand-copy strong { max-width:220px; font-size:.9rem; }.brand-copy small { font-size:.65rem; }.tool-label,.search-shortcut span { display:none; }
  .primary-navigation { overflow-x:auto; scrollbar-width:thin; padding:.3rem 0; }.primary-navigation > a { font-size:.75rem; padding:.6rem; }.primary-navigation > a svg { display:none; }.modules-menu > summary { padding:.7rem .3rem .7rem .7rem; font-size:.75rem; }
  .module-menu-groups { grid-template-columns:repeat(2,minmax(0,1fr)); gap:1.2rem; }.modules-panel { padding:1rem; }.modules-heading { align-items:flex-start; }.modules-heading strong { font-size:.8rem; }.modules-heading a { font-size:.7rem; }
  .guide-directory { grid-template-columns:1fr; }.appearance-panel { flex-wrap:wrap; }.container { width:calc(100% - 2rem); padding-inline:0; }
}
@media(max-width:480px) {
  .app-masthead,.app-navigation { width:calc(100% - 1.25rem); gap:.4rem; }.brand-mark { width:32px; height:32px; border-radius:9px; }.brand-mark svg { width:19px; }.workspace-brand { gap:.4rem; }.brand-copy strong { max-width:135px; font-size:.8rem; }.brand-copy small { display:none; }
  .header-tools { gap:0; }.header-tool { padding:.4rem; min-width:34px; }.header-tool svg { width:18px; }.search-shortcut { display:none; }.account-menu { margin-inline-start:.2rem; padding-inline-start:.4rem; }.account-avatar { width:30px; height:30px; }.account-menu > summary > svg { display:none; }
  .primary-navigation > a { font-size:.7rem; }.modules-menu > summary > svg:first-child { display:none; }.modules-menu > summary { font-size:.7rem; }.module-guide > summary { padding:.7rem; }.guide-summary-hint { display:none; }.module-guide summary > svg:last-child { margin-inline-start:auto; }
  .module-menu-groups { gap:.75rem; }.module-menu-link { font-size:.78rem; padding:.6rem .25rem; }.module-menu-groups h2 { font-size:.68rem; padding-inline:.25rem; }.guide-card > summary { padding:1rem; }.guide-module-icon { width:38px; height:38px; }.guide-card-body { padding:0 1rem 1rem; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; } }
@media print {
  :root { color-scheme:light; --text:#111; --muted:#444; --muted-soft:#555; --bg:#fff; --bg-elevated:#fff; --surface:#fff; --border:#ccc; }
  .app-header,.module-guide,.skip-link,.appearance-panel,.help-search { display:none!important; }
  body { color:#111; background:#fff!important; }
  .letter-sheet { color:#111; background:#fff; }.letter-reference,.letterhead-title { color:#444; }
}
