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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ===== СТРАНИЦА ВХОДА ===== */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 340px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  text-align: center;
}

.login-box h1 {
  font-size: 22px;
  margin-bottom: 8px;
  color: #333;
}

.login-box p {
  color: #888;
  font-size: 14px;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.login-box input:focus {
  border-color: #4a90d9;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: #4a90d9;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #3a7bc8;
}

.error-msg {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 8px;
}

/* ===== ОСНОВНОЙ ИНТЕРФЕЙС ===== */
#app-page {
  display: none;
}

.header {
  background: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 18px;
  color: #333;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 14px;
  color: #666;
}

.btn-logout {
  padding: 6px 14px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
}

.btn-logout:hover {
  background: #f5f5f5;
}

.btn-add {
  padding: 8px 18px;
  background: #4a90d9;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-add:hover {
  background: #3a7bc8;
}

.btn-clear-history {
  padding: 7px 14px;
  background: none;
  border: 1px solid #e74c3c;
  border-radius: 8px;
  font-size: 13px;
  color: #e74c3c;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-clear-history:hover {
  background: #fee2e2;
}

.btn-danger {
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: #c0392b;
}

.clear-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  border: 1px solid #eee;
  transition: background 0.15s;
}

.clear-option:hover {
  background: #f8f9fa;
}

.clear-option input[type="radio"] {
  accent-color: #e74c3c;
  width: 16px;
  height: 16px;
}

.btn-categories {
  padding: 7px 14px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-categories:hover {
  background: #f0f2f5;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #f8f9fa;
}

.cat-shortcut {
  font-size: 12px;
  font-weight: 700;
  background: #e8f0fe;
  color: #3a5fc8;
  border-radius: 5px;
  padding: 2px 7px;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.category-item-name {
  flex: 1;
  font-size: 14px;
  color: #333;
}

.btn-delete-cat {
  padding: 3px 10px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 12px;
  color: #e74c3c;
  cursor: pointer;
}

.btn-delete-cat:hover {
  background: #fee2e2;
  border-color: #e74c3c;
}

.layout {
  display: flex;
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
  gap: 24px;
}

/* ===== ВКЛАДКИ ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: white;
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.tab {
  padding: 8px 16px;
  border: none;
  background: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab:hover {
  background: #f0f2f5;
}

.tab.active {
  background: #4a90d9;
  color: white;
  font-weight: 500;
}

.tab.overdue {
  color: #e74c3c;
}

.tab.overdue.active {
  background: #e74c3c;
  color: white;
}

/* ===== КОЛОНКА ЗАДАЧ ===== */
.main-col {
  flex: 1;
  min-width: 0;
}

.task-section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: #999;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-left: 4px;
}

/* ===== КАРТОЧКА ЗАДАЧИ ===== */
.task-card {
  background: white;
  border-radius: 10px;
  border-left: 3px solid #ddd; /* перекрывается inline-стилем */
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
}

.task-card:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.task-card.done {
  opacity: 0.55;
}

.task-card.cancelled {
  opacity: 0.45;
  text-decoration: line-through;
}

.task-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.task-body {
  flex: 1;
  min-width: 0;
}

.task-text {
  font-size: 15px;
  color: #333;
  margin-bottom: 3px;
}

.task-type-label {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 8px;
  margin-right: 2px;
  vertical-align: middle;
}

.task-type-routine  { background: #dbeafe; color: #1d4ed8; }
.task-type-project  { background: #fef9c3; color: #854d0e; }
.task-type-goal     { background: #fee2e2; color: #991b1b; }
.task-type-work     { background: #dcfce7; color: #166534; }
.task-type-lymphasi { background: #f3e8ff; color: #6b21a8; }

.task-meta {
  font-size: 12px;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-postponed {
  background: #fff3cd;
  color: #856404;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
}

.badge-done {
  background: #d4edda;
  color: #155724;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
}

.badge-cancelled {
  background: #f8d7da;
  color: #721c24;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
}

.task-time {
  font-size: 13px;
  color: #aaa;
  flex-shrink: 0;
}

.task-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-done {
  padding: 5px 12px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-done:hover {
  background: #218838;
}

.btn-cancel {
  padding: 5px 12px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-cancel:hover {
  background: #c82333;
}

/* ===== ЧАСЫ И ДАТА ===== */
.clock-widget {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  text-align: center;
}

.clock-time {
  font-size: 28px;
  font-weight: 700;
  color: #333;
  letter-spacing: 2px;
}

.clock-date {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

/* ===== КАЛЕНДАРЬ ===== */
.calendar-widget {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.calendar-month {
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-name {
  font-size: 10px;
  color: #bbb;
  text-align: center;
  padding: 2px 0;
}

.cal-day {
  font-size: 11px;
  text-align: center;
  padding: 3px 2px;
  border-radius: 4px;
  position: relative;
  color: #555;
}

.cal-day.today {
  background: #4a90d9;
  color: white;
  font-weight: 600;
  border-radius: 50%;
}

.cal-day.has-tasks::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  background: #4a90d9;
  border-radius: 50%;
  margin: 1px auto 0;
}

.cal-day.today.has-tasks::after {
  background: white;
}

.cal-day.empty {
  color: transparent;
}

/* ===== ГРАФИК ПРОДУКТИВНОСТИ ===== */
.productivity-widget {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.widget-title {
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.productivity-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 60px;
}

.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  background: #4a90d9;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}

.chart-bar.today {
  background: #28a745;
}

.chart-bar.zero {
  background: #eee;
  height: 4px !important;
}

.chart-label {
  font-size: 10px;
  color: #bbb;
}

.chart-percent {
  font-size: 9px;
  color: #aaa;
}

/* ===== БОКОВАЯ ПАНЕЛЬ ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
}

.sidebar-section {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: #444;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid #f0f2f5;
}

.sidebar-task {
  padding: 6px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 13px;
  color: #444;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-task:last-child {
  border-bottom: none;
}

.sidebar-task-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-task-time {
  font-size: 11px;
  color: #bbb;
  flex-shrink: 0;
  margin-left: 6px;
}

/* ===== МОДАЛЬНОЕ ОКНО ДОБАВЛЕНИЯ ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.modal h2 {
  font-size: 17px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 7px;
  font-size: 14px;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #4a90d9;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-secondary {
  flex: 1;
  padding: 10px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
}

.modal-actions .btn-primary {
  flex: 1;
}

/* ===== ПУСТОЕ СОСТОЯНИЕ ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #bbb;
  font-size: 15px;
}

/* ===== АДМИН-ПАНЕЛЬ ===== */
.admin-link {
  font-size: 13px;
  color: #4a90d9;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid #4a90d9;
  border-radius: 6px;
}

#admin-page {
  display: none;
  max-width: 900px;
  margin: 24px auto;
  padding: 0 16px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-header h2 {
  font-size: 20px;
}

table {
  width: 100%;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-collapse: collapse;
}

th {
  background: #f8f9fa;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 12px 16px;
  font-size: 14px;
  border-top: 1px solid #f5f5f5;
}

.badge-admin {
  background: #cce5ff;
  color: #004085;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.badge-blocked {
  background: #f8d7da;
  color: #721c24;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.badge-active {
  background: #d4edda;
  color: #155724;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

/* ===== ЗАМЕТКИ ===== */

.notes-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.notes-hint {
  font-size: 13px;
  color: #888;
}

.notes-colors {
  display: flex;
  gap: 8px;
}

.note-color-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.note-color-btn:hover {
  transform: scale(1.15);
}

.note-color-btn.active {
  border-color: #333;
  transform: scale(1.15);
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.note-card {
  border-radius: 10px;
  padding: 14px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  position: relative;
  transition: box-shadow 0.2s, transform 0.15s;
}

.note-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}


.note-delete {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  color: rgba(0,0,0,0.25);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.note-delete:hover {
  color: #e74c3c;
  background: rgba(0,0,0,0.07);
}

.note-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  font-family: inherit;
  outline: none;
  padding-top: 4px;
  padding-right: 20px;
}

.note-textarea::placeholder {
  color: rgba(0,0,0,0.3);
}

.note-date {
  font-size: 11px;
  color: rgba(0,0,0,0.3);
  margin-top: 8px;
  text-align: right;
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ ===== */
@media (max-width: 768px) {

  /* Шапка */
  .header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header h1 {
    font-size: 16px;
  }

  .header-right {
    gap: 8px;
    flex-wrap: wrap;
  }

  .user-name {
    font-size: 13px;
  }

  .btn-add {
    padding: 7px 12px;
    font-size: 13px;
  }

  .btn-categories {
    padding: 6px 10px;
    font-size: 12px;
  }

  .btn-logout {
    padding: 5px 10px;
    font-size: 12px;
  }

  .admin-link {
    font-size: 12px;
    padding: 5px 10px;
  }

  /* Основной layout */
  .layout {
    flex-direction: column;
    margin: 12px auto;
    padding: 0 10px;
    gap: 12px;
  }

  /* Боковая панель — горизонтальный скролл виджетов */
  .sidebar {
    width: 100%;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 4px;
  }

  .sidebar::-webkit-scrollbar {
    height: 3px;
  }

  .sidebar::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
  }

  .clock-widget,
  .calendar-widget,
  .productivity-widget {
    flex-shrink: 0;
    margin-bottom: 0;
  }

  .clock-widget {
    min-width: 130px;
  }

  .clock-time {
    font-size: 22px;
  }

  .calendar-widget {
    min-width: 220px;
  }

  .productivity-widget {
    min-width: 200px;
  }

  /* Вкладки */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding: 4px;
    gap: 2px;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Заметки */
  .notes-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .notes-toolbar {
    gap: 8px;
  }

  /* Карточка задачи */
  .task-card {
    padding: 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .task-text {
    font-size: 14px;
  }

  .task-time {
    font-size: 12px;
  }

  .task-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 4px;
  }

  .btn-done,
  .btn-cancel {
    padding: 6px 14px;
    font-size: 12px;
    flex: 1;
    text-align: center;
  }

  /* Модальные окна */
  .modal {
    width: calc(100vw - 24px);
    padding: 20px 16px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  /* Логин */
  .login-box {
    width: calc(100vw - 40px);
    padding: 28px 20px;
  }
}

@media (max-width: 480px) {
  /* На совсем маленьких экранах — скрываем имя пользователя */
  .user-name {
    display: none;
  }

  /* Шапка компактнее */
  .header h1 {
    font-size: 15px;
  }

  .header-right {
    gap: 6px;
  }

  /* Задача: кнопки меньше */
  .btn-done,
  .btn-cancel {
    padding: 5px 10px;
    font-size: 11px;
  }
}
