/* ─── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:        #2563eb;
  --blue-dark:   #1d4ed8;
  --blue-light:  #eff6ff;
  --blue-mid:    #dbeafe;
  --green:       #16a34a;
  --green-light: #f0fdf4;
  --red:         #dc2626;
  --red-light:   #fef2f2;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
  --gray-400:    #94a3b8;
  --gray-500:    #64748b;
  --gray-600:    #475569;
  --gray-700:    #334155;
  --gray-800:    #1e293b;
  --gray-900:    #0f172a;
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:      0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg:   0 10px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-100);
  min-height: 100vh;
}

/* ─── Utilities ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Buttons ───────────────────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; border: none; background: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37,99,235,.3);
}
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-primary:active:not(:disabled) { background: var(--blue-dark); box-shadow: none; }

.btn-block { width: 100%; justify-content: center; padding: 10px 16px; font-size: 15px; }

.btn-ghost-sm {
  padding: 5px 10px;
  font-size: 13px;
  color: var(--gray-500);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}
.btn-ghost-sm:hover { background: var(--gray-100); color: var(--gray-700); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
  background: #fff;
}
.btn-icon:hover { background: var(--gray-50); color: var(--gray-700); }

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--blue-mid);
  background: var(--blue-light);
  transition: background .15s, border-color .15s;
}
.btn-add:hover { background: var(--blue-mid); border-color: var(--blue); }

.btn-delete {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.btn-delete:hover { color: var(--red); background: var(--red-light); }

/* ─── Spinner ───────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }

/* ─── LOGIN PAGE ────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f7ff 0%, #e8f0fe 100%);
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 28px;
}

.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}
.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: #fff;
}
.field-input::placeholder { color: var(--gray-400); }

.password-wrap { position: relative; }
.password-wrap .field-input { padding-right: 44px; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
}
.password-toggle:hover { color: var(--gray-600); }

#loginError { margin-bottom: 16px; }

/* ─── HEADER ────────────────────────────────────────────────────── */
.header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-name {
  font-size: 14px;
  color: var(--gray-700);
  font-weight: 500;
}
.frov-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 1px 8px;
}

/* ─── MAIN LAYOUT ───────────────────────────────────────────────── */
.main { padding: 28px 20px 60px; }
.container { max-width: 1100px; margin: 0 auto; }

/* ─── DATE NAV ──────────────────────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.date-center {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
}
.date-input {
  padding: 7px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.date-input:focus { border-color: var(--blue); }

.date-label {
  font-size: 14px;
  color: var(--gray-500);
  min-width: 120px;
}

.today-badge {
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid var(--blue-mid);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
}

/* ─── CARD ──────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}
.section-hint {
  font-size: 12px;
  color: var(--gray-400);
  padding: 6px 24px 0;
  margin: 0;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--gray-500);
  font-size: 13px;
}

/* ─── ENTRIES ───────────────────────────────────────────────────── */
.entries-header {
  display: grid;
  grid-template-columns: 210px 1fr 30px;
  gap: 10px;
  padding: 8px 24px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.col-time-header {
  display: flex;
  justify-content: space-around;
  padding: 0 8px;
}
.col-dur  { display: none; }

.entries-list { padding: 8px 0; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--gray-400);
  font-size: 14px;
}

.entry-row {
  display: grid;
  grid-template-columns: 210px 1fr 30px;
  gap: 10px;
  align-items: center;
  padding: 8px 24px;
  border-bottom: 1px solid var(--gray-100);
  animation: fadeIn .18s ease;
}
.entry-row:last-child { border-bottom: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

.entry-time-group {
  display: flex;
  align-items: center;
  gap: 5px;
}
.time-sep { color: var(--gray-400); font-weight: 500; flex-shrink: 0; }

.time-input {
  width: 96px;
  padding: 7px 6px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  text-align: center;
  outline: none;
  transition: border-color .15s, background .15s;
}
.time-input:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.time-input.error { border-color: var(--red); background: var(--red-light); }

.entry-duration { display: none; }


.entry-desc {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  outline: none;
  transition: border-color .15s, background .15s;
}
.entry-desc:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.entry-desc::placeholder { color: var(--gray-400); }
.entry-desc.error { border-color: var(--red); }

/* ─── CARD ACTIONS & FOOTER ─────────────────────────────────────── */
.card-actions {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.save-status {
  font-size: 13px;
  color: var(--gray-400);
}
.save-status.ok { color: var(--green); }
.save-status.err { color: var(--red); }

/* ─── Inspections table (shared: employee card + manager page) ── */
#totalBlock { display: none !important; }
.assignments-card { margin-bottom: 20px; }
#assignmentsCards { max-height: 280px; overflow-y: auto; }

.btn-done {
  padding: 4px 12px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--green);
  background: var(--green-light);
  border: 1.5px solid #bbf7d0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-done:hover:not(:disabled) { background: #dcfce7; border-color: #86efac; }
.btn-done:disabled { opacity: .5; cursor: default; }

.done-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.done-confirm-text {
  font-size: 13px;
  color: var(--gray-600);
}
.btn-confirm-yes {
  padding: 3px 10px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--green);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity .15s;
}
.btn-confirm-yes:hover:not(:disabled) { opacity: .85; }
.btn-confirm-yes:disabled { opacity: .5; cursor: default; }
.btn-confirm-no {
  padding: 3px 10px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.btn-confirm-no:hover:not(:disabled) { background: var(--gray-200); }
.btn-confirm-no:disabled { opacity: .5; cursor: default; }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast svg { flex-shrink: 0; opacity: .8; }
.toast-close {
  margin-left: 10px;
  background: none;
  border: none;
  color: #fff;
  opacity: .5;
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.toast-close:hover { opacity: 1; }

.insp-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

.insp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.insp-table thead th {
  padding: 10px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
}
.insp-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
.insp-table tbody tr:last-child { border-bottom: none; }
.insp-table tbody tr:hover { background: var(--gray-50); }
.insp-table td {
  padding: 10px 14px;
  color: var(--gray-700);
  vertical-align: middle;
}
.insp-id    { font-weight: 600; color: var(--gray-500); width: 70px; white-space: nowrap; }
.insp-date  { white-space: nowrap; width: 110px; }
.cell-action {
  width: 110px;
  white-space: nowrap;
  position: sticky;
  right: 0;
  background: #fff;
  z-index: 1;
}
.cell-assigned {
  width: 150px;
  position: sticky;
  right: 110px;
  background: #fff;
  z-index: 1;
}
/* Header cells: sticky top + sticky right — need higher z-index */
thead .cell-action,
thead .cell-assigned {
  background: var(--gray-50);
  z-index: 3;
}
/* Divider shadow to visually separate sticky zone */
.cell-assigned {
  box-shadow: -4px 0 8px rgba(0,0,0,.06);
}
.td-nowrap  { white-space: nowrap; }
.td-address { max-width: 200px; }
.td-notes   { max-width: 180px; color: var(--gray-500); font-size: 13px; }
.td-truncate {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-assigned { background: var(--blue-light);      color: var(--blue);       border: 1px solid var(--blue-mid); }
.badge-free     { background: var(--gray-100);        color: var(--gray-500);   border: none; }
.badge-done     { background: rgba(34,197,94,0.12);   color: #15803d;           border: 1px solid rgba(34,197,94,0.35); }

/* Buttons small */
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-assign {
  border: 1.5px solid var(--blue-mid);
  color: var(--blue);
  background: var(--blue-light);
  border-radius: var(--radius-sm);
}
.btn-assign:hover { background: var(--blue-mid); }

/* ─── Assign popover ─────────────────────────────────────────────── */
.assign-popover {
  z-index: 200;
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 280px;
}
.assign-search {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.assign-search:focus { border-color: var(--blue); }
.assign-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
}
.assign-option {
  padding: 7px 10px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.1s;
}
.assign-option:hover { background: var(--gray-50); }
.assign-option.selected { background: #eff6ff; color: var(--blue); font-weight: 500; }
.assign-option-none { color: var(--gray-400); font-style: italic; }
.assign-option-empty { color: var(--gray-400); cursor: default; }
.assign-option-self  { color: var(--blue); font-weight: 500; border-bottom: 1px solid var(--gray-100); }

.btn-done-self {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #bbf7d0;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  white-space: nowrap;
}
.btn-done-self:hover { background: #dcfce7; }
.assign-popover-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ─── Index page (employee) viewport layout ──────────────────────── */
.index-layout {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.index-layout .main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
}
.index-layout .container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
}
/* Assignments card stays compact (max-height already set on #assignmentsCards) */
.index-layout .assignments-card {
  flex-shrink: 0;
}
/* Work log card fills remaining space */
.index-layout .card:last-child {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.index-layout .card:last-child .card-header    { flex-shrink: 0; }
.index-layout .card:last-child .entries-header { flex-shrink: 0; }
.index-layout .card:last-child .entries-list   { flex: 1; min-height: 0; overflow-y: auto; }
.index-layout .card:last-child .card-actions   { flex-shrink: 0; }

/* ─── Manager page specifics ─────────────────────────────────────── */
.manager-layout {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.manager-layout .main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.manager-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
}
.manager-sidebar {
  flex: 0 0 210px;
  overflow-y: auto;
  padding: 16px;
  border-right: 1px solid var(--gray-100);
}
.sidebar-heading {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}
.filter-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-stack .filter-field {
  flex: none;
  min-width: 0;
}
.sidebar-filter-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.sidebar-filter-actions .btn-primary {
  flex: 1;
}
.sidebar-filter-total {
  font-size: 12px;
  color: var(--gray-400);
  display: block;
  margin-top: 4px;
}
.manager-cards-area {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px;
}
.manager-cards-area .card {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}
.manager-layout #tableWrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.manager-layout .pagination {
  flex-shrink: 0;
}

.container-wide { max-width: 1200px; }

.filter-card { margin-bottom: 16px; padding: 16px 20px; }
.filter-form {}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 160px; }
.filter-field-sm { min-width: 120px; flex: 0 1 140px; }
.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.filter-total { font-size: 13px; color: var(--gray-400); margin-left: 6px; }

/* Spinner large */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--gray-400);
}
.spinner-lg {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ─── Pagination ─────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.pag-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.pag-btn:hover:not(:disabled):not(.active) { background: var(--gray-50); border-color: var(--gray-300); }
.pag-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.pag-btn:disabled { opacity: .4; cursor: default; }
.pag-ellipsis { padding: 0 4px; color: var(--gray-400); line-height: 34px; }

/* ─── Responsive ────────────────────────────────────────────────── */
/* ─── Filter toggle button (hidden on desktop) ───────────────────── */
.filter-mobile-toggle { display: none; }

/* ─── Manager distribution cards — always multiline, dynamic height ─ */
#cardsWrap .insp-card { align-items: flex-start; padding: 10px 16px; }
#cardsWrap .insp-card-body { flex-direction: column; gap: 3px; }
#cardsWrap .insp-card-title,
#cardsWrap .insp-card-location,
#cardsWrap .insp-card-surveyor,
#cardsWrap .insp-card-meta {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  padding-right: 8px;
  flex: none;
  width: 100%;
}
#cardsWrap .insp-card-surveyor {
  font-size: 12px;
  color: var(--blue);
  font-weight: 500;
}
#cardsWrap .insp-card-date { padding-top: 2px; }
#cardsWrap .insp-card-side { align-self: flex-start; flex-direction: column; align-items: flex-end; gap: 4px; }

/* ─── 600px: mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* ── Header ── */
  .header-title { display: none; }
  .header-inner { padding: 0 12px; }
  .user-name    { display: none; }

  /* ── Cards ── */
  .card-header  { padding: 14px 16px; }
  .card-actions { padding: 10px 16px; }

  /* ── Entry rows (employee page) ── */
  .entries-header { display: none; }
  .entry-row {
    grid-template-columns: 1fr 36px;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 12px 16px;
  }
  .entry-time-group { grid-column: 1; grid-row: 1; }
  .entry-desc       { grid-column: 1; grid-row: 2; }
  .btn-delete       { grid-column: 2; grid-row: 1; align-self: start; }
  .entry-duration   { display: none; }

  /* Touch targets */
  .btn          { min-height: 40px; }
  .field-input  { min-height: 40px; }
  .time-input   { min-height: 40px; }
  .pag-btn      { min-width: 36px; height: 36px; }

  /* ── Employee page: allow natural scroll on mobile ── */
  .index-layout {
    height: auto;
    overflow-y: auto;
  }
  .index-layout .main {
    flex: none;
    overflow: visible;
    min-height: auto;
  }
  .index-layout .container {
    flex: none;
    overflow: visible;
    min-height: auto;
  }
  .index-layout .card:last-child {
    flex: none;
    overflow: visible;
  }
  .index-layout .card:last-child .entries-list {
    overflow: visible;
    flex: none;
    max-height: none;
  }
  #assignmentsCards {
    max-height: none;
    overflow: visible;
  }

  /* ── Manager page: stack sidebar above cards ── */
  .manager-layout {
    height: auto;
    overflow-y: auto;
  }
  .manager-layout .main {
    flex: none;
    overflow: visible;
    padding: 0;
  }
  .manager-body {
    flex-direction: column;
    overflow: visible;
    min-height: 0;
  }
  .manager-sidebar {
    flex: none;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--gray-100);
    display: none;
    padding: 14px 16px;
  }
  .manager-sidebar.mobile-open {
    display: block;
  }
  .filter-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .sidebar-filter-actions {
    margin-top: 4px;
  }
  .manager-cards-area {
    flex: none;
    overflow: visible;
    padding: 12px;
  }
  .manager-cards-area .card {
    flex: none;
    overflow: visible;
  }
  .manager-layout #tableWrap {
    overflow: visible;
    max-height: none;
  }
  .manager-layout .pagination {
    padding: 10px 16px;
  }

  /* Filter toggle button */
  .filter-mobile-toggle {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    min-height: 40px;
  }
  .filter-mobile-toggle:hover { background: var(--gray-100); }
  .filter-mobile-toggle.active {
    background: var(--blue-light);
    border-color: var(--blue-mid);
    color: var(--blue);
  }
}

/* ─── Dashboard ──────────────────────────────────────────────────── */
.dash-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--gray-100);
}

.dash-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 20px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Filters bar */
.dash-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
/* KPI row */
.kpi-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.kpi-card {
  flex: 1;
  min-width: 180px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.1;
}
.kpi-unit {
  font-size: 13px;
  color: var(--gray-400);
}

.dash-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dash-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

.dash-chart-wrap {
  position: relative;
  height: 260px;
}

/* ── Detail section ─────────────────────────────────────────────── */
.dash-detail {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.dash-card-emp-table {
  flex: 0 0 420px;
  min-width: 280px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.dash-card-emp-table .dash-card-title {
  padding: 16px 20px 10px;
}

.emp-chart-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.emp-chart-inner {
  position: relative;
}

.dot-legend {
  display: flex;
  gap: 14px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.dot-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--gray-500);
}

.emp-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.emp-stats-table th {
  padding: 7px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.emp-stats-table th:hover { color: var(--gray-800); }
.emp-stats-table th:first-child { width: 28px; padding-right: 0; cursor: default; }
.emp-stats-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.emp-stats-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--gray-800); }
.emp-stats-table tbody tr:last-child td { border-bottom: none; }
.emp-stats-row { cursor: pointer; transition: background .12s; }
.emp-stats-row:hover { background: var(--gray-50); }
.emp-stats-row.active { background: var(--blue-light); }
.emp-stats-row.active td { color: var(--blue-dark); font-weight: 500; }

.emp-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dash-card-granular { flex: 1; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.dash-card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.gran-tabs {
  display: flex;
  gap: 2px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.gran-btn {
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-500);
  background: none;
  border: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.gran-btn:hover { color: var(--gray-700); background: var(--gray-200); }
.gran-btn.active { background: #fff; color: var(--gray-900); font-weight: 600; box-shadow: var(--shadow-sm); }

.dash-chart-wrap-lg { height: 320px; }

.chart-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 14px;
  color: var(--gray-400);
  text-align: center;
  padding: 24px;
}

.gran-hint {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.hint-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--gray-500);
}
.hint-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--gray-200);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-700); }
.nav-link.active { background: #eff6ff; color: var(--blue); }


/* ─── View toggle (manager page) ────────────────────────────────── */
.view-toggle-bar {
  display: flex;
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-500);
  background: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.view-btn:hover  { background: var(--gray-100); color: var(--gray-700); }
.view-btn.active { background: var(--gray-100); color: var(--gray-900); font-weight: 600; }

/* ─── Inspection cards ───────────────────────────────────────────── */
.insp-card {
  display: flex;
  align-items: center;
  padding: 7px 16px;
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
  min-width: 0;
}
.insp-card:last-child { border-bottom: none; }
.insp-card:hover { background: var(--gray-50); }

.insp-card-date {
  flex: 0 0 78px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
}
.insp-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
}
.insp-card-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}
.insp-card-location {
  flex: 1.5;
  min-width: 0;
  font-size: 12px;
  color: var(--gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}
.insp-card-meta {
  flex: 2;
  min-width: 0;
  font-size: 12px;
  color: var(--gray-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}
.insp-card-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-left: 6px;
}
.insp-card-side .cell-assigned {
  width: auto;
  position: static;
  right: auto;
  background: transparent;
  box-shadow: none;
  z-index: auto;
}

/* ─── Employee "Мои заявки" — multiline cards ────────────────────── */
#assignmentsCards .insp-card {
  align-items: flex-start;
  padding: 10px 16px;
}
#assignmentsCards .insp-card-body {
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
#assignmentsCards .insp-card-title,
#assignmentsCards .insp-card-location,
#assignmentsCards .insp-card-surveyor,
#assignmentsCards .insp-card-meta {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  padding-right: 0;
}
#assignmentsCards .insp-card-date { padding-top: 2px; }
#assignmentsCards .insp-card-side { padding-top: 2px; align-self: flex-start; }

/* ─── History card ───────────────────────────────────────────────── */
.history-card { margin-bottom: 20px; }
.index-layout .history-card { flex-shrink: 0; }

#historyCards {
  max-height: 400px;
  overflow-y: auto;
}

#historyCards .insp-card {
  align-items: flex-start;
  padding: 10px 16px;
}
#historyCards .insp-card-body {
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
#historyCards .insp-card-title,
#historyCards .insp-card-location,
#historyCards .insp-card-surveyor,
#historyCards .insp-card-meta {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  padding-right: 0;
}
#historyCards .insp-card-date { padding-top: 2px; }
#historyCards .insp-card-side { padding-top: 2px; align-self: flex-start; }
#historyCards .insp-card-surveyor { font-size: 12px; color: var(--blue); font-weight: 500; }

.insp-card-report-ro {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--gray-100);
  width: 100%;
}
.report-num-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  border: 1px solid var(--blue-mid);
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
}
.report-time-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  white-space: nowrap;
}

@media (max-width: 600px) {
  #historyCards { max-height: none; overflow: visible; }
}

.insp-card-report {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--gray-100);
  width: 100%;
}
.report-label {
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
}
.report-sep {
  font-size: 12px;
  color: var(--gray-400);
}
.inp-report-num {
  width: 64px;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-800);
  background: var(--gray-50);
  outline: none;
}
.inp-report-num:focus {
  border-color: var(--blue);
  background: #fff;
}
.inp-time-from,
.inp-time-to {
  width: 90px;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-800);
  background: var(--gray-50);
  outline: none;
}
.inp-time-from:focus,
.inp-time-to:focus {
  border-color: var(--blue);
  background: #fff;
}
.report-save-status {
  font-size: 11px;
  margin-left: 2px;
  min-width: 12px;
  color: var(--gray-400);
}
.report-save-status.saved { color: var(--green); }
.report-save-status.error { color: var(--red); }

/* ─── Add inspection button bar ─────────────────────────────────── */
#addInspectionBar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.btn-delete-insp {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.btn-delete-insp:hover {
  background: var(--red-light);
  color: var(--red);
}

/* ─── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: min(580px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-400);
  border-radius: var(--radius-sm);
  font-size: 16px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body {
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  overflow-y: auto;
}
.modal-body .field-full { grid-column: 1 / -1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}
.modal-error {
  grid-column: 1 / -1;
  color: var(--red);
  font-size: 13px;
  display: none;
}
.modal-error.visible { display: block; }
@media (max-width: 600px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-body .field-full { grid-column: 1; }
}
#assignmentsCards .insp-card-side { padding-top: 2px; align-self: flex-start; }

/* ─── Analytics page ─────────────────────────────────────────────── */
.analytics-layout { min-height: 100vh; background: var(--gray-50); }
.analytics-main   { max-width: 1100px; margin: 0 auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }

.analytics-stats  { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-chip        { background: #fff; border: 1.5px solid var(--gray-200); border-radius: var(--radius); padding: 14px 20px; display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.stat-chip-label  { font-size: 12px; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; }
.stat-chip-value  { font-size: 28px; font-weight: 700; color: var(--gray-800); line-height: 1; }

.analytics-tabs   { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-200); }
.atab             { padding: 8px 18px; font-size: 14px; font-weight: 500; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; color: var(--gray-400); transition: color .15s; }
.atab:hover       { color: var(--gray-700); }
.atab.active      { color: var(--blue); border-bottom-color: var(--blue); }

.analytics-tab-pane { display: flex; flex-direction: column; gap: 12px; }

.analytics-filters    { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.analytics-filter-sel,
.analytics-filter-date { padding: 7px 10px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; outline: none; background: #fff; }
.analytics-filter-sel:focus,
.analytics-filter-date:focus { border-color: var(--blue); }
.analytics-total { font-size: 13px; color: var(--gray-400); margin-left: 4px; }

.events-table         { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.events-table th      { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1.5px solid var(--gray-100); }
.events-table td      { padding: 9px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.events-table tr:last-child td { border-bottom: none; }
.events-table tr:hover td { background: var(--gray-50); }

.ev-time    { white-space: nowrap; color: var(--gray-400); font-size: 12.5px; }
.ev-details { color: var(--gray-500); }
.ev-ip      { color: var(--gray-300); font-size: 12px; white-space: nowrap; }

.user-chip  { display: inline-block; background: #f1f5f9; border-radius: 20px; padding: 2px 10px; font-size: 13px; font-weight: 500; white-space: nowrap; }

.ev-badge         { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.ev-login         { background: #dcfce7; color: #15803d; }
.ev-logout        { background: #f1f5f9; color: #64748b; }
.ev-assign        { background: #dbeafe; color: #1d4ed8; }
.ev-unassign      { background: #fff7ed; color: #c2410c; }
.ev-done          { background: #d1fae5; color: #065f46; }
.ev-entries       { background: #f3e8ff; color: #7e22ce; }
.ev-add           { background: #e0f2fe; color: #0369a1; }
.ev-delete        { background: #fee2e2; color: #b91c1c; }

.online-dot { display: inline-block; width: 8px; height: 8px; background: #22c55e; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

@media (max-width: 700px) {
  .events-table .ev-ip { display: none; }
  .analytics-stats { gap: 8px; }
  .stat-chip { min-width: 100px; padding: 10px 14px; }
  .stat-chip-value { font-size: 22px; }
}
