/* Customer portal styles — hand-authored for the MVP (see README). */
:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok-bg: #ecfdf5; --ok-ink: #065f46; --ok-line: #6ee7b7;
  --err-bg: #fef2f2; --err-ink: #991b1b; --err-line: #fca5a5;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #f1f5f9;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f5f9; padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* top bar */
.topbar { background: var(--bg); color: #e2e8f0; }
.topbar-inner {
  max-width: 1040px; margin: 0 auto; padding: 0 20px; height: 60px;
  display: flex; align-items: center; gap: 24px;
}
.brand { font-weight: 700; color: #fff; font-size: 18px; }
.brand span { color: #93c5fd; font-weight: 600; }
.brand-lg { font-size: 24px; }
.nav { display: flex; gap: 18px; margin-left: 8px; flex: 1; }
.nav a { color: #cbd5e1; font-size: 14px; font-weight: 500; }
.nav a:hover { color: #fff; text-decoration: none; }
.nav .nav-admin { color: #fbbf24; }
.logout { display: flex; align-items: center; gap: 12px; }
.who { color: #94a3b8; font-size: 13px; }

/* layout */
.container { max-width: 1040px; margin: 0 auto; padding: 28px 20px 64px; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .muted { width: 100%; margin: 0; }
.page-head .btn { margin-left: auto; }
.back { font-size: 13px; color: var(--muted); width: 100%; }
.muted { color: var(--muted); }
.right { text-align: right; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px;
}
.card-title { margin: 0 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-patch { background: #eff6ff; color: #1d4ed8; }
.badge-cli { background: #f5f3ff; color: #6d28d9; }
.badge-other { background: #f1f5f9; color: #475569; }

/* buttons */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer;
  line-height: 1.1; transition: background .12s, border-color .12s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: #334155; color: #cbd5e1; }
.btn-ghost:hover { background: #334155; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-inline { display: flex; flex-direction: row; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span, .field > legend { font-weight: 600; font-size: 13px; }
.field-sm { max-width: 110px; }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  background: #fff; color: var(--ink); width: 100%; font-family: inherit;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
/* Inline forms lay fields out in a row with sensible widths. */
.form-inline .field { margin: 0; width: 260px; }
.form-inline .field.field-sm { width: 90px; }
.form-inline > input { width: 200px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
fieldset.field { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 12px; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.upload-status { font-size: 13px; }

/* alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; border: 1px solid; }
.alert-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
.alert-err { background: var(--err-bg); color: var(--err-ink); border-color: var(--err-line); }

/* empty states */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty p { margin: 6px 0; }
.error-page h1 { font-size: 56px; margin: 0; color: var(--ink); }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--ink); }
.stat-label { font-size: 13px; color: var(--muted); }

/* login */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15,23,42,.12); padding: 32px; width: 100%; max-width: 400px;
}
.login-head { text-align: center; margin-bottom: 24px; }
.login-head .muted { margin: 10px 0 0; font-size: 14px; }
/* The brand is white for the dark topbar; on the white login card make it dark. */
.login-head .brand { color: var(--ink); }
.login-head .brand span { color: var(--brand); }

/* inline edit/delete actions in a table cell */
.row-actions { display: inline-flex; gap: 8px; align-items: center; justify-content: flex-end; }

/* per-bundle conversation */
.chat { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); }
.msg-meta { font-size: 12px; margin-bottom: 4px; display: flex; gap: 8px; align-items: baseline; }
.msg-body { white-space: pre-wrap; font-size: 14px; }
.msg-customer { align-self: flex-start; background: #fff; }
.msg-support { align-self: flex-end; background: #eff6ff; border-color: #bfdbfe; }
.chat-form textarea { width: 100%; }

/* api token reveal */
.token-new { border: 1px solid var(--ok-line); background: var(--ok-bg); }
.token-value { background: var(--bg); color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.token-value code { background: none; color: inherit; padding: 0; font-size: 13px; }

/* upload progress bar */
.upload-progress {
  vertical-align: middle; margin-left: 10px; width: 220px; height: 10px;
  border: none; border-radius: 999px; overflow: hidden; background: var(--line);
  -webkit-appearance: none; appearance: none;
}
.upload-progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
.upload-progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; transition: width .15s ease; }
.upload-progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }

/* confirmation modal */
.modal {
  border: none; border-radius: var(--radius); padding: 0;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 10px 30px rgba(15,23,42,.25); color: var(--ink);
}
.modal::backdrop { background: rgba(15,23,42,.5); }
.modal-card { margin: 0; padding: 22px; }
.modal-msg { margin: 0 0 18px; font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* admin shell with left sidebar */
.admin-shell { display: grid; grid-template-columns: 210px 1fr; gap: 28px; align-items: start; }
.sidebar { position: sticky; top: 20px; }
.side-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; padding-left: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link { display: block; padding: 8px 12px; border-radius: 8px; color: #334155; font-weight: 500; font-size: 14px; }
.side-link:hover { background: #eef2f7; text-decoration: none; }
.side-link.is-active { background: var(--brand); color: #fff; }
.side-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 4px 14px; padding-left: 10px; border-left: 1px solid var(--line); }
.side-sublink { padding: 5px 10px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.side-sublink:hover { background: #eef2f7; color: var(--ink); text-decoration: none; }
.admin-main { min-width: 0; }

/* card header with a trailing action */
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head .card-title { margin: 0; }
.card-head .btn { margin-left: auto; }

/* rendered markdown (product/artifact descriptions) */
.prose { color: #1e293b; font-size: 15px; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: .5em 0; }
.prose ul, .prose ol { margin: .5em 0; padding-left: 1.4em; }
.prose a { color: var(--brand); }
.prose code { background: #f1f5f9; padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.prose pre { background: var(--bg); color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: .8em 0 .3em; line-height: 1.25; }
.prose blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.prose table { border-collapse: collapse; margin: .5em 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.prose-sm { font-size: 13px; }
.art-name { font-weight: 500; }
.art-desc { margin-top: 4px; color: var(--muted); max-width: 52ch; }

@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-inner { gap: 12px; }
  .admin-shell { grid-template-columns: 1fr; gap: 16px; }
  .sidebar { position: static; }
  .side-nav { flex-flow: row wrap; }
  .side-sub { display: none; }
}
