/* parttoo Admin — mobile-first stylesheet */
:root {
  --ink: #16212e;
  --ink-2: #47576b;
  --ink-3: #7b8b9e;
  --line: #e3e8ef;
  --bg: #f5f7fa;
  --card: #ffffff;
  --brand: #082B50;
  --brand-2: #23405c;
  --sale: #F20D16;
  --ok: #1f9d55;
  --warn: #d98324;
  --bad: #d64545;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 51, .06), 0 6px 18px -12px rgba(16, 32, 51, .28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* the hidden attribute must beat the display rules below */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ───────────── login ───────────── */
.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: radial-gradient(120% 90% at 50% 0%, #23405c 0%, var(--brand) 55%, #101a26 100%);
  background-color: var(--brand);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .55);
}

.brand { display: flex; align-items: center; gap: .75rem; }
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: .95rem; letter-spacing: .02em;
  flex: none;
}
.brand h1 { font-size: 1.15rem; line-height: 1.2; }
/* the storefront logotype (inline SVG symbol #parttoo-logo): PARTT takes the
   surrounding colour, OO stays brand red. The login h1 sits on a white card,
   so PARTT is navy there. */
.brand h1.brand-h1 { margin: 0; line-height: 0; }
.logo {
  display: block;
  height: 1.15rem;
  width: auto;
  aspect-ratio: 348.624 / 57.281;
  color: var(--brand);
}
.brand p { margin: .1rem 0 0; font-size: .85rem; color: var(--ink-3); }

.brand-sm .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: .8rem; }
/* the topbar sits on navy, so the mark is white there */
.logo-sm { height: .95rem; color: #fff; }

/* ───────────── form fields ───────────── */
/* <label class="field"><span>Label</span><input …></label> — stacked on
   every surface (login card, modal forms) so labels never sit inline. */
.field { display: block; margin-top: 1rem; }
.field > span {
  display: block;
  margin-bottom: .35rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-2);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .7rem;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(8, 43, 80, .14);
}
.field input[readonly] { background: #f5f7fa; color: var(--ink-2); }
.field textarea { min-height: 6rem; resize: vertical; }

/* ───────────── buttons ───────────── */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: .6rem 1rem;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.18); }
.btn-ghost { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .22); }
.btn-ghost:hover { background: rgba(255, 255, 255, .18); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--ink-3); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f0c9c9; }
.btn-danger:hover { background: #fdf2f2; }
.btn-block { display: block; width: 100%; margin-top: 1.25rem; padding: .8rem; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; border-radius: 8px; }

.icon-btn {
  border: none; background: none; cursor: pointer;
  font-size: 1.5rem; line-height: 1; color: var(--ink-3);
  padding: 0 .25rem;
}

/* ───────────── app shell ───────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  padding: .7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}

.tabs {
  max-width: 1180px; margin: 0 auto;
  display: flex; gap: .25rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 .5rem .5rem;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .62);
  background: none;
  border: none;
  border-radius: 8px;
  padding: .45rem .7rem;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, .09); }
.tab.active { color: var(--brand); background: #fff; }

/* ───────────── segmented sub-tabs ───────────── */
.seg {
  display: flex; gap: .25rem;
  padding: .35rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: .85rem;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.seg[hidden] { display: none !important; }
.seg-btn {
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: .4rem .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { color: #fff; background: var(--brand); }

/* nested tabs: department -> view */
.seg.sub {
  background: transparent;
  border: none;
  padding: 0;
  gap: .3rem;
  border-radius: 0;
  width: auto;
  flex-wrap: wrap;
  overflow: visible;
  margin-bottom: .55rem;
}
.seg.sub .seg-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .32rem .8rem;
  font-size: .76rem;
}
.seg.sub .seg-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.run-item pre { max-height: 160px; }
.run-list .run-dropped { font-style: italic; }

/* collapsed model prompt */
details.prompt summary {
  cursor: pointer;
  font-size: .78rem;
  color: var(--brand);
  font-weight: 600;
  white-space: nowrap;
}
details.prompt .run-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .4rem;
}
.run-item .run-head {
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0;
}
details.prompt pre {
  margin: .4rem 0 0;
  min-width: 260px;
  max-width: 420px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .74rem;
  line-height: 1.4;
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .5rem;
}

/* ───────────── bottom nav (app-like) ───────────── */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 18px rgba(15, 23, 42, .06);
}
.nav-item {
  font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  background: none; border: none;
  color: var(--muted);
  padding: .35rem .2rem;
  cursor: pointer;
  min-height: 44px;
  border-radius: 10px;
}
.nav-item svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-item span {
  font-size: .68rem; font-weight: 600; letter-spacing: .01em;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { color: var(--brand); }
.nav-item.active svg { stroke: var(--brand); }

.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom));
}

/* ───────────── cards & content ───────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.card-head h2 { font-size: 1rem; }
.card-head .sub { color: var(--ink-3); font-weight: 500; font-size: .85rem; }
.card-body { padding: 1rem; }
.card-body.tight { padding: 0; }

.toolbar {
  display: flex; gap: .5rem; align-items: center;
  padding: .75rem 1rem; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar input[type="search"], .toolbar input[type="text"] {
  flex: 1 1 12rem; min-width: 0;
  padding: .5rem .75rem;
  font: inherit; font-size: .9rem;
  border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.toolbar input:focus { border-color: var(--brand-2); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
thead th {
  text-align: left;
  padding: .6rem .75rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-3);
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky; top: 0;
}
tbody td { padding: .65rem .75rem; border-bottom: 1px solid #f1f4f8; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfcfd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: .35rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

/* badges */
.badge {
  display: inline-block;
  padding: .12rem .45rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-ok { background: #e8f6ee; color: #16794a; }
.badge-warn { background: #fdf2e3; color: #a56217; }
.badge-bad { background: #fdecec; color: #a72f2f; }
.badge-mute { background: #eef1f5; color: var(--ink-2); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.stat {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
}
.stat dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
.stat dd { margin: .2rem 0 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* progress bar */
.bar { height: 8px; background: #eef1f5; border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), #3f6f9c); border-radius: 999px; transition: width .4s ease; }

/* list rows */
.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem 1rem; border-bottom: 1px solid #f1f4f8;
  font-size: .88rem;
}
.row-item:last-child { border-bottom: none; }
.row-item[data-report-id] { cursor: pointer; }
.row-item[data-report-id]:hover { background: rgba(0, 0, 0, 0.03); }
.row-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* states */
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-3); font-size: .9rem; }
.error { padding: .75rem 1rem; background: #fdf2f2; color: var(--bad); font-size: .85rem; border-radius: 10px; margin: 1rem 0 0; }
.hint { color: var(--ink-3); font-size: .82rem; margin: .35rem 0 0; }
.skeleton { padding: 1.5rem 1rem; text-align: center; color: var(--ink-3); font-size: .88rem; }

/* ───────────── modal ───────────── */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(14, 24, 36, .55);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-panel {
  background: var(--card);
  width: 100%; max-width: 560px;
  max-height: 92vh; max-height: 92dvh;
  border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  box-shadow: 0 -12px 40px -12px rgba(0, 0, 0, .4);
  animation: sheet-in .2s ease;
}
@keyframes sheet-in { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.15rem; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 1.05rem; }
.modal-body {
  padding: 1.15rem; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal-body .field:first-child { margin-top: 0; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.modal-actions {
  display: flex; gap: .5rem; justify-content: flex-end;
  padding-top: 1.15rem; margin-top: 1.25rem; border-top: 1px solid var(--line);
}
.modal-actions .btn { flex: 1 1 auto; }

/* ───────────── toast ───────────── */
.toast {
  position: fixed;
  left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: #fff;
  font-size: .87rem;
  font-weight: 600;
  padding: .65rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .5);
  max-width: min(92vw, 30rem);
  text-align: center;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ───────────── ≥ 640px ───────────── */
@media (min-width: 640px) {
  .main { padding: 1.5rem 1.25rem 3rem; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal { align-items: center; padding: 1.5rem; }
  .modal-panel { border-radius: 16px; }
  .modal-actions .btn { flex: 0 0 auto; min-width: 7rem; }
}

/* ───────────── ≥ 900px ───────────── */
@media (min-width: 900px) {
  body { font-size: 15.5px; }
  .card-head { flex-wrap: nowrap; }
  .card-head h2 { font-size: 1.05rem; }
}