* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f7fb;
  color: #1a1f2e;
  font-size: 14px;
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ===== Login ===== */
.login-bg {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  width: 380px;
  max-width: 92vw;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  line-height: 1.3;
}
.login-title span {
  font-size: 13px;
  font-weight: 400;
  color: #64748b;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
}
.login-card input, .login-card select {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  font-size: 14px;
  color: #1a1f2e;
  background: #fff;
  font-family: inherit;
}
.login-card input:focus, .login-card select:focus {
  outline: none;
  border-color: #2563eb;
}
.login-error {
  color: #ef4444;
  font-size: 13px;
  min-height: 16px;
}
.login-hint {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  margin-top: 4px;
}

.user-block {
  background: rgba(255,255,255,0.05);
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-name {
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 500;
}
.user-logout {
  font-size: 11px;
  color: #94a3b8;
  text-decoration: none;
}
.user-logout:hover { color: #fff; }

.bell-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}
.bell-btn:hover { background: rgba(255,255,255,0.1); }
.bell-count {
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.bell-count:empty { display: none; }

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 150;
  max-width: 360px;
}
.toast {
  background: #fff;
  border-left: 4px solid #2563eb;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(15,23,42,0.18);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  animation: toastIn 0.25s ease;
}
.toast.overdue { border-left-color: #ef4444; }
.toast.today { border-left-color: #f59e0b; }
.toast.tomorrow { border-left-color: #2563eb; }
.toast-head {
  font-weight: 600;
  font-size: 13px;
}
.toast-meta {
  color: #64748b;
  font-size: 12px;
}
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Sidebar ===== */
.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  padding: 0 8px;
  line-height: 1.25;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.12s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active {
  background: #2563eb;
  color: #ffffff;
}
.nav-item .ico {
  font-size: 16px;
  width: 20px;
  text-align: center;
}
.voice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  line-height: 1.2;
}
.voice-btn:hover { background: #1d4ed8; }
.voice-btn .mic { font-size: 18px; }

/* ===== Main ===== */
.main {
  padding: 20px 24px;
  overflow-y: auto;
}
.page { display: none; }
.page.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.view-switch {
  display: inline-flex;
  background: #ffffff;
  border-radius: 10px;
  padding: 4px;
  border: 1px solid #e5e7eb;
}
.vs-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}
.vs-btn.active {
  background: #2563eb;
  color: #fff;
}

.period-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 4px 10px;
}
.period-arrow {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #475569;
  cursor: pointer;
  padding: 2px 6px;
}
.period-title {
  font-size: 13px;
  color: #1a1f2e;
  font-weight: 500;
  min-width: 120px;
  text-align: center;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.filter-btn, .add-btn, .ghost-btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  color: #1a1f2e;
}
.add-btn {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.add-btn:hover { background: #1d4ed8; }
.filter-btn:hover, .ghost-btn:hover { background: #f1f5f9; }

/* ===== Filter panel ===== */
.filter-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.filter-panel.hidden { display: none; }
.filter-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filter-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
  min-width: 160px;
}
.filter-row select {
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}
#filterCount {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 2px;
}
#filterCount:empty { display: none; }

/* ===== Calendar ===== */
#calendar {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
}
.fc { font-size: 13px; }
.fc-theme-standard .fc-scrollgrid,
.fc-theme-standard td,
.fc-theme-standard th {
  border-color: #eef0f4;
}
.fc-col-header-cell-cushion {
  color: #64748b;
  font-weight: 500;
  text-transform: none;
  font-size: 12px;
}
.fc-daygrid-day-number {
  color: #1a1f2e;
  font-size: 13px;
  padding: 6px 8px;
}
.fc-day-today { background: #eff6ff !important; }
.fc-day-today .fc-daygrid-day-number {
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px;
  padding: 0;
}
.fc-day-sun .fc-daygrid-day-number,
.fc-day-sun.fc-col-header-cell .fc-col-header-cell-cushion {
  color: #ef4444;
}
.fc-event {
  border: none !important;
  background: transparent !important;
  padding: 2px 6px !important;
  margin: 1px 4px !important;
  cursor: pointer;
}
.fc-event-main {
  padding: 0 !important;
}
.task-pill {
  display: flex;
  flex-direction: column;
  border-left: 3px solid #3b82f6;
  padding: 2px 6px;
  background: #fff;
  border-radius: 2px;
}
.task-pill .tp-title {
  color: #1a1f2e;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-pill .tp-meta {
  color: #64748b;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fc-toolbar { display: none; }

/* ===== Bottom row ===== */
.bottom-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 240px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-title {
  font-weight: 600;
  font-size: 14px;
}
.card-action {
  color: #2563eb;
  font-size: 13px;
  text-decoration: none;
}
.badge {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 500;
}
.close-x {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.object-list, .task-list, .upcoming-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.object-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.object-list li:hover { background: #f8fafc; }
.object-list .obj-icon {
  font-size: 16px;
  color: #64748b;
}
.object-list .obj-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}
.object-list .obj-count {
  font-size: 12px;
  color: #94a3b8;
}
.object-list .chev { color: #cbd5e1; }

.task-list li, .upcoming-list li {
  border-left: 3px solid #3b82f6;
  padding: 6px 10px;
  border-radius: 2px;
  background: #f9fafb;
  cursor: pointer;
}
.task-list li:hover, .upcoming-list li:hover {
  background: #f1f5f9;
}
.task-list .row1, .upcoming-list .row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.task-list .tt-title, .upcoming-list .tt-title {
  font-weight: 500;
  font-size: 13px;
}
.task-list .tt-time, .upcoming-list .tt-time {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
}
.task-list .tt-meta, .upcoming-list .tt-meta {
  font-size: 12px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
}

.task-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.task-detail h3 {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
}
.task-detail .row {
  display: flex;
  font-size: 13px;
  gap: 12px;
}
.task-detail .row .k {
  color: #94a3b8;
  width: 90px;
  flex-shrink: 0;
}
.task-detail .row .v {
  color: #1a1f2e;
  font-weight: 500;
}
.task-detail .status-pill {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  border-radius: 6px;
  padding: 3px 10px;
  font-weight: 500;
}
.task-detail .status-pill.done { background: #dcfce7; color: #15803d; }
.task-detail .status-pill.in_progress { background: #fef3c7; color: #b45309; }
.task-detail .status-pill.cancelled { background: #fee2e2; color: #b91c1c; }
.task-detail .actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}
.task-detail .actions a {
  color: #2563eb;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.task-detail .actions a.done-link { color: #15803d; }
.empty {
  color: #94a3b8;
  font-size: 13px;
  font-style: italic;
  padding: 20px 0;
  text-align: center;
}
.empty-page {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  min-height: 400px;
}

/* ===== List tables (Objects / Tasks / Employees) ===== */
.list-table {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}
.list-table table {
  width: 100%;
  border-collapse: collapse;
}
.list-table th {
  background: #f8fafc;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: #64748b;
  padding: 10px 14px;
  border-bottom: 1px solid #eef0f4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.list-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.list-table tr:last-child td { border-bottom: none; }
.list-table tr:hover td { background: #f8fafc; }
.list-table .row-actions a {
  color: #2563eb;
  margin-right: 12px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}
.list-table .row-actions a.danger { color: #ef4444; }

.hint-csv {
  font-size: 12px;
  color: #64748b;
  margin: -4px 0 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 8px 12px;
  border-radius: 8px;
}
.hint-csv code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  font-size: 11px;
}

/* ===== Modal ===== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-bg.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 14px;
  width: 460px;
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 600;
  font-size: 15px;
}
.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
}
.modal-body input,
.modal-body select,
.modal-body textarea {
  padding: 9px 11px;
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  font-size: 13px;
  color: #1a1f2e;
  font-family: inherit;
  background: #fff;
}
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: #2563eb;
}
.modal-body .row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}
.ghost-btn.danger { color: #ef4444; }

@media (max-width: 1100px) {
  .bottom-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .bottom-row { grid-template-columns: 1fr; }
}

/* === День по сотрудникам === */
.day-by-emp { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 12px; }
.day-by-emp.hidden { display: none; }
.dbe-emp { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; }
.dbe-emp-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: #f8fafc; border-bottom: 1px solid #e5e7eb;
}
.dbe-emp-name { font-weight: 600; color: #0f172a; font-size: 15px; }
.dbe-status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  color: #fff; font-size: 11px; font-weight: 500; letter-spacing: 0.2px;
}
.dbe-emp-count { color: #64748b; font-size: 13px; margin-left: auto; }
.dbe-emp-total { color: #64748b; font-size: 13px; padding-left: 12px; border-left: 1px solid #e5e7eb; }
.dbe-tasks { display: flex; flex-direction: column; }
.dbe-task {
  display: flex; flex-direction: column; gap: 4px;
  padding: 11px 16px; border-top: 1px solid #f1f5f9; cursor: pointer;
  transition: background 0.12s;
}
.dbe-task:first-child { border-top: none; }
.dbe-task:hover { background: #f8fafc; }
.dbe-task-main { display: flex; align-items: baseline; gap: 10px; }
.dbe-time { font-weight: 600; color: #0f172a; font-size: 14px; min-width: 50px; }
.dbe-title { color: #0f172a; font-size: 14px; flex: 1; }
.dbe-dur { color: #64748b; font-size: 12px; }
.dbe-task-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; color: #64748b; font-size: 12px; padding-left: 60px; }
.dbe-type { padding-left: 6px; }
.dbe-empty {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 40px 20px; text-align: center;
}
.dbe-empty-title { font-size: 18px; font-weight: 600; color: #0f172a; margin-bottom: 6px; }
.dbe-empty-sub { color: #64748b; margin-bottom: 12px; }
.dbe-empty-hint { color: #94a3b8; font-size: 13px; }

#calendar.hidden { display: none; }

/* === Цветные плашки статуса сотрудника === */
.emp-status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  color: #fff; font-size: 11px; font-weight: 500; white-space: nowrap;
}

/* === Карточка объекта === */
#objectsListView.hidden, #objectCardView.hidden { display: none; }
.back-link { color: #2563eb; text-decoration: none; font-size: 14px; }
.back-link:hover { text-decoration: underline; }
.object-card { display: flex; flex-direction: column; gap: 18px; }
.obj-head {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 18px 22px;
}
.obj-head-name { font-size: 22px; font-weight: 700; color: #0f172a; }
.obj-head-sub { color: #64748b; font-size: 14px; margin-top: 4px; }
.obj-stats { display: flex; gap: 22px; margin-left: auto; }
.obj-stat { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.obj-stat .num { font-size: 22px; font-weight: 700; color: #0f172a; }
.obj-stat .lbl { font-size: 12px; color: #64748b; }
.obj-note {
  background: #fffbeb; border: 1px solid #fde68a; color: #78350f;
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
}
.obj-section { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; }
.obj-section-title {
  padding: 12px 18px; background: #f8fafc; border-bottom: 1px solid #e5e7eb;
  font-weight: 600; color: #0f172a; font-size: 14px;
}
.obj-empty { padding: 24px; text-align: center; color: #94a3b8; font-style: italic; }
.obj-task-row { cursor: pointer; }
.obj-task-row:hover { background: #f8fafc; }
.obj-row { cursor: pointer; }
.obj-row:hover { background: #f8fafc; }
.row-actions a.open-obj { color: #2563eb; margin-right: 12px; }
