:root {
  color-scheme: light;
  --red: #c8102e;
  --red-dark: #980b21;
  --black: #101010;
  --ink: #222;
  --muted: #6a6a6a;
  --line: #e7e7e7;
  --surface: #fff;
  --soft: #f6f6f6;
  --danger-soft: #fff0f2;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f4f4f4 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell[hidden],
.login-screen[hidden] {
  display: none;
}

.login-screen {
  align-items: center;
  background: var(--black);
  display: flex;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-box h1 {
  color: var(--black);
  font-size: 34px;
  line-height: 1;
  margin: 0;
}

.login-error {
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
  min-height: 20px;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  align-items: center;
  background: var(--black);
  color: white;
  display: flex;
  justify-content: space-between;
  min-height: 92px;
  padding: 20px clamp(16px, 4vw, 42px);
}

.topbar h1,
.panel h2,
.task-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.eyebrow {
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.status-pill,
.count-badge {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-pill {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.status-pill.online {
  background: var(--red);
}

.layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(360px, 1.25fr) minmax(320px, 0.95fr);
  margin: 0 auto;
  max-width: 1360px;
  padding: 22px clamp(14px, 3vw, 32px) 36px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.task-form-panel,
.task-list-panel {
  padding: 18px;
}

.panel-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel h2 {
  color: var(--black);
  font-size: 22px;
  line-height: 1.15;
}

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

label {
  color: var(--black);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 6px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #d7d7d7;
  border-radius: 6px;
  color: var(--black);
  min-height: 42px;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.14);
  outline: none;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-actions,
.filters,
.task-actions {
  display: flex;
  gap: 8px;
}

.primary-button,
.secondary-button,
.ghost-button,
.filter,
.icon-button,
.logout-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 9px 13px;
}

.primary-button {
  background: var(--red);
  color: white;
  flex: 1;
}

.primary-button:hover {
  background: var(--red-dark);
}

.secondary-button,
.ghost-button,
.filter,
.icon-button,
.logout-button {
  background: var(--soft);
  color: var(--black);
}

.logout-button {
  background: white;
}

.ghost-button {
  border: 1px solid var(--line);
  white-space: nowrap;
}

.filters {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.date-filter {
  margin-bottom: 12px;
}

.filter.active {
  background: var(--black);
  color: white;
}

.count-badge {
  background: var(--danger-soft);
  color: var(--red);
  min-width: 44px;
}

.route-summary {
  background: var(--soft);
  border-left: 4px solid var(--red);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 42px;
  padding: 10px 12px;
}

.tasks {
  display: grid;
  gap: 10px;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  padding: 14px;
}

.task-card.overdue {
  background: var(--danger-soft);
  border-color: rgba(200, 16, 46, 0.32);
}

.task-title-row {
  align-items: start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.task-card h3 {
  color: var(--black);
  font-size: 18px;
  line-height: 1.2;
}

.priority {
  background: var(--black);
  border-radius: 999px;
  color: white;
  display: none;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.priority.visible {
  display: inline-flex;
}

.client,
.address,
.meta,
.notes {
  margin: 7px 0 0;
}

.client {
  font-weight: 800;
}

.address,
.meta,
.notes {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.notes:empty {
  display: none;
}

.client:empty,
.address:empty {
  display: none;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.task-actions {
  align-content: start;
  flex-direction: column;
  min-width: 142px;
}

.quick-status {
  min-height: 40px;
}

.empty {
  color: var(--muted);
  padding: 22px 10px;
  text-align: center;
}

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

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .grid.two,
  .grid.three,
  .task-card {
    grid-template-columns: 1fr;
  }

  .task-actions {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 0;
  }

  .task-actions > * {
    flex: 1 1 120px;
  }

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