:root {
  --bg: #f4f6f9;
  --sidebar: #11243b;
  --sidebar-2: #0c1b2e;
  --accent: #f59e0b;     /* KLRStec "tool" amber */
  --accent-2: #2563eb;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #ffffff;
  --good: #16a34a;
  --warn: #dc2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: "SFMono-Regular", Consolas, monospace;
  background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 0.85em;
}

.layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #cdd7e4; display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent); color: #11243b; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; color: #fff; font-size: 17px; }
.brand-sub { font-size: 12px; color: #8da3bd; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  color: #cdd7e4; padding: 10px 12px; border-radius: 8px; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav-link.active { background: var(--accent); color: #11243b; font-weight: 700; }
.nav-link .ic { width: 18px; text-align: center; opacity: .9; }

.markets { margin-top: 26px; padding: 0 8px; }
.markets-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8da3bd; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: rgba(255,255,255,.1); color: #e4ecf5;
  border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600;
}

.sidebar-foot { margin-top: auto; padding: 14px 8px 0; font-size: 12px; color: #6f86a3; }
.sidebar-foot .who { margin-bottom: 6px; }
.sidebar-foot .who strong { color: #cdd7e4; }
.sidebar-foot .logout {
  display: inline-block; color: #cdd7e4; background: rgba(255,255,255,.06);
  padding: 6px 10px; border-radius: 7px; font-weight: 600; margin-bottom: 12px;
}
.sidebar-foot .logout:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.sidebar-foot .org { color: #6f86a3; }

/* ---- Login page ---- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #11243b, #0c1b2e);
}
.login-card {
  width: 340px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 14px; padding: 28px 26px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 14px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
/* On the white card the sidebar's white brand-name would be invisible. */
.login-brand .brand-name { color: var(--text); }
.login-brand .brand-sub { color: var(--muted); }
.login-card .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card .field input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; color: var(--text);
}
.login-card .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #fde9c0; }
.login-btn { width: 100%; padding: 11px; font-size: 15px; margin-top: 4px; }
.login-error {
  background: #fef2f2; color: var(--warn); border: 1px solid #fecaca;
  padding: 9px 12px; border-radius: 8px; font-size: 13px;
}
.login-warn {
  background: #fffbeb; color: #92400e; border: 1px solid #fcd9a3;
  padding: 9px 12px; border-radius: 8px; font-size: 13px;
}

/* ---- Content ---- */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; margin: 0; }
.integrations { display: flex; gap: 8px; }
.badge { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 20px; border: 1px solid; }
.badge.ok  { color: var(--good); border-color: #bbf7d0; background: #f0fdf4; }
.badge.off { color: var(--muted); border-color: var(--line); background: #f9fafb; }

.page { padding: 24px 28px; }
.hint { color: var(--muted); margin-top: 0; }

/* ---- Cards / grids ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card h2 { margin: 0 0 12px; font-size: 15px; }

.metric { display: flex; flex-direction: column; gap: 4px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.metric-foot { color: var(--muted); font-size: 12px; }

.checklist, .steps { margin: 0; padding-left: 0; list-style: none; }
.steps { padding-left: 18px; list-style: decimal; }
.steps li { margin: 6px 0; }
.checklist li { padding: 6px 0 6px 26px; position: relative; }
.checklist li::before { position: absolute; left: 0; font-weight: 700; }
.checklist li.done::before { content: "✓"; color: var(--good); }
.checklist li.todo::before { content: "○"; color: var(--muted); }

/* ---- Messages ---- */
.messages { display: flex; flex-direction: column; gap: 14px; }
.message-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.message-product { color: var(--muted); font-size: 13px; margin: 6px 0; }
.message-body { margin: 8px 0 12px; }
.muted { color: var(--muted); font-weight: 400; }
.btn {
  background: var(--accent); color: #11243b; border: none; cursor: pointer;
  font-weight: 700; padding: 9px 14px; border-radius: 8px; font-size: 14px;
}
.btn:hover { filter: brightness(1.05); }
.draft {
  width: 100%; margin-top: 12px; min-height: 90px; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-family: inherit; font-size: 14px;
}
.draft:not(:placeholder-shown) { background: #fffdf5; border-color: #fcd9a3; }

/* ---- Reports ---- */
.report h2 { font-size: 15px; }
.placeholder-chart {
  margin-top: 12px; height: 120px; border-radius: 8px;
  border: 1px dashed var(--line); display: flex; align-items: center;
  justify-content: center; color: var(--muted); font-size: 13px;
  background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 10px, #f3f5f8 10px, #f3f5f8 20px);
}

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.table .right { text-align: right; }
.status-pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.status-pill.good { color: var(--good); background: #f0fdf4; }
.status-pill.warn { color: var(--warn); background: #fef2f2; }

/* ---- Topbar right + marketplace selector ---- */
.topbar-right { display: flex; align-items: center; gap: 16px; }
.mp-selector { display: flex; align-items: center; gap: 10px; }
.mp-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.mp-region { font-size: 12px; font-weight: 700; color: var(--text); }
.mp-endpoint { font-size: 11px; color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; }
#mp-select {
  appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 34px 9px 12px;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; min-width: 160px;
}
#mp-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #fde9c0; }

/* active marketplace chip in the sidebar */
.chip.chip-active { background: var(--accent); color: #11243b; }
.markets .markets-label { margin-top: 14px; }
.markets .markets-label:first-child { margin-top: 0; }

/* ---- SP-API routing card ---- */
.card.routing { margin-top: 16px; }
.routing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.routing-grid > div { display: flex; flex-direction: column; gap: 3px; }
.routing-grid .rk { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.routing-grid .rv { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Empty state ---- */
.empty-state { color: var(--muted); }

/* ---- API error banner ---- */
.api-error {
  background: #fef2f2; color: var(--warn); border: 1px solid #fecaca;
  border-radius: 10px; padding: 11px 16px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.5;
}
.api-error small { color: #b91c1c; }

/* ---- Info banner (neutral) ---- */
.info-banner {
  background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe;
  border-radius: 10px; padding: 11px 16px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.5;
}

@media (max-width: 720px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .brand-text, .markets, .sidebar-foot, .nav-link span:not(.ic) { display: none; }
  .nav-link { justify-content: center; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-right { flex-wrap: wrap; gap: 10px; }
  .mp-meta { display: none; }
}
