:root {
  /* Тёплая светлая тема + зелёные акценты */
  --bg: #faf7f0;
  --bg-panel: #fffdf8;
  --bg-side: #f4efe2;
  --bg-hover: #efe8d8;
  --border: #e3dcc9;
  --text: #2f2b24;
  --text-muted: #857e6c;
  --green: #2e7d5b;
  --green-dark: #235e45;
  --green-light: #e2f0e8;
  --accent-warm: #d9a441;
  --blue: #2f6fb0;
  --blue-light: #e2ecf7;
  --red: #c0492f;
  --red-light: #f7e3de;
  --shadow: 0 6px 24px rgba(70, 60, 30, 0.10);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--green); }
button { font-family: inherit; cursor: pointer; }

/* ---------- Авторизация ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #faf7f0 0%, #eef5ef 100%);
  padding: 20px;
}
.auth-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 420px;
  padding: 32px;
}
.auth-card h1 { margin: 0 0 6px; color: var(--green-dark); font-size: 24px; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-light);
}
.btn {
  border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  background: var(--green); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--green-dark); border: 1px solid var(--green); }
.btn-outline:hover { background: var(--green-light); }
.btn-warm { background: var(--accent-warm); color: #33290f; }
.btn-warm:hover { background: #c8963a; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #a53c25; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.link-btn { background: none; border: none; color: var(--green); font-weight: 600; padding: 0; }
.switch-hint { text-align: center; margin-top: 16px; color: var(--text-muted); }
.form-error {
  background: var(--red-light); color: var(--red);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; display: none;
}
.form-info {
  background: var(--green-light); color: var(--green-dark);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; display: none;
}

/* ---------- Каркас панели ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  height: 58px; flex: 0 0 58px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 18px; gap: 14px;
  box-shadow: 0 1px 6px rgba(70,60,30,.05); z-index: 5;
}
.topbar .brand { font-size: 18px; font-weight: 700; color: var(--green-dark); }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-panel); display: flex; align-items: center; justify-content: center;
  position: relative; font-size: 18px; color: var(--text);
}
.icon-btn:hover { background: var(--bg-hover); }
.badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 11px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.main { flex: 1; display: flex; overflow: hidden; }

/* ---------- Боковая панель ---------- */
.sidebar {
  width: 260px; flex: 0 0 260px; background: var(--bg-side);
  border-right: 1px solid var(--border); overflow-y: auto; padding: 14px 10px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text); font-weight: 600; margin-bottom: 3px;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--green); color: #fff; }
.nav-group-title { display: flex; align-items: center; gap: 8px; }
.nav-sub { margin-left: 22px; }
.nav-sub .nav-item { font-weight: 500; padding: 8px 12px; }
.nav-sub.collapsed { display: none; }
.caret { transition: transform .15s; font-size: 11px; }
.caret.open { transform: rotate(90deg); }
.side-sep { height: 1px; background: var(--border); margin: 10px 4px; }

/* ---------- Контент ---------- */
.content { flex: 1; overflow-y: auto; padding: 20px 24px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; color: var(--green-dark); }
.page-head .spacer { flex: 1; }

.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
}
.filters .field { margin: 0; }
.filters .field label { font-size: 11px; color: var(--text-muted); }
.filters .field input, .filters .field select { padding: 7px 9px; font-size: 13px; }
.checkbox-row { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--green); }

/* ---------- Таблица задач ---------- */
.table-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
table.data th {
  background: var(--bg-side); color: var(--text-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
}
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--green-light); }
table.data tbody tr:last-child td { border-bottom: none; }
.muted { color: var(--text-muted); }
.empty-state { padding: 40px; text-align: center; color: var(--text-muted); }

/* тег-иконка */
.tag { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.tag .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.tag.urgent { color: var(--red); } .tag.urgent .dot { background: var(--red); }
.tag.normal { color: var(--green); } .tag.normal .dot { background: var(--green); }
.tag.regular { color: var(--accent-warm); } .tag.regular .dot { background: var(--accent-warm); }

/* статус-бейдж */
.status { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status.unassigned { background: #efe8d8; color: #7a6f52; }
.status.in_progress { background: var(--blue-light); color: var(--blue); }
.status.done { background: var(--green-light); color: var(--green-dark); }
.deadline-over { color: var(--red); font-weight: 700; }
.deadline-soon { color: #d9821a; font-weight: 700; background: #fbefdc; border-radius: 4px; }

/* ---------- Карточки статистики ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--green-dark); }
.stat-card .label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.stat-card.warn .value { color: var(--red); }
.stat-card.blue .value { color: var(--blue); }
.progressbar { height: 8px; background: var(--bg-side); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progressbar > span { display: block; height: 100%; background: var(--green); }

/* ---------- Модальные окна ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(40, 34, 20, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal-overlay.second { z-index: 60; }
.modal {
  background: var(--bg-panel); border-radius: var(--radius); width: 100%; max-width: 640px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.modal.wide { max-width: 820px; }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 17px; color: var(--green-dark); flex: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-muted); line-height: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.detail-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.detail-row .k { color: var(--text-muted); min-width: 150px; }
.detail-row .v { font-weight: 600; }
.section-title { font-weight: 700; color: var(--green-dark); margin: 18px 0 8px; font-size: 14px; }
.comment {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; margin-bottom: 8px;
}
.comment .meta { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.comment-list { max-height: 220px; overflow-y: auto; }
.tag-preview-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--green-light);
  color: var(--green-dark); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.chip .x { cursor: pointer; font-weight: 700; }

/* календарь выбора периода */
.calendar { display: flex; gap: 20px; flex-wrap: wrap; }
.cal-month { }
.cal-month-title { font-weight: 700; margin-bottom: 6px; color: var(--green-dark); }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 11px; text-align: center; color: var(--text-muted); margin-bottom: 4px; }
.cal-dow span { display: block; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day { padding: 5px 0; text-align: center; border-radius: 5px; cursor: pointer; border: 1px solid var(--border); font-size: 12px; }
.cal-day:hover { background: var(--green-light); }

/* автокомплит ответственных */
.autocomplete { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 190px; overflow-y: auto; box-shadow: var(--shadow); display: none;
}
.ac-list.open { display: block; }
.ac-item { padding: 9px 12px; cursor: pointer; }
.ac-item:hover, .ac-item.active { background: var(--green-light); }

/* уведомления (выдвижная панель справа) */
.drawer {
  position: fixed; top: 0; right: -420px; width: 400px; max-width: 92vw; height: 100%;
  background: var(--bg-panel); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(70,60,30,.12); z-index: 70;
  transition: right .22s ease; display: flex; flex-direction: column;
}
.drawer.open { right: 0; }
.drawer-head {
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.drawer-head h3 { margin: 0; flex: 1; font-size: 16px; color: var(--green-dark); }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.notif {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 9px; background: var(--bg);
}
.notif.unread { border-left: 4px solid var(--accent-warm); background: #fffaf0; }
.notif.overdue { border-left-color: var(--red); }
.notif .meta { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--border); }

/* карточка сотрудника */
.emp-task-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 7px; cursor: pointer;
}
.emp-task-row:hover { background: var(--green-light); }
.emp-task-row .left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark-done { color: var(--green); font-weight: 700; }
.mark-progress { color: var(--blue); font-weight: 700; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--green-dark); color: #fff; padding: 11px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

.hidden { display: none !important; }
.loader { padding: 30px; text-align: center; color: var(--text-muted); }
