:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --border: #2a2e37;
    --text: #e5e7eb;
    --text-muted: #9aa1ac;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

/* Manual override via the navbar toggle - takes precedence over the OS
   preference above in both directions. */
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --border: #2a2e37;
  --text: #e5e7eb;
  --text-muted: #9aa1ac;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
}
.theme-toggle:hover { background: var(--bg); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.navbar .brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.navbar nav { display: flex; gap: 1rem; align-items: center; }
.navbar nav a { color: var(--text-muted); font-weight: 500; }
.navbar nav a:hover { color: var(--text); text-decoration: none; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}
.container.narrow { max-width: 480px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.stack > * + * { margin-top: 0.75rem; }

.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.form-field .hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

[x-cloak] { display: none !important; }

.provider-picker { position: relative; min-width: 220px; }
.provider-picker-input { position: relative; }
.provider-picker-input input { padding-right: 2rem; }
.provider-picker-chevron {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.15s ease;
  pointer-events: none;
}
.provider-picker-input.open .provider-picker-chevron { transform: translateY(-30%) rotate(-135deg); }

.provider-dropdown {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  width: 100%;
  margin-top: 4px;
  padding: 0.3rem;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.provider-dropdown li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: calc(var(--radius) - 3px);
  cursor: pointer;
  font-size: 0.9rem;
}
.provider-dropdown li:hover { background: var(--bg); }
.provider-dropdown li.active { background: var(--primary); color: #fff; }
.provider-dropdown li.no-match { cursor: default; color: var(--text-muted); }
.provider-dropdown li.no-match:hover { background: transparent; }
.provider-picker-check { font-weight: 700; }

input[type="text"], input[type="email"], input[type="password"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn.secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-muted);
}
.badge.active { background: rgba(79, 70, 229, 0.15); color: var(--primary); }
.badge.completed { background: rgba(22, 163, 74, 0.15); color: var(--success); }
.badge.error { background: rgba(220, 38, 38, 0.15); color: var(--danger); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 1rem 1.25rem;
  border-left: 2px solid var(--border);
}
.timeline li:last-child { border-color: transparent; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.3rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.timeline .when { font-size: 0.8rem; color: var(--text-muted); }
.timeline .location { font-size: 0.85rem; color: var(--text-muted); }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error { background: rgba(220, 38, 38, 0.1); color: var(--danger); border: 1px solid rgba(220, 38, 38, 0.3); }
.alert.success { background: rgba(22, 163, 74, 0.1); color: var(--success); border: 1px solid rgba(22, 163, 74, 0.3); }
.alert.info { background: rgba(79, 70, 229, 0.1); color: var(--primary); border: 1px solid rgba(79, 70, 229, 0.3); }

.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters .form-field { margin-bottom: 0; min-width: 150px; }

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
