:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #d0d7de;
  --border-soft: #e6eaef;
  --text: #1f2328;
  --muted: #6e7781;
  --primary: #2d6a4f;
  --primary-dark: #1b4332;
  --primary-soft: #d8ebe1;
  --warn: #f59f00;
  --warn-soft: #fff4d6;
  --danger: #cf222e;
  --danger-soft: #ffebe9;
  --ok: #2da44e;
  --ok-soft: #dafbe1;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.muted { color: var(--muted); }
.mono { font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 12.5px; }

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.topbar .brand { display: flex; align-items: baseline; gap: 12px; }
.topbar .brand strong { font-size: 16px; }
.topbar .brand .muted { color: rgba(255,255,255,0.75); font-size: 12px; }
.topbar .actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: #f0f2f4; }
.btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: #6e4d00;
}
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 12.5px;
  padding: 2px 4px;
}
.btn-link:hover { text-decoration: underline; }
.btn-revert { color: var(--warn); }

#lastUpdated { font-variant-numeric: tabular-nums; }

.board {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  gap: 12px;
  padding: 12px;
  align-items: stretch;
}

.column {
  flex: 0 0 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  min-height: 0;
}
.column-special { background: #fafbfc; }
.column-overdue { border-color: var(--danger); }
.column-overdue .column-header { background: var(--danger-soft); }
.column-hidden { display: none; }

.column-header {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f6f8fa;
  border-radius: 8px 8px 0 0;
}
.column-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text);
}
.column-header .count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.column-cards {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.12s ease, transform 0.12s ease;
  user-select: none;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card:active { cursor: grabbing; }
.card-confirmed { border-left: 4px solid var(--ok); }
.card-unconfirmed { border-left: 4px solid var(--warn); background: #fffdf7; }
.card-ghost { opacity: 0.4; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  gap: 6px;
}
.card-no { font-weight: 600; font-size: 13px; }
.card-cust { font-size: 13px; margin-bottom: 2px; }
.card-deliv { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.card-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.card-flags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.card-foot {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-ok { background: var(--ok-soft); color: var(--primary-dark); }
.badge-warn { background: var(--warn-soft); color: #6e4d00; }

.pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 4px;
}
.pill-red { background: var(--danger-soft); color: var(--danger); }
.pill-amber { background: var(--warn-soft); color: #6e4d00; }

.flag {
  display: inline-block;
  background: #eef2f5;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--muted);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.modal-panel {
  position: relative;
  background: var(--surface);
  border-radius: 10px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.modal-head h2 { margin: 0 0 4px 0; font-size: 18px; }
.modal-section { margin-bottom: 16px; }
.modal-section h3 {
  margin: 0 0 6px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.modal-section p { margin: 4px 0; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.items-table th, .items-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}
.items-table th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
}
.items-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.items-table .row-partial { background: var(--warn-soft); }

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-width: 80vw;
}
.toast.hidden { display: none; }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--danger); }

/* Settings page */
.settings-wrap {
  max-width: 720px;
  margin: 24px auto;
  padding: 0 16px;
}
.settings-wrap h1 { font-size: 22px; margin: 0 0 4px 0; }
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-top: 16px;
}
.settings-card h2 { font-size: 16px; margin: 0 0 12px 0; }
.holiday-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.holiday-row:last-child { border-bottom: none; }
.holiday-add {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.holiday-add input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}
.holiday-empty {
  color: var(--muted);
  font-style: italic;
  padding: 12px 0;
}
