* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #f8f9fa; color: #212121; }
body::before { content: ''; position: fixed; inset: 0; background: url('Водяной знак (2).png') center/contain no-repeat; opacity: .06; pointer-events: none; z-index: 0; }
.topnav { background: linear-gradient(135deg, #0d1b42, #1a3a7a); color: #fff; padding: 0 24px; display: flex; align-items: center; height: 56px; gap: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topnav .logo { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.topnav .logo img { height: 32px; width: 32px; border-radius: 50%; }
.topnav .nav-link { color: rgba(255,255,255,.7); text-decoration: none; font-size: 13px; padding: 4px 0; border-bottom: 2px solid transparent; transition: all .2s; }
.topnav .nav-link:hover, .topnav .nav-link.active { color: #fff; border-bottom-color: #fff; }
.topnav .nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topnav .nav-right span { font-size: 12px; color: rgba(255,255,255,.6); }
.topnav .nav-right a { color: rgba(255,255,255,.7); text-decoration: none; font-size: 12px; }
.topnav .nav-right a:hover { color: #fff; }
body { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: 100%; margin: 0 auto; padding: 20px; position: relative; z-index: 1; width: 100%; flex: 1; display: flex; flex-direction: column; min-height: 0; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; padding: 12px 16px; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.toolbar h1 { font-size: 18px; margin-right: auto; color: #0d1b42; }
.toolbar .btn + .btn { margin-left: 0; }

.btn { padding: 6px 14px; border: none; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; transition: all .2s; display: inline-flex; align-items: center; gap: 4px; }
.btn-primary { background: #0d1b42; color: #fff; }
.btn-primary:hover { background: #1a3a7a; }
.btn-secondary { background: #1e88e5; color: #fff; }
.btn-secondary:hover { background: #1565c0; }
.btn-danger { background: #c62828; color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-success { background: #2e7d32; color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-outline { background: transparent; border: 1px solid #bdbdbd; color: #616161; }
.btn-outline:hover { background: #f5f5f5; border-color: #9e9e9e; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 50%; }

.filter-group { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #616161; }
.filter-group select, .filter-group input { padding: 5px 8px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 12px; background: #fff; }

.dropdown-checkboxes { position: relative; display: inline-block; }
.dropdown-checkboxes-btn { padding: 5px 10px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 12px; background: #fff; cursor: pointer; white-space: nowrap; }
.dropdown-checkboxes-btn:hover { border-color: #1e88e5; }
.dropdown-checkboxes-panel { display: none; position: absolute; top: 100%; left: 0; z-index: 100; background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 6px; min-width: 200px; margin-top: 2px; }
.dropdown-checkboxes-panel.open { display: block; }
.dd-option { display: flex; align-items: center; gap: 6px; padding: 5px 8px; font-size: 12px; cursor: pointer; border-radius: 4px; white-space: nowrap; }
.dd-option:hover { background: #f0f4ff; }
.dd-option input[type=checkbox] { margin: 0; accent-color: #0d1b42; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 12px; border: 1px solid #e0e0e0; font-size: 11px; cursor: pointer; background: #fafafa; user-select: none; transition: all .15s; }
.chip:hover { border-color: #1e88e5; background: #e3f2fd; }
.chip input[type=checkbox] { margin: 0; accent-color: #0d1b42; }
.chip:has(input:checked) { background: #0d1b42; border-color: #0d1b42; color: #fff; }

.table-wrap { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { background: #f5f5f5; padding: 6px 8px; text-align: left; font-size: 10px; font-weight: 600; color: #616161; border-bottom: 2px solid #e0e0e0; white-space: nowrap; cursor: pointer; user-select: none; }
.table th:hover { color: #0d1b42; }
.table td { padding: 4px 6px; border-bottom: 1px solid #f5f5f5; font-size: 12px; }
.table td { background: #fff; }
.table tr.zebra-even td { background: #f2f2f2; }
.table tr:hover td { background: #f8f9ff; }
.table tr.zebra-even:hover td { background: #f0f2f5; }
.table tr.selected td { background: #e8eaf6; }
/* sticky client name column on the left */
.table .sticky-client { position: sticky; left: 0; z-index: 3; }
.table tr.selected td.sticky-client { background: #e8eaf6; }
.table .sticky-client::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 0;
  bottom: 0;
  width: 8px;
  background: linear-gradient(to right, rgba(0,0,0,.08), transparent);
  pointer-events: none;
}

.status-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }

dialog { border: none; border-radius: 12px; padding: 24px; box-shadow: 0 8px 32px rgba(0,0,0,.25); min-width: 460px; max-width: 92vw; max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { font-size: 16px; margin-bottom: 16px; color: #0d1b42; }
dialog label { display: block; font-size: 12px; margin-bottom: 10px; color: #424242; }
dialog input, dialog select, dialog textarea { width: 100%; padding: 8px 10px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 13px; margin-top: 4px; background: #fff; }
dialog input:focus, dialog select:focus, dialog textarea:focus { outline: none; border-color: #1e88e5; box-shadow: 0 0 0 2px rgba(30,136,229,.15); }
dialog textarea { resize: vertical; min-height: 36px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

/* Week Grid */
.week-grid-wrapper { overflow-x: auto; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.week-grid { width: 100%; border-collapse: collapse; }
.week-grid th, .week-grid td { border: 1px solid #e0e0e0; padding: 6px 8px; font-size: 12px; vertical-align: top; }
.time-label-cell { font-size: 11px; font-weight: 600; color: #0d1b42; text-align: center; white-space: nowrap; background: #f8f9ff; }
.week-cell { min-height: 32px; cursor: pointer; transition: background .15s; }
.week-cell:hover { background: #e8eaf6; }
.week-cell-empty { color: #bdbdbd; text-align: center; font-size: 16px; }
.task-input { width: 100%; padding: 4px 6px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 12px; }
.task-input:focus { outline: none; border-color: #1e88e5; }
.task-date { width: 100%; padding: 4px 6px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 12px; }
.task-done input { text-decoration: line-through; opacity: .6; pointer-events: none; }
.task-done .task-date { text-decoration: line-through; opacity: .6; }
.event-completed { text-decoration: line-through; opacity: .5; }
.task-checkmark { cursor: pointer; font-size: 16px; color: #999; transition: color .2s; user-select: none; }
.task-checkmark.done { color: #43a047; }
.task-checkmark:hover { color: #43a047; }

/* Calendar */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 12px 16px; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.cal-head h2 { font-size: 18px; color: #0d1b42; text-transform: capitalize; }
#monthView { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; gap: 1px; background: #e0e0e0; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; flex: 1; min-height: 0; }
.cal-day { background: #fff; min-height: 0; padding: 4px 6px; cursor: pointer; font-size: 12px; position: relative; }
.cal-day:hover { background: #f5f5f5; }
.cal-day .day-num { font-weight: 600; margin-bottom: 2px; }
.cal-day .event-dot { display: block; font-size: 9px; line-height: 1.3; padding: 1px 3px; border-radius: 2px; margin-top: 1px; white-space: normal; word-break: break-word; color: #fff; cursor: pointer; }
.event-dot:hover { opacity: .9; }
.event-del { margin-left: 2px; font-size: 8px; opacity: 0; transition: opacity .1s; }
.event-dot:hover .event-del { opacity: .7; }
.event-del:hover { opacity: 1 !important; }
.cal-empty { background: #fafafa; cursor: default; min-height: 0; }
.cal-today { background: #e8eaf6; }
.cal-selected { background: #c5cae9; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e0e0e0; margin-bottom: 16px; }
.tab { padding: 8px 20px; font-size: 13px; cursor: pointer; color: #616161; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab:hover { color: #0d1b42; }
.tab.active { color: #0d1b42; border-bottom-color: #0d1b42; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Cards */
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 16px; margin-bottom: 12px; }
.card h3 { font-size: 14px; color: #0d1b42; margin-bottom: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); text-align: center; }
.stat-card .value { font-size: 24px; font-weight: 700; color: #0d1b42; }
.stat-card .label { font-size: 11px; color: #9e9e9e; margin-top: 4px; text-transform: uppercase; }

.notes-icon { cursor: pointer; font-size: 14px; opacity: .5; transition: opacity .15s; }
.notes-icon:hover { opacity: 1; }
.notes-popup { position: fixed; z-index: 9999; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 10px 14px; max-width: 250px; font-size: 13px; line-height: 1.5; color: #333; box-shadow: 0 4px 16px rgba(0,0,0,.12); opacity: 0; transition: opacity .15s; pointer-events: none; }
.notes-popup.visible { opacity: 1; pointer-events: auto; }
.inline-edit { cursor: pointer; border-bottom: 1px dashed #ccc; transition: border-color .2s; }
.inline-edit:hover { border-bottom-color: #1976D2; }
.event-inline { display: inline; }

.empty { color: #9e9e9e; font-size: 13px; padding: 20px; text-align: center; }

.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #0d1b42 0%, #1a3a7a 100%); }
.login-box { background: #fff; padding: 40px; border-radius: 16px; box-shadow: 0 16px 48px rgba(0,0,0,.3); width: 380px; }
.login-box h1 { font-size: 22px; color: #0d1b42; text-align: center; margin-bottom: 4px; }
.login-box .subtitle { text-align: center; font-size: 13px; color: #757575; margin-bottom: 24px; }
.login-box label { display: block; font-size: 13px; margin-bottom: 16px; color: #424242; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; margin-top: 4px; }
.login-box input:focus { outline: none; border-color: #1e88e5; box-shadow: 0 0 0 3px rgba(30,136,229,.1); }
.login-box .btn { width: 100%; padding: 12px; font-size: 14px; border-radius: 8px; }
.login-box .error { color: #c62828; font-size: 13px; text-align: center; margin-bottom: 12px; }
.login-box .link { text-align: center; font-size: 12px; margin-top: 16px; color: #757575; }
.login-box .link a { color: #1e88e5; text-decoration: none; }

@media (max-width: 768px) {
  .container { padding: 12px; }
  .table td, .table th { padding: 6px 8px; font-size: 12px; }
  .toolbar { padding: 8px 12px; gap: 4px; }
  .toolbar h1 { font-size: 16px; }
  .form-row { flex-direction: column; gap: 0; }
  dialog { min-width: auto; padding: 16px; }
  .login-box { width: 90%; padding: 24px; }
  .cal-grid { font-size: 10px; }
}

/* ── Mobile Navigation ── */
.hamburger { display: none; background: none; border: none; color: #fff; font-size: 26px; cursor: pointer; padding: 0 4px; line-height: 1; align-self: center; }

@media (max-width: 900px) {
  .hamburger { display: flex; align-items: center; order: -1; }
  .topnav { flex-wrap: wrap; position: relative; gap: 0; padding: 0 12px; min-height: 56px; height: auto; }
  .topnav .logo { order: 0; flex: 1; }
  .topnav .logo-text { font-size: 13px; }
  .topnav .nav-link,
  .topnav .nav-right { display: none; width: 100%; order: 99; }
  .topnav .nav-right { margin-left: 0; padding: 8px 12px; border-top: 1px solid rgba(255,255,255,.15); display: none; flex-direction: column; gap: 6px; }
  .topnav.nav-open .nav-link,
  .topnav.nav-open .nav-right { display: block; }
  .topnav.nav-open .nav-right { display: flex; }
  .topnav .nav-link { padding: 10px 12px; border-bottom: none; border-left: 3px solid transparent; }
  .topnav .nav-link:hover { border-left-color: #fff; }
  .topnav .nav-right span { display: block; margin-bottom: 4px; font-size: 13px; }
  .topnav .nav-right a { font-size: 13px; padding: 4px 0; display: inline-block; }
}

/* ── Small screens ── */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .cal-head { flex-wrap: wrap; }
  .cal-day { min-height: 0; font-size: 10px; }
  .week-grid td { font-size: 10px; padding: 3px; }
  .login-box { padding: 20px; }
  dialog { max-width: 98vw; padding: 12px; }
  .tabs { overflow-x: auto; white-space: nowrap; }
  .tab { padding: 8px 12px; font-size: 12px; }
}

