:root {
  --accent:      #1a73e8;
  --accent-dark: #1558b0;
  --danger:      #d32f2f;
  --warn:        #f59e0b;
  --ok:          #16a34a;
  --bg:          #f8f9fa;
  --surface:     #ffffff;
  --border:      #dee2e6;
  --text:        #212529;
  --text-muted:  #6c757d;
  --sidebar-w:   220px;
}

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

.hidden { display: none !important; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}

.nav-brand {
  padding: 20px 16px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #334155;
}

.nav-list { list-style: none; padding: 8px 0; }

.nav-link {
  display: block;
  padding: 10px 16px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 6px;
  margin: 2px 8px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: #334155; color: #e2e8f0; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link.hidden { display: none; }

/* ── Content ─────────────────────────────────────────────────────────────── */

.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  max-width: 1300px;
}

.page { display: none; }
.page.active { display: block; }

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

h1 { font-size: 22px; font-weight: 600; margin-bottom: 20px; }
h2 { font-size: 15px; font-weight: 600; margin: 24px 0 12px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn-primary, .btn-secondary, .btn-sm, .btn-danger {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #ced4da; }
.btn-sm        { padding: 4px 10px; font-size: 12px; background: var(--border); color: var(--text); }
.btn-sm:hover  { background: #ced4da; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71c1c; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.data-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.num { text-align: right; }

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8f9fa; }

tr.overdue-mid  td { background: #fffbeb; }
tr.overdue-high td { background: #fef2f2; }

/* ── Badges ──────────────────────────────────────────────────────────────── */

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

/* Project status */
.badge-active   { background: #dcfce7; color: #166534; }
.badge-on_hold  { background: #fef9c3; color: #854d0e; }
.badge-done     { background: #dbeafe; color: #1e40af; }
.badge-archived { background: #f3f4f6; color: #6b7280; }

/* Task status */
.badge-todo        { background: #f3f4f6; color: #4b5563; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }

/* Priority */
.badge-low    { background: #f3f4f6; color: #6b7280; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-high   { background: #fee2e2; color: #991b1b; }

/* Role */
.badge-admin  { background: #ede9fe; color: #5b21b6; }
.badge-member { background: #f3f4f6; color: #4b5563; }

/* ── Filter bar ─────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar select, .filter-bar input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
}

.filter-bar label.checkbox-inline {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */

form { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
}

label input, label select, label textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

label textarea { min-height: 60px; resize: vertical; }

label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
label.checkbox-row input { width: 16px; height: 16px; padding: 0; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: 10px;
  width: 500px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.modal-header h2 { font-size: 16px; margin: 0; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
}

#modal-body { padding: 20px; }

/* ── Dashboard stats ────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stat-card.stat-warning { border-left: 3px solid var(--warn); }
.stat-card.stat-warning .stat-value { color: var(--danger); }
.stat-card.stat-accent  { border-left: 3px solid var(--accent); }
.stat-card.stat-accent  .stat-value { color: var(--accent); }
.stat-card.stat-warn    { border-left: 3px solid #f59e0b; }
.stat-card.stat-warn    .stat-value { color: #d97706; }
.stat-card.stat-ok      { border-left: 3px solid var(--ok); }
.stat-card.stat-ok      .stat-value { color: var(--ok); }

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.toast.hidden { display: none; }
.toast-ok    { background: var(--ok); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* ── Login ───────────────────────────────────────────────────────────────── */

.login-overlay {
  position: fixed; inset: 0;
  background: #1e293b;
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}

.login-overlay.hidden { display: none; }

.login-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
}

.login-logo     { font-size: 24px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-error    { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 4px; }

/* ── Sidebar footer ──────────────────────────────────────────────────────── */

.nav-footer { margin-top: auto; padding: 12px 8px; border-top: 1px solid #334155; display: flex; flex-direction: column; gap: 6px; }

.nav-user { padding: 6px 8px 2px; font-size: 12px; color: #cbd5e1; }
.nav-user strong { display: block; color: #fff; font-size: 13px; }

.btn-logout, .btn-profile {
  display: block; width: 100%;
  padding: 8px 12px;
  background: none; border: 1px solid #334155; border-radius: 6px;
  color: #94a3b8; font-size: 12px; cursor: pointer; text-align: left;
}

.btn-logout:hover, .btn-profile:hover { background: #334155; color: #e2e8f0; }

/* ── Reports ─────────────────────────────────────────────────────────────── */

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .report-grid { grid-template-columns: 1fr; }
}

/* ── Worker shell (zjednodušené rozhranie pre bežných členov tímu) ──────── */

#worker-shell.hidden { display: none; }
#worker-shell {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; flex-direction: column;
}

.worker-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: #1e293b; color: #fff;
  flex-shrink: 0;
}
.worker-title { font-size: 17px; font-weight: 700; }
.worker-topbar-actions { display: flex; gap: 6px; }
.worker-icon-btn {
  background: none; border: 1px solid #334155; border-radius: 8px;
  color: #e2e8f0; font-size: 18px; width: 40px; height: 40px; cursor: pointer;
}
.worker-icon-btn:hover { background: #334155; }

.worker-body {
  flex: 1; overflow-y: auto;
  padding: 24px 18px 40px;
  display: flex; flex-direction: column; align-items: stretch;
  max-width: 480px; width: 100%; margin: 0 auto;
}

.worker-status {
  text-align: center;
  padding: 18px 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 24px;
}
.worker-status .state-label { font-size: 19px; font-weight: 700; }
.worker-status .state-sub   { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.worker-status.st-traveling { border-left: 4px solid var(--warn); }
.worker-status.st-working   { border-left: 4px solid var(--ok); }

.worker-buttons { display: flex; flex-direction: column; gap: 14px; }
.worker-btn {
  padding: 22px 16px; font-size: 18px; font-weight: 700;
  border: none; border-radius: 14px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.worker-btn-travel  { background: var(--accent); color: #fff; }
.worker-btn-arrive  { background: var(--ok); color: #fff; }
.worker-btn-home    { background: var(--border); color: var(--text); }
.worker-btn-end     { background: var(--danger); color: #fff; }

.worker-today {
  text-align: center; margin-top: 22px; font-size: 13px; color: var(--text-muted);
}

/* ── Mobile top bar + off-canvas drawer ─────────────────────────────────── */

.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; height: 56px;
    background: #1e293b; color: #fff; padding: 0 12px; z-index: 1600;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
  }
  .mobile-topbar .hamburger {
    background: none; border: none; color: #fff; font-size: 22px; cursor: pointer;
    padding: 6px 8px; line-height: 1;
  }
  .mobile-topbar .mobile-title { font-size: 16px; font-weight: 700; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 2000;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop.visible {
    display: block;
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1900;
  }

  .content { margin-left: 0; padding: 16px; padding-top: 72px; }
  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
