:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #162033;
  --muted: #65758b;
  --line: #d6deea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #15803d;
  --danger: #dc2626;
  --shadow: 0 18px 44px rgba(23, 32, 51, 0.14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --surface: #1f2937;
  --surface-soft: #273244;
  --text: #f8fafc;
  --muted: #aebacc;
  --line: #39475d;
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --success: #4ade80;
  --danger: #f87171;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 96px;
}

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

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  overflow-wrap: anywhere;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.status-panel,
.dashboard-panel,
.view-panel,
.dialog-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dashboard-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.stat-card span {
  display: block;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

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

.import-button {
  display: inline-grid;
  min-height: 40px;
  place-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.import-button input {
  display: none;
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.status-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 13px;
}

.status-badge.is-granted {
  background: rgba(21, 128, 61, 0.14);
  color: var(--success);
}

.status-badge.is-denied,
.status-badge.is-unsupported {
  background: rgba(220, 38, 38, 0.14);
  color: var(--danger);
}

.status-badge.is-default {
  background: rgba(37, 99, 235, 0.14);
  color: var(--primary-dark);
}

.notification-message {
  max-width: 420px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.secondary-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.today-panel {
  margin-bottom: 14px;
}

.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab-button.is-active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 5px 16px rgba(23, 32, 51, 0.12);
}

.view-panel {
  padding: 16px;
}

.section-title,
.calendar-header,
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin-bottom: 14px;
}

.section-title h2,
.calendar-header h2,
.dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

#task-count {
  min-width: 32px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  color: var(--primary-dark);
  font-weight: 700;
  text-align: center;
}

.task-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-swipe-shell {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  touch-action: pan-y;
}

.swipe-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 18px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transition: opacity 160ms ease;
}

.swipe-complete {
  justify-content: flex-start;
  background: var(--success);
}

.swipe-delete {
  justify-content: flex-end;
  background: var(--danger);
}

.task-swipe-shell.show-complete .swipe-complete,
.task-swipe-shell.show-delete .swipe-delete {
  opacity: 1;
}

.task-item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  border-left-width: 5px;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
  will-change: transform;
}

.task-item.is-swiping {
  transition: none;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.16);
}

.task-item.priority-high {
  border-left-color: var(--danger);
}

.task-item.priority-medium {
  border-left-color: var(--primary);
}

.task-item.priority-low {
  border-left-color: var(--success);
}

.task-toggle {
  width: 21px;
  height: 21px;
  margin-top: 2px;
  accent-color: var(--success);
}

.task-title {
  margin: 0 0 5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.task-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.priority-chip {
  display: inline-block;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.priority-chip.priority-high {
  background: rgba(220, 38, 38, 0.14);
  color: var(--danger);
}

.priority-chip.priority-medium {
  background: rgba(37, 99, 235, 0.14);
  color: var(--primary-dark);
}

.priority-chip.priority-low {
  background: rgba(21, 128, 61, 0.14);
  color: var(--success);
}

.task-item.is-completed {
  border-color: rgba(21, 128, 61, 0.45);
}

.task-item.is-location-triggered::after {
  content: "Lokacija";
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.task-item.is-completed .task-title {
  color: var(--success);
  text-decoration: line-through;
}

.delete-button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  font-weight: 700;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden],
.view-panel[hidden],
.dialog[hidden] {
  display: none;
}

.calendar-header {
  margin-bottom: 14px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.calendar-day {
  min-height: 52px;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.calendar-day strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.calendar-day span {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.calendar-day.has-tasks span {
  background: var(--primary);
}

.calendar-day.is-today {
  border-color: var(--primary);
}

.calendar-day.is-muted {
  visibility: hidden;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.35);
  font-size: 34px;
  line-height: 1;
}

.dialog {
  position: fixed;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 16px;
  background: rgba(15, 23, 42, 0.46);
  z-index: 5;
}

.dialog-panel {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.dialog-header {
  margin-bottom: 16px;
}

.task-form {
  display: grid;
  gap: 14px;
}

.location-picker {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.location-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.location-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.task-map {
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.leaflet-container {
  font-family: Arial, sans-serif;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input[type="text"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface-soft);
}

input[readonly] {
  color: var(--muted);
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--primary);
  outline: 3px solid rgba(37, 99, 235, 0.18);
}

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

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

.checkbox-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--success);
}

.task-form button[type="submit"] {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 28px;
  }

  .task-item {
    grid-template-columns: auto 1fr auto;
    align-items: center;
  }

  .task-meta {
    margin-bottom: 0;
  }

  .dialog {
    align-items: center;
  }
}

@media (max-width: 420px) {
  .dashboard-panel .section-title {
    display: grid;
    align-items: stretch;
  }

  .dashboard-panel .status-actions {
    justify-content: stretch;
  }

  .dashboard-panel .status-actions > * {
    flex: 1;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .location-header {
    display: grid;
  }

  .location-header .secondary-button {
    width: 100%;
  }

  .status-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .status-actions {
    justify-content: stretch;
  }

  .status-actions button {
    flex: 1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 46px;
  }
}
