/* P2 Dispatch — shared styles */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600&family=Inter:wght@400;500;600;700&display=swap');

:root, body.theme-dark {
  --bg: #111113;
  --surface: #1a1a1e;
  --surface-2: #222228;
  --surface-3: #2b2b33;
  --border: #2f2f37;
  --border-strong: #42424c;
  --text: #ecebe8;
  --text-2: #b4b2ba;
  --muted: #8a8892;
  --accent: #b3303b;
  --accent-hover: #c83a46;
  --accent-soft: rgba(179, 48, 59, 0.16);
  --ok: #43a86f;
  --ok-soft: rgba(67, 168, 111, 0.15);
  --warn: #e0a73c;
  --warn-soft: rgba(224, 167, 60, 0.15);
  --danger: #e5544c;
  --danger-soft: rgba(229, 84, 76, 0.15);
  --info: #6c9bf0;
  --info-soft: rgba(108, 155, 240, 0.15);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  color-scheme: dark;
}
body.theme-light {
  --bg: #f3f2ef;
  --surface: #ffffff;
  --surface-2: #f6f5f2;
  --surface-3: #ebe9e4;
  --border: #e0ddd6;
  --border-strong: #c9c5bb;
  --text: #1b1a1d;
  --text-2: #45434a;
  --muted: #6f6c75;
  --accent: #9e2531;
  --accent-hover: #861f29;
  --accent-soft: rgba(158, 37, 49, 0.1);
  --ok: #217a4a;
  --ok-soft: rgba(33, 122, 74, 0.12);
  --warn: #9a6a0c;
  --warn-soft: rgba(196, 140, 20, 0.16);
  --danger: #c0392f;
  --danger-soft: rgba(192, 57, 47, 0.12);
  --info: #2f62c4;
  --info-soft: rgba(47, 98, 196, 0.1);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display {
  font-family: 'Oswald', 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
}
a { color: inherit; }
.ic { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  font: 600 13px/1 'Inter', sans-serif; cursor: pointer; text-decoration: none;
  white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.08); background: var(--ok); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { min-height: 52px; padding: 0 20px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.input, select.input, textarea.input {
  width: 100%; min-height: 38px; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font: 400 14px/1.3 'Inter', sans-serif;
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.input.invalid { border-color: var(--danger); }
.fields { display: grid; gap: 12px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) {
  .fields-2, .fields-3 { grid-template-columns: 1fr 1fr; }
}
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.field > label.check { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; color: var(--text); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Pills / chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
button.pill { border: none; cursor: pointer; font-family: inherit; }
button.pill:hover { filter: brightness(1.15); }

.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  font-size: 11px; font-weight: 700; background: var(--accent); color: #fff;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.card-pad { padding: 14px 16px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  font: 600 12px/1 'Inter', sans-serif; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---------- Modal / sheet ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 480px; margin: auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow);
}
.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; flex: 1; }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .overlay { padding: 0; align-items: stretch; }
  .modal { max-width: none; border-radius: 0; min-height: 100%; border: none; display: flex; flex-direction: column; }
  .modal-body { flex: 1; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); }
  .modal-head { position: sticky; top: 0; background: var(--surface); z-index: 2; }
}

/* ---------- Toast ---------- */
#toastHost { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #2d2d33; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; max-width: 90vw; }
.toast-ok { background: #1f7a48; }
.toast-error { background: #b3362e; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Menu ---------- */
.menu {
  position: fixed; z-index: 200; min-width: 200px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow);
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: none; background: none; border-radius: 6px;
  color: var(--text); font: 500 13px 'Inter', sans-serif; text-align: left; cursor: pointer;
}
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }
.menu hr { border: none; border-top: 1px solid var(--border); margin: 5px 0; }
