:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e6eb;
  --text: #1f2933;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #047857;
  --error: #b91c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem 1rem;
}

.page { max-width: 800px; margin: 0 auto; }
.page.hidden { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

#login-page .card { max-width: 420px; margin: 4rem auto; }

h1 { margin: 0 0 0.5rem; font-size: 1.5rem; }
h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }

.subtitle, .hint {
  color: var(--muted);
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.user-info { display: flex; align-items: center; gap: 1rem; }
.user-info span { color: var(--muted); font-size: 0.9rem; }

form { display: flex; flex-direction: column; gap: 1rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; }
label small { color: var(--muted); font-weight: normal; }

input[type="text"],
input[type="password"],
input[type="number"] {
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

input.full { width: 100%; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover:not(:disabled) { background: var(--primary-hover); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
button.secondary:hover:not(:disabled) { background: #eff6ff; }

button.danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}
button.danger:hover { background: #fef2f2; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.5rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; border-bottom: 1px solid var(--border); }
td { padding: 0.5rem 0.25rem; }
td input { width: 100%; }
td:last-child { width: 50px; text-align: right; }

#add-staffel, #add-leverancier, #add-deelvracht, #add-periode { margin-top: 0.5rem; }

label.single {
  max-width: 320px;
}

.hint code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.85em;
}

.hint.preview {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.periode-kaart {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.periode-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
}

.periode-header label.grow {
  grid-column: 1;
}

.periode-header .danger {
  height: 38px;
  padding: 0 0.75rem;
  white-space: nowrap;
}

.kmzones-tabel {
  font-size: 0.85rem;
}

.kmzones-tabel th, .kmzones-tabel td {
  padding: 0.3rem 0.4rem;
}

.kmzones-tabel td input {
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
}

.kmzones-tabel th:nth-child(2),
.kmzones-tabel td:nth-child(2) { width: 30%; }

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 2rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  z-index: 10;
}

#save-btn {
  padding: 0.7rem 1.5rem;
  background: var(--success);
}
#save-btn:hover { background: #065f46; }

.status {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
.status.hidden { display: none; }
.status.success { background: #ecfdf5; color: var(--success); }
.status.error { background: #fef2f2; color: var(--error); }
