@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
  --accent: #33475B;
  --accent-dark: #1F2E3D;
  --accent-soft: #E8EBEE;
  --success: #2E7D52;
  --success-soft: #E4F0E9;
  --danger: #A33636;
  --danger-soft: #F3E4E4;
  --warning: #B8860B;
  --warning-soft: #F5EED8;
  --ink: #1F2937;
  --ink-soft: #6B7280;
  --bg: #F4F5F6;
  --surface: #FFFFFF;
  --line: #E3E6EA;
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Vazirmatn', Tahoma, Arial, sans-serif;
  --sidebar-w: 76px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ========== Auth (همکار style) ========== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.logo { text-align: center; margin-bottom: 8px; }
.logo-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}
.logo h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}
.logo p {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 24px;
  line-height: 1.7;
}

.auth-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: right;
}

.tabs {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
}
.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.field { margin-bottom: 16px; text-align: right; }
.field label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink-soft);
}
.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.12s;
}
.btn.primary, .btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn.primary:hover, .btn-primary:hover { background: var(--accent-dark); }
.btn.full { width: 100%; margin-top: 4px; }
.btn.link {
  background: none;
  color: var(--accent);
  font-weight: 500;
  font-size: 12px;
  width: 100%;
  margin-top: 12px;
  padding: 6px;
  border: none;
}
.btn.link:hover { text-decoration: underline; }
.btn.small {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  width: auto;
}
.btn.small:hover { background: #eceff1; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.hint { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; line-height: 1.7; }

.message {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
  display: none;
}
.message.show { display: block; }
.message.success { background: var(--success-soft); color: var(--success); }
.message.error { background: var(--danger-soft); color: var(--danger); }

/* ========== App shell ========== */
#app-screen {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-right, .topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.sidebar-brand-text strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.sidebar-brand-text span {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 12px;
}
.nav-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 12px 10px 6px;
  letter-spacing: 0.02em;
}
.nav-section:first-child { padding-top: 4px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: right;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover {
  background: var(--bg);
  color: var(--ink);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  right: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--accent);
}
.nav-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex-shrink: 0;
}
.nav-item.active .nav-icon {
  opacity: 1;
  background: var(--accent);
}
.nav-label { flex: 1; }
.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 12px 10px;
}
.sidebar-search {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: right;
}
.sidebar-search:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--surface);
}

.content {
  padding: 24px;
  overflow-y: auto;
  background: var(--bg);
}

.page { display: none; }
.page.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink-soft);
}
.chip:hover { color: var(--ink); border-color: #cfd3d8; }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.add-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.add-bar input[type="text"] {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
}
.add-bar input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.add-bar input[type="date"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  background: var(--surface);
  max-width: 148px;
}

.list { display: flex; flex-direction: column; gap: 8px; }

.task-item,
.project-item,
.routine-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.task-item:hover { border-color: #cfd3d8; }
.task-item.done .task-title {
  text-decoration: line-through;
  color: var(--ink-soft);
}

.task-check {
  width: 18px;
  height: 18px;
  border: 1.5px solid #9CA3AF;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
}
.task-check.checked {
  background: var(--success);
  border-color: var(--success);
}

.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 14px;
  font-weight: 500;
  word-break: break-word;
  color: var(--ink);
}
.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.tag-work { background: #33475B; }
.tag-personal { background: #6B7280; }
.tag-urgent { background: #A33636; }
.tag-other { background: #9CA3AF; }

.due-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}
.due-chip.overdue { background: var(--danger-soft); color: var(--danger); }
.due-chip.today { background: var(--warning-soft); color: #7a5c00; }

.task-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-wrap: wrap;
}
.task-item:hover .task-actions { opacity: 1; }
.task-actions button {
  width: auto;
  height: auto;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink-soft);
}
.task-actions button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: transparent;
}

.subtasks {
  margin-top: 8px;
  padding-right: 10px;
  border-right: 2px solid var(--line);
}
.subtask {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.subtask.done { text-decoration: line-through; opacity: 0.7; }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}
.empty-icon {
  font-size: 22px;
  margin-bottom: 8px;
  opacity: 0.4;
  color: var(--accent);
}

.user-menu { position: relative; }
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  min-width: 160px;
  padding: 6px;
  z-index: 100;
}
.dropdown-header {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  color: var(--ink-soft);
}
.dropdown button {
  width: 100%;
  text-align: right;
  padding: 8px 10px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--danger);
}
.dropdown button:hover { background: var(--danger-soft); }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-dark);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.due-summary { margin-bottom: 12px; }
.due-summary-row { display: flex; gap: 8px; flex-wrap: wrap; }

.progress-bar {
  height: 4px;
  background: var(--accent-soft);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

/* Notes */
.notes-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  min-height: 55vh;
}
.notes-sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  overflow-y: auto;
  max-height: 70vh;
}
.note-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
}
.note-item:hover,
.note-item.active { background: var(--accent-soft); }
.note-item .nt { font-weight: 600; font-size: 13px; color: var(--ink); }
.note-item .np {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notes-editor {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.notes-editor input.title {
  width: 100%;
  border: none;
  font-size: 17px;
  font-weight: 700;
  font-family: var(--font);
  margin-bottom: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}
.notes-editor input.title:focus { outline: none; border-bottom-color: var(--accent); }
.notes-editor textarea {
  width: 100%;
  min-height: 380px;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.8;
  resize: vertical;
  background: transparent;
  color: var(--ink);
}
.notes-editor textarea:focus { outline: none; }

/* Calendar */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 68px;
  padding: 6px;
  cursor: pointer;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-cell.other { opacity: 0.4; }
.cal-cell .dn { font-size: 12px; font-weight: 600; color: var(--ink); }
.cal-cell .dots { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }
.cal-cell .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-head {
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 6px;
  font-weight: 600;
}

/* Search */
.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(31, 46, 61, 0.35);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.search-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  border: 1px solid var(--line);
}
.search-box input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  margin-bottom: 10px;
  background: var(--bg);
}
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.sr-group { margin-bottom: 10px; }
.sr-group h4 {
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 4px;
  font-weight: 600;
}
.sr-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.sr-item:hover { background: var(--accent-soft); }

.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.report-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.report-stat .v { font-size: 22px; font-weight: 700; color: var(--ink); }
.report-stat .l { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-header h2 { font-size: 14px; font-weight: 700; margin: 0; color: var(--ink); }

#mm-canvas {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  background: var(--surface) !important;
}

@media (max-width: 768px) {
  #app-screen { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: 240px;
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
  #menu-btn { display: flex; }
  .notes-layout { grid-template-columns: 1fr; }
  .task-actions { opacity: 1; }
}
@media (min-width: 769px) {
  #menu-btn { display: none; }
}


/* ===== Compact icon sidebar (rail) ===== */
:root { --sidebar-w: 76px; }

.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  overflow: hidden;
  width: var(--sidebar-w);
}

.sidebar-brand { display: none !important; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section { display: none !important; }

.nav-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: center;
  margin: 0;
  position: relative;
  min-height: 56px;
  line-height: 1.2;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  right: -6px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--accent);
}

.nav-icon { display: none !important; }

.nav-svg {
  width: 22px;
  height: 22px;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-label {
  flex: none;
  font-size: 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 8px 0 4px;
  margin-top: auto;
}

.sidebar-search { display: none !important; }

@media (max-width: 768px) {
  .sidebar {
    width: 76px;
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  }
  .sidebar.open { transform: translateX(0); }
}

/* ========== Motion system ========== */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  .btn,
  .chip,
  .nav-item,
  .icon-btn,
  .task-item,
  .project-item,
  .routine-item,
  .note-item,
  .cal-cell,
  .task-check,
  .sidebar-search,
  .field input,
  .add-bar input {
    transition:
      background-color 0.18s ease,
      border-color 0.18s ease,
      color 0.18s ease,
      box-shadow 0.18s ease,
      transform 0.18s ease,
      opacity 0.18s ease;
  }

  .btn.primary:active,
  .btn:active,
  .chip:active,
  .nav-item:active,
  .icon-btn:active {
    transform: scale(0.96);
  }

  .nav-item {
    transition:
      background-color 0.2s ease,
      color 0.2s ease,
      transform 0.2s ease;
  }
  .nav-item:hover {
    transform: translateY(-1px);
  }
  .nav-item.active {
    transform: none;
  }
  .nav-item.active::before {
    animation: barIn 0.22s ease both;
  }

  .task-item,
  .project-item,
  .routine-item {
    transition:
      border-color 0.18s ease,
      box-shadow 0.2s ease,
      transform 0.2s ease,
      opacity 0.25s ease;
  }
  .task-item:hover,
  .project-item:hover,
  .routine-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(31, 46, 61, 0.06);
  }

  .task-check {
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  }
  .task-check:active { transform: scale(0.9); }
  .task-check.checked {
    animation: checkPop 0.28s cubic-bezier(0.34, 1.4, 0.64, 1) both;
  }

  .task-actions {
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(2px);
  }
  .task-item:hover .task-actions {
    transform: translateY(0);
  }

  .page {
    display: none;
    opacity: 0;
  }
  .page.active {
    display: block;
    animation: pageIn 0.28s ease both;
  }

  .list > * {
    animation: itemIn 0.32s ease both;
  }
  .list > *:nth-child(1) { animation-delay: 0.02s; }
  .list > *:nth-child(2) { animation-delay: 0.04s; }
  .list > *:nth-child(3) { animation-delay: 0.06s; }
  .list > *:nth-child(4) { animation-delay: 0.08s; }
  .list > *:nth-child(5) { animation-delay: 0.1s; }
  .list > *:nth-child(6) { animation-delay: 0.12s; }
  .list > *:nth-child(7) { animation-delay: 0.14s; }
  .list > *:nth-child(8) { animation-delay: 0.16s; }

  .chip.active {
    transition: background 0.2s ease, transform 0.18s ease;
  }

  .toast {
    animation: toastIn 0.28s ease both;
  }

  .search-modal {
    animation: fadeIn 0.2s ease both;
  }
  .search-box {
    animation: slideDown 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .dropdown {
    animation: dropIn 0.18s ease both;
  }

  .auth-card {
    animation: pageIn 0.35s ease both;
  }

  .message.show {
    animation: itemIn 0.25s ease both;
  }

  .sidebar {
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  }

  #app-screen:not(.hidden) {
    animation: fadeIn 0.3s ease both;
  }
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes checkPop {
  0%   { transform: scale(0.7); }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes barIn {
  from { opacity: 0; transform: scaleY(0.4); }
  to   { opacity: 1; transform: scaleY(1); }
}

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

/* Add bar: wide input, short button */
.add-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.add-bar #new-task-input {
  flex: 1 1 auto;
  min-width: 0;
}
.add-bar #add-task-btn {
  width: auto !important;
  flex: 0 0 auto;
  padding: 11px 16px;
  min-width: 72px;
  white-space: nowrap;
}
.jalali-due {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}
.jalali-due select {
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
  max-width: 88px;
}
.jalali-due select:focus {
  outline: none;
  border-color: var(--accent);
}

.dropdown-item {
  width: 100%;
  text-align: right;
  padding: 8px 10px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--ink);
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }

.account-box { max-width: 420px; text-align: right; }
.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.account-head h3 { font-size: 16px; font-weight: 700; margin: 0; }
.account-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}
.account-section h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ink-soft);
}
.account-box .btn.full { margin-top: 4px; margin-bottom: 4px; }

/* ========== Form controls — no ugly native look ========== */
select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

select {
  padding: 9px 28px 9px 12px;
  font-size: 13px;
  line-height: 1.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
  background-size: 12px;
  cursor: pointer;
  max-width: 100%;
}

select:hover {
  border-color: #c5cad1;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 71, 91, 0.12);
  background-color: var(--surface);
}

select:disabled,
input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg);
}

/* Jalali due row — compact & aligned */
.jalali-due {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  align-items: stretch;
}

.jalali-due select {
  min-width: 0;
  height: 42px;
  padding: 0 28px 0 10px;
  font-size: 12px;
  background-color: var(--surface);
}

.jalali-due select#due-jy { width: 78px; }
.jalali-due select#due-jm { width: 100px; }
.jalali-due select#due-jd { width: 64px; }

.add-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.add-bar #new-task-input {
  flex: 1 1 200px;
  min-width: 160px;
  height: 42px;
  padding: 0 14px;
  background: var(--surface);
}

.add-bar #add-task-btn {
  height: 42px;
  padding: 0 18px;
  width: auto !important;
  flex: 0 0 auto;
  border-radius: 8px;
}

/* Auth selects / admin */
.field select {
  width: 100%;
  height: 42px;
  padding: 0 28px 0 14px;
  background-color: var(--bg);
}

.field select:focus {
  background-color: var(--surface);
}

/* Option list still OS-native but less jarring when closed */
select option {
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  padding: 8px;
}

/* Hide default IE arrow */
select::-ms-expand { display: none; }

/* Custom select (cselect) */
.cselect {
  position: relative;
  min-width: 72px;
  user-select: none;
}
.cselect-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cselect-btn:hover { border-color: #c5cad1; }
.cselect.open .cselect-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 71, 91, 0.12);
}
.cselect-btn .cselect-label {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}
.cselect-btn .cselect-label.is-placeholder {
  color: var(--ink-soft);
}
.cselect-caret {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: transform 0.18s ease;
}
.cselect.open .cselect-caret { transform: rotate(180deg); }

.cselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  min-width: 100%;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(31, 46, 61, 0.12);
  z-index: 80;
  padding: 4px;
  display: none;
  animation: dropIn 0.16s ease both;
}
.cselect.open .cselect-menu { display: block; }

.cselect-option {
  display: block;
  width: 100%;
  text-align: right;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.cselect-option:hover {
  background: var(--bg);
}
.cselect-option.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}

#due-jy-wrap { width: 82px; }
#due-jm-wrap { width: 108px; }
#due-jd-wrap { width: 68px; }

@media (max-width: 640px) {
  .jalali-due { width: 100%; }
  #due-jy-wrap, #due-jm-wrap, #due-jd-wrap { flex: 1; width: auto; }
}

/* ===== Floating vertical nav rail ===== */
:root {
  --sidebar-w: 72px;
  --rail-gap: 14px;
}

#app-screen {
  display: block;
  min-height: 100vh;
  position: relative;
}

.topbar {
  grid-column: auto;
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
}

.sidebar {
  position: fixed !important;
  top: 50% !important;
  right: var(--rail-gap) !important;
  bottom: auto !important;
  left: auto !important;
  transform: translateY(-50%) !important;
  width: var(--sidebar-w) !important;
  height: auto !important;
  max-height: calc(100vh - 100px);
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: 18px !important;
  box-shadow: 0 8px 28px rgba(31, 46, 61, 0.10) !important;
  padding: 10px 6px !important;
  z-index: 40;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav {
  flex: none !important;
  overflow: visible !important;
  padding: 0 !important;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 6px;
  margin-top: 4px;
}

.nav-item.active::before {
  right: -6px;
  border-radius: 3px;
}

.content {
  margin-right: 0;
  padding: 18px 24px;
  /* فضا برای نوار شناور سمت راست */
  padding-right: calc(var(--sidebar-w) + var(--rail-gap) * 2 + 8px);
  min-height: calc(100vh - var(--topbar-h));
  background: var(--bg);
}

@media (max-width: 768px) {
  .sidebar {
    top: auto !important;
    bottom: 16px !important;
    right: 50% !important;
    transform: translateX(50%) !important;
    flex-direction: row !important;
    width: auto !important;
    max-width: calc(100vw - 24px);
    max-height: none;
    border-radius: 16px !important;
    padding: 6px !important;
  }
  .sidebar-nav {
    display: flex !important;
    flex-direction: row !important;
    gap: 2px;
    overflow-x: auto;
  }
  .sidebar-footer {
    border-top: none;
    border-right: 1px solid var(--line);
    padding: 0 0 0 4px;
    margin: 0;
  }
  .nav-item {
    min-height: 52px;
    min-width: 56px;
    padding: 8px 6px;
  }
  .nav-item.active::before {
    display: none;
  }
  .content {
    padding: 14px;
    padding-bottom: 90px;
  }
  .sidebar.open {
    transform: translateX(50%) !important;
  }
}

/* ========== Global modern polish ========== */
:root {
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(31, 46, 61, 0.04);
  --shadow: 0 4px 16px rgba(31, 46, 61, 0.06);
  --shadow-lg: 0 12px 40px rgba(31, 46, 61, 0.10);
}

body {
  background: #eef0f3;
}

/* Topbar glass */
.topbar {
  background: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(227, 230, 234, 0.9) !important;
  height: 56px;
  padding: 0 20px 0 calc(var(--sidebar-w) + var(--rail-gap) * 2) !important;
}
.topbar h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
}
.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

/* Content */
.content {
  padding: 22px 28px;
  padding-right: calc(var(--sidebar-w) + var(--rail-gap) * 2 + 12px);
}

/* Toolbar + chips */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  gap: 10px;
}
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.chip:hover {
  color: var(--ink);
  background: #e8eaed;
}
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(51, 71, 91, 0.25);
}
.btn.small {
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--line);
}

/* Add bar as modern card */
.add-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  gap: 8px;
}
.add-bar #new-task-input {
  border: 1px solid transparent;
  background: var(--bg);
  border-radius: 10px;
  height: 44px;
  font-size: 14px;
}
.add-bar #new-task-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(51, 71, 91, 0.1);
}
.add-bar #add-task-btn {
  height: 44px;
  border-radius: 10px;
  padding: 0 20px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(51, 71, 91, 0.2);
}

/* Task / project / routine cards */
.list {
  gap: 10px;
}
.task-item,
.project-item,
.routine-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.task-item:hover,
.project-item:hover,
.routine-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #d5d9de;
}
.task-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.task-check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border-width: 1.5px;
}
.due-chip {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}
.task-actions button {
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid transparent;
}
.task-actions button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

/* Empty state */
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 56px 24px;
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 1;
}

/* Auth modern */
#auth-screen {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(51, 71, 91, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(51, 71, 91, 0.06), transparent 55%),
    var(--bg);
}
.auth-inner {
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  padding: 28px 24px;
}
.logo-icon {
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(51, 71, 91, 0.25);
}
.tabs {
  border-radius: 12px;
  padding: 4px;
}
.tab {
  border-radius: 9px;
  padding: 10px;
}
.field input {
  height: 44px;
  border-radius: 10px;
  padding: 0 14px;
}
.btn.primary {
  height: 44px;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(51, 71, 91, 0.22);
}

/* Notes */
.notes-layout {
  gap: 14px;
}
.notes-sidebar,
.notes-editor {
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}
.note-item {
  border-radius: 10px;
  padding: 11px 12px;
}
.note-item.active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.notes-editor {
  padding: 22px;
}
.notes-editor input.title {
  font-size: 20px;
  letter-spacing: -0.02em;
}

/* Calendar */
.cal-grid {
  gap: 6px;
}
.cal-cell {
  border-radius: 12px;
  min-height: 76px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.cal-cell:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}
.cal-cell.today {
  box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-sm);
}

/* Reports */
.report-stat {
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.report-stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.report-stat .v {
  font-size: 26px;
  letter-spacing: -0.03em;
}

/* Search + account modals */
.search-modal {
  background: rgba(31, 46, 61, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.search-box {
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.5);
}
.search-box input {
  height: 46px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0 14px;
}
.account-box {
  border-radius: 18px;
}
.account-section {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

/* Cards */
.card {
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 16px;
  background: linear-gradient(180deg, #fff, #fafbfc);
}

/* Mindmap canvas */
#mm-canvas {
  border-radius: 16px !important;
  box-shadow: var(--shadow-sm);
}

/* Dropdown */
.dropdown {
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  border: 1px solid var(--line);
}
.dropdown-item {
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 500;
}

/* Toast */
.toast {
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  font-weight: 500;
}

/* Progress */
.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
}
.progress-bar span {
  border-radius: 999px;
}

/* Due summary */
.due-summary-row .chip,
.due-summary .due-chip {
  box-shadow: var(--shadow-sm);
}

/* Floating rail polish */
.sidebar {
  border-radius: 20px !important;
  box-shadow: 0 10px 36px rgba(31, 46, 61, 0.12) !important;
  border: 1px solid rgba(227, 230, 234, 0.95) !important;
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.nav-item {
  border-radius: 14px;
}
.nav-item.active {
  box-shadow: inset 0 0 0 1px rgba(51, 71, 91, 0.06);
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 14px !important;
  }
  .content {
    padding: 14px;
    padding-bottom: 100px;
  }
  .toolbar,
  .add-bar {
    border-radius: 12px;
  }
}
