:root {
  --color-primary: #2C6E7F;
  --color-primary-light: #4A90A4;
  --color-primary-bg: #EBF4F7;
  --color-bg: #F5F7F8;
  --color-surface: #FFFFFF;
  --color-text: #1A2B35;
  --color-text-muted: #6B8088;
  --color-border: #DDE4E8;
  --color-overdue: #C94040;
  --color-soon: #C47A15;
  --color-done: #3D8B5E;
  --color-postponed: #7B6CAB;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0F1E25;
    --color-surface: #1A2B35;
    --color-text: #E8F1F4;
    --color-text-muted: #8BA5AE;
    --color-border: #2A3D47;
    --color-primary-bg: #1A3340;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-weight: 700;
  margin: 0 0 8px;
}

p { margin: 0 0 8px; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--color-primary); }

/* Layout */

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  padding: 16px 16px calc(76px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  padding: 16px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar h1 {
  font-size: 20px;
}

/* Bottom navigation */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  z-index: 20;
}

.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.bottom-nav button.active {
  color: var(--color-primary);
}

.bottom-nav .icon {
  font-size: 20px;
}

.bottom-nav .label {
  font-size: 11px;
}

/* Cards */

.card {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--color-border);
}

.card-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.muted {
  color: var(--color-text-muted);
  font-size: 13px;
}

/* Task rows */

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.task-row:last-child { border-bottom: none; }

.task-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  min-width: 24px;
  accent-color: var(--color-done);
}

.task-row .task-info { flex: 1; min-width: 0; }

.task-row .task-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-row .task-meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

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

.badge-po_termínu, .badge-overdue { background: rgba(201,64,64,0.15); color: var(--color-overdue); }
.badge-dnes { background: rgba(196,122,21,0.15); color: var(--color-soon); }
.badge-čeká { background: var(--color-primary-bg); color: var(--color-primary); }
.badge-odloženo { background: rgba(123,108,171,0.15); color: var(--color-postponed); }
.badge-nezjištěno { background: rgba(107,128,136,0.15); color: var(--color-text-muted); }
.badge-hotovo { background: rgba(61,139,94,0.15); color: var(--color-done); }

.priority-vysoká::before { content: "🔴 "; }
.priority-střední::before { content: "🟠 "; }
.priority-nízká::before { content: "🟢 "; }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 10px;
  border: none;
  background: var(--color-primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn:active { opacity: 0.85; }

.btn-secondary {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-danger {
  background: transparent;
  color: var(--color-overdue);
  border: 1px solid var(--color-border);
}

.btn-block { margin-top: 8px; }

.fab-add {
  width: 100%;
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-primary);
  border-radius: 12px;
  min-height: 48px;
  font-weight: 600;
  cursor: pointer;
  margin: 12px 0;
}

/* Forms */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.field textarea {
  min-height: 80px;
  padding: 12px;
  resize: vertical;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.chip.selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.checkbox-row input {
  width: 24px;
  height: 24px;
}

/* Filter tags */

.filter-tags {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.filter-tags .chip { white-space: nowrap; }

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}

.modal-sheet {
  background: var(--color-surface);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text-muted);
  min-width: 44px;
  min-height: 44px;
}

/* Login */

.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

.login-logo {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

.login-title {
  text-align: center;
  font-size: 22px;
  margin-bottom: 24px;
}

.login-error {
  color: var(--color-overdue);
  font-size: 13px;
  margin-bottom: 12px;
}

/* Onboarding */

.onboarding {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.onboarding-step {
  flex: 1;
}

.onboarding-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}

.onboarding-progress span {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
}

.onboarding-progress span.active { background: var(--color-primary); }

.big-choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 56px;
}

.big-choice.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

/* Empty state */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-muted);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

/* Areas grid */

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

.area-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
}

.area-card .icon { font-size: 28px; margin-bottom: 8px; }

/* Calendar */

.cal-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.cal-toggle .chip { flex: 1; text-align: center; justify-content: center; }

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.month-grid .day-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  min-height: 44px;
}

.month-grid .day-cell.has-events { border-color: var(--color-primary); }
.month-grid .day-cell .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: 2px;
}

.month-grid .day-cell.empty { border: none; }

.week-group { margin-bottom: 16px; }
.week-group h4 { font-size: 13px; color: var(--color-text-muted); margin-bottom: 6px; }

/* Utility */

.hidden { display: none !important; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
