:root{
  --radius: 14px;
  --radius-sm: 8px;
  --font-display: 'Space Grotesk','Vazirmatn',Tahoma,sans-serif;
  --font-body: 'Vazirmatn',Tahoma,Arial,sans-serif;
  --font-mono: 'JetBrains Mono','Space Grotesk',Consolas,monospace;
}

[data-theme="dark"]{
  --bg: #0a0d12;
  --surface: #10141b;
  --surface-2: #161b24;
  --border: #212934;
  --border-soft: #1a212b;
  --text: #e7eaf0;
  --text-dim: #8a94a6;
  --text-faint: #58616f;
  --accent: #34d399;
  --accent-soft: rgba(52,211,153,0.12);
  --accent-2: #f0a75d;
  --danger: #f26d76;
  --danger-soft: rgba(242,109,118,0.12);
  --high: #f26d76;
  --high-soft: rgba(242,109,118,0.12);
  --medium: #f0a75d;
  --medium-soft: rgba(240,167,93,0.12);
  --low: #6b93f2;
  --low-soft: rgba(107,147,242,0.12);
  --shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
}
[data-theme="light"]{
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --border: #dde3e9;
  --border-soft: #e7ecf0;
  --text: #161a20;
  --text-dim: #626c7c;
  --text-faint: #97a1b0;
  --accent: #0f9d6e;
  --accent-soft: rgba(15,157,110,0.10);
  --accent-2: #c47a2c;
  --danger: #d34753;
  --danger-soft: rgba(211,71,83,0.10);
  --high: #d34753;
  --high-soft: rgba(211,71,83,0.10);
  --medium: #c47a2c;
  --medium-soft: rgba(196,122,44,0.10);
  --low: #3a63c9;
  --low-soft: rgba(58,99,201,0.10);
  --shadow: 0 20px 50px -24px rgba(30,41,59,0.25);
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:
    radial-gradient(circle at 1px 1px, var(--border-soft) 1px, transparent 1px) 0 0/22px 22px,
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 32px 16px;
  transition: background-color .35s ease, color .35s ease;
}

.wrap{ width:100%; max-width: 460px; }
.wrap.dashboard{ max-width: 1200px; }
.wrap.dashboard .card{ padding: 32px 40px 36px; }

@media (max-width: 1000px){
  .wrap.dashboard{ max-width: 94vw; }
  .wrap.dashboard .card{ padding: 24px 20px 24px; }
}

/* rack unit top bar */
.rack-bar{
  display:flex; align-items:center; justify-content:space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 14px;
  flex-wrap: wrap; row-gap: 8px;
}
.rack-lights{ display:flex; gap:6px; direction:ltr; }
.rack-lights span{ width:8px; height:8px; border-radius:50%; display:inline-block; }
.rack-lights .l1{ background:#f26d76; }
.rack-lights .l2{ background:#f0a75d; }
.rack-lights .l3{ background: var(--accent); box-shadow:0 0 8px var(--accent); animation: blink 2.4s ease-in-out infinite; }
@keyframes blink{ 0%,100%{opacity:1;} 50%{opacity:.35;} }

.rack-id{
  font-family: var(--font-mono); font-weight:600; font-size: 12px; letter-spacing:.02em;
  color: var(--text-faint); direction:ltr; unicode-bidi: isolate;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0;
}
.rack-id b{ color: var(--accent); font-weight:600; }

.theme-toggle{
  border:1px solid var(--border); background: var(--surface);
  width:30px; height:30px; border-radius: 8px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  color: var(--text-dim); transition: border-color .2s, color .2s, transform .2s;
  flex-shrink:0;
}
.theme-toggle:hover{ color: var(--accent); border-color: var(--accent); }
.theme-toggle svg{ width:15px; height:15px; }

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 28px 28px;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise{ from{ opacity:0; transform:translateY(10px);} to{opacity:1; transform:translateY(0);} }

.eyebrow{
  font-family: var(--font-body); font-size: 12.5px;
  color: var(--accent); margin: 0 0 10px; font-weight:600;
  display:flex; align-items:center; gap:8px;
}
.eyebrow::before{ content:''; width:14px; height:1px; background: var(--accent); flex-shrink:0; }

h1{
  font-family: var(--font-display); font-size: 22px; line-height:1.6;
  margin: 0 0 8px; font-weight:700;
}
.sub{ color: var(--text-dim); font-size: 13.5px; line-height:1.9; margin:0 0 26px; }

label{ display:block; font-size: 13px; color: var(--text-dim); margin-bottom: 9px; font-weight:600; }

.submit-btn{
  width:100%;
  background: var(--accent);
  color: #06130d;
  border:none; border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: var(--font-body);
  font-weight:700; font-size:14.5px;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:8px;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.submit-btn:hover{ transform: translateY(-1px); box-shadow: 0 10px 24px -10px var(--accent-soft); }
.submit-btn:active{ transform: translateY(0); }
.submit-btn:disabled{ opacity:.55; cursor:not-allowed; transform:none; box-shadow:none; }
.submit-btn.small{ padding:10px 14px; font-size:13px; width:auto; margin-top:12px; }

.foot{
  margin-top:18px; text-align:center;
  font-family: var(--font-mono); font-size: 11px; letter-spacing:.03em;
  color: var(--text-faint); direction:ltr; unicode-bidi: isolate;
}

/* ---------- ورود ---------- */
.lock-form{ text-align:center; padding: 20px 0; }
.lock-form input{
  width:100%; background: var(--surface-2); border:1px solid var(--border);
  border-radius: var(--radius-sm); padding:12px 14px; color:var(--text);
  font-family: var(--font-body); font-size:14px; margin-bottom:14px; outline:none;
  text-align:center;
}
.lock-form input:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.err-msg{ color: var(--danger); font-size:12.5px; margin: -6px 0 14px; }

/* ---------- داشبورد ---------- */
.top-row{ display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:6px; }
.logout-link{
  border-radius:8px; padding:9px 16px; border:1px solid var(--border); color: var(--danger);
  text-decoration:none; font-size:13px; font-weight:600; white-space:nowrap; flex-shrink:0;
}
.logout-link:hover{ border-color: var(--danger); }

.tabs{ display:flex; gap:8px; margin: 18px 0 18px; flex-wrap:wrap; }
.tabs a{
  font-family: var(--font-body); font-size:13px; font-weight:600; padding:9px 16px; border-radius:8px;
  text-decoration:none; border:1px solid var(--border); color: var(--text-dim);
}
.tabs a.active{ background: var(--accent); color:#06130d; border-color: var(--accent); }

.save-msg{ background: var(--accent-soft); color: var(--accent); border-radius:8px; padding:10px 14px; font-size:13px; margin-bottom:16px; }

.stats-row{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.stat{
  font-family: var(--font-mono); font-size:12px; color: var(--text-dim);
  background: var(--surface-2); border:1px solid var(--border); border-radius:999px; padding:6px 12px;
}
.stat b{ color: var(--text); font-weight:700; margin-inline-end:4px; }
.stat-overdue{ color: var(--danger); border-color: var(--danger-soft); }
.stat-overdue b{ color: var(--danger); }
.stat-done b{ color: var(--accent); }

.view-tabs{ display:flex; gap:16px; margin-bottom:16px; border-bottom:1px solid var(--border); }
.view-tabs a{ font-size:13px; font-weight:600; color: var(--text-dim); text-decoration:none; padding-bottom:10px; border-bottom:2px solid transparent; }
.view-tabs a.active{ color: var(--accent); border-color: var(--accent); }

/* ---------- افزودن سریع ---------- */
.quick-add{
  display:flex; gap:8px; flex-wrap:wrap; align-items:stretch;
  background: var(--surface-2); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding:12px; margin-bottom:16px;
}
.quick-add input, .quick-add select{
  background: var(--surface); border:1px solid var(--border); border-radius:7px;
  color: var(--text); font-family: var(--font-body); font-size:13.5px; padding:10px 12px; outline:none;
}
.quick-add input:focus, .quick-add select:focus{ border-color: var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.qa-title{ flex:2 1 200px; min-width:150px; }
.qa-priority{ flex:1 1 130px; }
.qa-date{ flex:1 1 130px; color-scheme: dark; }
[data-theme="light"] .qa-date{ color-scheme: light; }
.qa-tags{ flex:1 1 160px; }
.qa-submit{
  background: var(--accent); color:#06130d; border:none; border-radius:7px; padding:10px 18px;
  font-weight:700; font-size:13.5px; cursor:pointer; flex-shrink:0;
}
.qa-submit:hover{ transform: translateY(-1px); }

/* ---------- فیلتر/جست‌وجو ---------- */
.filter-bar{ margin-bottom:10px; }
.search-box{
  width:100%; background: var(--surface-2); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding:10px 14px; color: var(--text); font-family: var(--font-body); font-size:13.5px; outline:none;
  margin-bottom:10px;
}
.search-box:focus{ border-color: var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.chip-row{ display:flex; gap:6px; flex-wrap:wrap; }
.status-filter-row{ margin-bottom:16px; }
.filter-chip{
  background: var(--surface-2); border:1px solid var(--border); color: var(--text-dim);
  border-radius:999px; padding:6px 13px; font-size:12px; font-family: var(--font-body); font-weight:600;
  cursor:pointer; transition: all .15s;
}
.filter-chip:hover{ border-color: var(--accent); color: var(--accent); }
.filter-chip.active{ background: var(--accent); color:#06130d; border-color: var(--accent); }

/* ---------- کارت تسک ---------- */
.task-card{
  display:block; border:1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom:10px; background: var(--surface-2); overflow:hidden;
  border-inline-start: 4px solid var(--border);
  transition: border-color .18s, box-shadow .18s;
}
.task-card.priority-high{ border-inline-start-color: var(--high); }
.task-card.priority-medium{ border-inline-start-color: var(--medium); }
.task-card.priority-low{ border-inline-start-color: var(--low); }
.task-card:hover{ box-shadow: 0 10px 26px -18px rgba(0,0,0,.4); }
.task-card.is-overdue{ background: var(--danger-soft); }

.task-summary{
  list-style:none; cursor:pointer; padding:13px 16px; display:flex; align-items:center;
  gap:10px; flex-wrap:wrap;
}
.task-summary::-webkit-details-marker{ display:none; }
.task-summary::marker{ content:''; }

.quick-status{ display:flex; gap:2px; flex-shrink:0; }
.qs-btn{
  width:26px; height:26px; border-radius:7px; border:1px solid var(--border); background: var(--surface);
  color: var(--text-faint); font-size:13px; cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition: all .15s;
}
.qs-btn:hover{ border-color: var(--accent); color: var(--accent); }
.qs-btn.active.qs-todo{ background: var(--surface); color: var(--text-dim); border-color: var(--text-dim); }
.qs-btn.active.qs-doing{ background: var(--medium-soft); color: var(--medium); border-color: var(--medium); }
.qs-btn.active.qs-done{ background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.task-title{ font-size:14.5px; font-weight:600; color: var(--text); flex:1 1 160px; min-width:0; }
.task-title.done-strike{ text-decoration: line-through; color: var(--text-faint); font-weight:500; }

.badge{
  font-family: var(--font-mono); font-size:11px; padding:4px 9px; border-radius:999px;
  background: var(--surface); border:1px solid var(--border); color: var(--text-dim); flex-shrink:0;
  white-space:nowrap;
}
.priority-badge.pr-high{ color: var(--high); border-color: var(--high-soft); background: var(--high-soft); }
.priority-badge.pr-medium{ color: var(--medium); border-color: var(--medium-soft); background: var(--medium-soft); }
.priority-badge.pr-low{ color: var(--low); border-color: var(--low-soft); background: var(--low-soft); }
.due-badge.overdue{ color: var(--danger); border-color: var(--danger); background: var(--danger-soft); font-weight:700; }
.sub-badge{ color: var(--accent); }
.tag-badge{ color: var(--text-dim); }

.chevron{ width:16px; height:16px; color: var(--text-faint); flex-shrink:0; transition: transform .2s; margin-inline-start:auto; }
.task-card[open] .chevron{ transform: rotate(180deg); }

.task-body{ padding: 4px 16px 16px; border-top:1px solid var(--border-soft); }
.task-desc{ font-size:13.5px; color: var(--text-dim); line-height:1.8; margin:12px 0; white-space:pre-wrap; }

.progress-bar{ height:5px; background: var(--surface); border-radius:999px; overflow:hidden; margin:10px 0; }
.progress-fill{ height:100%; background: var(--accent); border-radius:999px; transition: width .3s; }

.subtask-list{ margin:8px 0; }
.subtask-item{ display:flex; align-items:center; gap:8px; padding:6px 0; }
.sub-check{
  width:20px; height:20px; border-radius:5px; border:1px solid var(--border); background: var(--surface);
  color: var(--accent); font-size:12px; cursor:pointer; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; padding:0;
}
.sub-check.checked{ background: var(--accent-soft); border-color: var(--accent); }
.sub-text{ font-size:13px; color: var(--text); flex:1; }
.sub-text.done-strike{ text-decoration: line-through; color: var(--text-faint); }
.sub-del{ background:none; border:none; color: var(--text-faint); cursor:pointer; font-size:12px; padding:2px 6px; flex-shrink:0; }
.sub-del:hover{ color: var(--danger); }
.add-sub-form{ display:flex; gap:6px; margin-top:8px; }
.add-sub-form input{
  flex:1; background: var(--surface); border:1px solid var(--border); border-radius:6px;
  padding:7px 10px; color: var(--text); font-size:12.5px; font-family: var(--font-body); outline:none;
}
.add-sub-form input:focus{ border-color: var(--accent); }
.add-sub-form button{
  background: var(--surface); border:1px solid var(--border); border-radius:6px; padding:7px 12px;
  color: var(--text-dim); font-size:12px; cursor:pointer;
}
.add-sub-form button:hover{ border-color: var(--accent); color: var(--accent); }

.edit-disclosure{ margin-top:12px; border-top:1px dashed var(--border-soft); padding-top:10px; }
.edit-toggle{ list-style:none; cursor:pointer; font-size:12.5px; color: var(--text-dim); font-weight:600; }
.edit-toggle::-webkit-details-marker{ display:none; }
.edit-toggle:hover{ color: var(--accent); }
.edit-form{ margin-top:12px; }
.edit-form label{ margin-top:10px; }
.edit-form input, .edit-form textarea, .edit-form select{
  width:100%; background: var(--surface); border:1px solid var(--border); border-radius:7px;
  padding:9px 11px; color: var(--text); font-family: var(--font-body); font-size:13px; outline:none;
}
.edit-form textarea{ min-height:70px; resize:vertical; }
.edit-form input:focus, .edit-form textarea:focus, .edit-form select:focus{ border-color: var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.edit-grid{ display:grid; grid-template-columns:1fr 1fr; gap:0 12px; }

.task-actions{ display:flex; align-items:center; gap:8px; margin-top:14px; padding-top:12px; border-top:1px dashed var(--border-soft); flex-wrap:wrap; }
.task-meta{ font-size:11px; color: var(--text-faint); font-family: var(--font-mono); }
.action-btn{
  background:none; border:1px solid var(--border); color: var(--text-dim); border-radius:6px;
  padding:6px 12px; font-size:12px; cursor:pointer; font-family: var(--font-body);
}
.action-btn:hover{ border-color: var(--accent); color: var(--accent); }
.action-btn.danger:hover{ border-color: var(--danger); color: var(--danger); }

/* ---------- بایگانی ---------- */
.archived-card{ padding:14px 16px; opacity:.85; }
.archived-row{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }

.empty-state{ text-align:center; color: var(--text-dim); font-size:13.5px; padding: 30px 0; }

/* ---------- تنظیمات ---------- */
.settings-form label{ margin: 16px 0 6px; }
.settings-form input[type=text], .settings-form textarea{
  width:100%; background:var(--surface-2); border:1px solid var(--border); border-radius:8px;
  padding:10px 12px; color:var(--text); font-family:var(--font-body); font-size:13.5px; outline:none;
}
.settings-form textarea{ min-height:64px; }
.settings-form input:focus, .settings-form textarea:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.settings-section{ border-top:1px solid var(--border); margin-top:22px; padding-top:16px; }
.settings-section h3{ font-size:14px; margin:0 0 4px; font-family:var(--font-display); }
.hint{ font-size:12px; color: var(--text-faint); margin-top:8px; line-height:1.7; }
.fav-preview{ display:flex; align-items:center; gap:10px; margin-top:8px; }
.fav-preview img{ width:28px; height:28px; border-radius:6px; border:1px solid var(--border); }

@media (prefers-reduced-motion: reduce){
  *{ animation:none !important; transition:none !important; }
}

@media (max-width:560px){
  .task-summary{ padding:12px; }
  .task-title{ flex-basis:100%; order:1; }
  .chevron{ order:2; margin-inline-start:0; }
  .quick-add{ flex-direction:column; }
  .quick-add input, .quick-add select, .qa-submit{ width:100%; }
  .edit-grid{ grid-template-columns:1fr; }
}
