:root {
  --bg: #f6f5f4;
  --surface: #ffffff;
  --surface-2: #f0efee;
  --border: #e1e0df;
  --text: #1c1b1a;
  --text-muted: #6b6a69;
  --primary: #3584e4;
  --primary-hover: #1c71d8;
  --danger: #e01b24;
  --success: #2ec27e;
  --warning: #e5a50a;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --font: 'Vazirmatn', Tahoma, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ========== Auth ========== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #e8f0fe 0%, #f6f5f4 50%, #fef6e8 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

.logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.logo h1 { font-size: 24px; font-weight: 700; }
.logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 15px;
  background: var(--surface);
  transition: border-color 0.2s;
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(53,132,228,0.15);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-hover); }
.btn.full { width: 100%; margin-top: 8px; }
.btn.link {
  background: none;
  color: var(--primary);
  font-weight: 500;
  font-size: 13px;
  width: 100%;
  margin-top: 12px;
}
.btn.small {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--text);
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.hint { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }

.message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 10px;
  font-size: 13px;
  text-align: center;
  display: none;
}
.message.show { display: block; }
.message.success { background: #e6f8ef; color: #0a7a3e; }
.message.error { background: #fde8e9; color: #c01c28; }

/* ========== App Layout ========== */
#app-screen {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-right, .topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar h2 { font-size: 17px; font-weight: 600; }

.icon-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); }

.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 12px 8px;
  overflow-y: auto;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: right;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: rgba(53,132,228,0.1);
  color: var(--primary);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.content {
  padding: 20px 24px;
  overflow-y: auto;
}

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

/* Toolbar & Filters */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.add-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.add-bar input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 15px;
  background: var(--surface);
}
.add-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(53,132,228,0.12);
}

/* Task List */
.list { display: flex; flex-direction: column; gap: 8px; }

.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: box-shadow 0.15s;
}
.task-item:hover { box-shadow: var(--shadow); }
.task-item.done .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.task-check.checked {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  font-size: 13px;
}

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

.tag-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.tag-work { background: #3584e4; }
.tag-personal { background: #9141ac; }
.tag-urgent { background: #e01b24; }
.tag-other { background: #77767b; }

.due-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.due-chip.overdue { background: #fde8e9; color: #c01c28; }
.due-chip.today { background: #fef6e8; color: #b06a00; }

.task-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.task-item:hover .task-actions { opacity: 1; }
.task-actions button {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.task-actions button:hover { background: var(--surface-2); }

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

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

.coming-soon {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.coming-soon h3 { font-size: 20px; margin-bottom: 8px; color: var(--text); }

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1b1a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Mobile */
@media (max-width: 768px) {
  #app-screen {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    width: 260px;
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
  #menu-btn { display: flex; }
}
@media (min-width: 769px) {
  #menu-btn { display: none; }
}
