/* Kapu design system, matching the wholesale portal: orange on white with
   teal accents, Plus Jakarta Sans, 12px radii, and the gradient top bar. */

:root {
  --orange: #ff6700;
  --orange-soft: #fff3eb;
  --orange-border: #ffd0b0;
  --orange-deep: #c2410c;
  --teal: #00ba77;
  --teal-dark: #006d56;
  --teal-soft: #e6faf2;
  --teal-border: #8fedd2;
  --ink: #111111;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --line: #e5e7eb;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --danger: #b42318;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --radius-lg: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: "Plus Jakarta Sans", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
a { color: var(--orange-deep); }

.top-bar {
  height: 4px;
  background: linear-gradient(90deg, var(--orange) 0%, #ff9a00 50%, var(--teal) 100%);
  flex-shrink: 0;
}

/* ---- App shell ---- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-wordmark { display: block; height: 15px; width: auto; }

.brand-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.header-right { display: flex; align-items: center; gap: 10px; }

.who {
  font-size: 13px;
  color: var(--muted-strong);
  display: flex;
  align-items: center;
  gap: 8px;
}

.who strong { color: var(--ink); font-weight: 700; }

.role-pill {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid var(--teal-border);
}

.role-pill.admin { background: var(--orange-soft); color: var(--orange-deep); border-color: var(--orange-border); }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

.page.narrow { max-width: 760px; }

.page-head { margin-bottom: 22px; }

.kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-dark);
  font-weight: 700;
  margin: 0 0 6px;
}

h1 { font-size: 27px; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 6px; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }

.sub { color: var(--muted); font-size: 14.5px; margin: 0; line-height: 1.5; }

/* ---- Cards, forms, buttons ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.card + .card { margin-top: 16px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

label { display: grid; gap: 7px; font-size: 13px; color: var(--ink); font-weight: 600; }

input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 11px 13px;
  color: var(--ink);
}

input:focus, select:focus { outline: none; border-color: var(--teal); }

.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--orange);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(255, 103, 0, 0.22);
  white-space: nowrap;
}

.btn:hover:not(:disabled) { filter: brightness(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  box-shadow: none;
  font-weight: 700;
  padding: 8px 12px;
  font-size: 13px;
}

.btn.ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--muted); filter: none; }

.btn.danger { background: #fff; color: var(--danger); border: 1.5px solid #f3c6c1; box-shadow: none; }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); filter: none; }

.btn.wide { width: 100%; }
.btn.small { padding: 7px 11px; font-size: 12.5px; box-shadow: none; }

.hint { color: var(--muted); font-size: 13.5px; line-height: 1.5; font-weight: 400; margin: 0; }

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 40px;
  height: 22px;
  margin: 3px 0 0;
  accent-color: var(--orange);
  flex-shrink: 0;
}

.toggle-row span { display: grid; gap: 4px; min-width: 0; }
.toggle-row strong { font-size: 14.5px; }

.error-text {
  color: var(--danger);
  font-size: 13.5px;
  background: var(--danger-soft);
  border: 1px solid #f3c6c1;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0;
}

.notice {
  background: var(--orange-soft);
  border: 1px solid var(--orange-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--orange-deep);
  line-height: 1.5;
}

.notice code, .mono { font-family: var(--mono); }

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px dashed var(--orange-border);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-top: 8px;
}

.copy-row span { font-family: var(--mono); font-size: 14px; color: var(--ink); flex: 1; word-break: break-all; }

/* ---- Login ---- */

.auth-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  position: relative;
  background: #fff;
  padding: 0 16px 48px;
}

.auth-center { flex: 1; display: grid; place-items: center; width: 100%; padding: 24px 0; }

.auth-card { width: min(400px, 100%); text-align: center; }

.login-brand { display: grid; justify-items: center; gap: 9px; margin-bottom: 26px; }

.login-brand span {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

.login-brand span + span {
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--teal-dark);
  margin-top: -4px;
}

.auth-card h1 { font-size: 26px; margin: 0; }
.auth-sub { margin: 8px 0 26px; color: var(--muted); font-size: 14.5px; }
.auth-fields { text-align: left; display: grid; gap: 14px; }

/* ---- Tables ---- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 11px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }

tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }

td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

td.notes { max-width: 280px; }

.note-cell { display: grid; gap: 6px; justify-items: start; }

.note-line {
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

.note-line.note-error { color: var(--danger); }

.note-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(80vh, 720px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  box-shadow: 0 18px 50px rgba(17, 17, 17, 0.16);
}

.note-dialog::backdrop { background: rgba(17, 17, 17, 0.35); }

.note-dialog h2 { font-size: 18px; margin: 0; }

.note-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  max-height: 58vh;
  overflow: auto;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--ink);
}

.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---- Tabs ---- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }

.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}

.tab:hover { color: var(--ink); }
.tab.active { color: var(--orange-deep); border-bottom-color: var(--orange); }

/* ---- Event badges ---- */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted-strong);
  white-space: nowrap;
}

.badge.ok { background: var(--teal-soft); color: var(--teal-dark); }
.badge.warn { background: var(--orange-soft); color: var(--orange-deep); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters label { font-size: 12px; }
.filters select, .filters input { min-width: 150px; }

@media (max-width: 640px) {
  .app-header { padding: 10px 14px; }
  .brand-tag { display: none; }
  .page { padding: 20px 14px 56px; }
  .filters select, .filters input { min-width: 0; }
}
