/* Northwind Explorer — same WP-admin look as the SQLite3 Complete Guide.
   CSP is style-src 'self': no style="" attributes anywhere; everything is here. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --wp-blue: #2271b1;
  --wp-blue-dark: #135e96;
  --wp-blue-light: #e8f0fb;
  --wp-nav-bg: #1d2327;
  --wp-nav-text: #a7aaad;
  --wp-nav-active: #72aee6;
  --sidebar-w: 240px;
  --header-h: 56px;
  --bg: #f0f0f1;
  --surface: #ffffff;
  --border: #c3c4c7;
  --border-soft: #dcdcde;
  --text: #1d2327;
  --text-muted: #50575e;
  --text-light: #787c82;
  --code-bg: #1d2327;
  --code-text: #72aee6;
  --success: #00a32a;
  --warning: #dba617;
  --error: #d63638;
  --gold: #9a6b00;
  --radius: 4px;
}

html, body { min-height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { color: var(--wp-blue); }
code, .mono { font-family: 'JetBrains Mono', monospace; }

/* ── Admin bar ── */
.nw-bar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); z-index: 100;
  background: var(--wp-nav-bg); border-bottom: 1px solid #3c434a;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.nw-logo { display: flex; align-items: center; gap: 10px; color: #a7aaad; font-weight: 700; font-size: 15px; text-decoration: none; white-space: nowrap; }
.nw-logo svg { width: 26px; height: 26px; }
.nw-logo span { color: var(--wp-nav-active); }
.nw-bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nw-badge-ro {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: #f0c33c;
  border: 1px solid #6b5a1e; background: rgba(240,195,60,.08); padding: 3px 10px; border-radius: 12px;
}
.nw-badge-ro svg { width: 12px; height: 12px; }

/* ── Sidebar ── */
.nw-sidebar {
  position: fixed; top: var(--header-h); left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--wp-nav-bg); border-right: 1px solid #3c434a; overflow-y: auto; z-index: 90;
  padding-bottom: 24px;
}
.nw-sidebar::-webkit-scrollbar { width: 4px; }
.nw-sidebar::-webkit-scrollbar-thumb { background: #3c434a; border-radius: 2px; }
.nw-side-label { font-size: 11px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .8px; padding: 18px 16px 6px; }
.nw-side-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 16px; font-size: 13px; font-weight: 500;
  color: var(--wp-nav-text); text-decoration: none; border-left: 3px solid transparent;
}
.nw-side-item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nw-side-item.active { color: var(--wp-nav-active); background: rgba(114,174,230,.08); border-left-color: var(--wp-nav-active); }
.nw-side-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nw-side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-side-count { font-size: 11px; color: var(--text-light); font-variant-numeric: tabular-nums; }
.nw-side-item.active .nw-side-count { color: var(--wp-nav-active); }

/* ── Main ── */
.nw-main { margin-left: var(--sidebar-w); margin-top: var(--header-h); padding: 24px 28px 40px; min-height: calc(100vh - var(--header-h)); }
.nw-crumbs { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.nw-crumbs a { color: var(--wp-blue); text-decoration: none; }
.nw-crumbs a:hover { text-decoration: underline; }
.nw-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nw-title span.hl { color: var(--wp-blue); }
.nw-subtitle { font-size: 13px; color: var(--text-muted); margin: 2px 0 18px; max-width: 820px; }
.nw-kind { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 3px; background: var(--wp-blue-light); color: var(--wp-blue-dark); }
.nw-kind-view { background: #f1ecfa; color: #4d3a7a; }

/* ── Cards / notices ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.card-header { padding: 13px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; }
.card-meta { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.card-body { padding: 18px 20px; }
.card-body > p { font-size: 13.5px; line-height: 1.7; margin-bottom: 10px; max-width: 860px; }
.card-body > p:last-child { margin-bottom: 0; }
.notice { border-left: 4px solid; padding: 11px 15px; border-radius: 0 var(--radius) var(--radius) 0; margin: 0 0 18px; font-size: 13px; }
.notice-info { background: #f0f6fc; border-color: var(--wp-blue); color: #1a4a70; }
.notice-warning { background: #fef9e7; border-color: var(--warning); color: #7a4f0c; }
.notice-error { background: #fdf0f0; border-color: var(--error); color: #7a1c1e; }
.notice-success { background: #f0faf0; border-color: var(--success); color: #1a5c28; }
.notice code { font-size: 12px; background: rgba(0,0,0,.05); padding: 1px 4px; border-radius: 3px; }

/* ── Overview stats ── */
.nw-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.nw-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.nw-stat-num { font-size: 24px; font-weight: 700; color: var(--wp-blue); font-variant-numeric: tabular-nums; line-height: 1.2; }
.nw-stat-lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

.nw-table-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.nw-table-card { display: block; border: 1px solid var(--border-soft); border-left: 3px solid var(--wp-blue); border-radius: var(--radius); padding: 10px 12px; text-decoration: none; color: var(--text); background: #fbfbfc; }
.nw-table-card:hover { border-color: var(--wp-blue); background: var(--wp-blue-light); }
.nw-table-card-head { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 13.5px; }
.nw-table-card-head .n { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nw-table-card p { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin-top: 3px; }
.nw-view-list { columns: 3 220px; column-gap: 24px; list-style: none; font-size: 13px; }
.nw-view-list li { padding: 3px 0; break-inside: avoid; }
.nw-view-list a { text-decoration: none; }
.nw-view-list a:hover { text-decoration: underline; }
.nw-view-list .n { color: var(--text-light); font-size: 12px; margin-left: 4px; }

.nw-layers { list-style: none; counter-reset: layer; display: grid; gap: 8px; }
.nw-layers li { counter-increment: layer; position: relative; padding: 8px 12px 8px 42px; background: #fbfbfc; border: 1px solid var(--border-soft); border-radius: var(--radius); font-size: 13px; line-height: 1.55; }
.nw-layers li::before { content: counter(layer); position: absolute; left: 12px; top: 8px; width: 20px; height: 20px; border-radius: 50%; background: var(--wp-blue); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.nw-layers code { font-size: 12px; background: var(--wp-blue-light); color: var(--wp-blue-dark); padding: 1px 5px; border-radius: 3px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif; cursor: pointer; text-decoration: none; border: 1px solid transparent; line-height: 1.3; }
.btn-primary { background: var(--wp-blue); color: #fff; }
.btn-primary:hover { background: var(--wp-blue-dark); }
.btn-secondary { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--wp-blue); color: var(--wp-blue); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── Data / Structure tabs ── */
.nw-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; gap: 2px; }
.nw-tab { padding: 9px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); text-decoration: none; border: 1px solid transparent; border-bottom: none; margin-bottom: -1px; border-radius: var(--radius) var(--radius) 0 0; }
.nw-tab:hover { color: var(--text); background: rgba(0,0,0,.03); }
.nw-tab.active { color: var(--text); background: var(--surface); border-color: var(--border); border-bottom-color: var(--surface); font-weight: 600; }

/* ── Toolbar ── */
.nw-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.nw-search { display: flex; gap: 6px; flex: 1; min-width: 220px; max-width: 420px; }
.nw-input { flex: 1; min-width: 0; padding: 7px 10px; font-size: 13px; font-family: 'Inter', sans-serif; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); }
.nw-input:focus { outline: none; border-color: var(--wp-blue); box-shadow: 0 0 0 2px rgba(34,113,177,.2); }
.nw-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--wp-blue-light); color: var(--wp-blue-dark); border: 1px solid #b3c9e3; padding: 3px 4px 3px 10px; border-radius: 14px; }
.nw-chip a { text-decoration: none; color: var(--wp-blue-dark); font-weight: 700; padding: 0 6px; border-radius: 10px; }
.nw-chip a:hover { background: rgba(0,0,0,.08); }
.nw-toolbar-meta { margin-left: auto; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Data grid ── */
.nw-grid-wrap { overflow-x: auto; }
.nw-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.nw-grid th {
  position: sticky; top: 0; background: #f6f7f7; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--text-muted);
  padding: 8px 12px; border-bottom: 2px solid var(--border);
}
.nw-grid th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.nw-grid th a:hover { color: var(--wp-blue); }
.nw-grid th.sorted a { color: var(--wp-blue-dark); }
.nw-sort-arrow { font-size: 10px; }
.nw-grid th .nw-key { font-size: 9px; font-weight: 700; padding: 0 4px; border-radius: 2px; margin-left: 3px; }
.nw-key-pk { color: var(--gold); background: #fbf3dc; }
.nw-key-fk { color: var(--wp-blue); background: var(--wp-blue-light); }
.nw-grid td { padding: 6px 12px; border-bottom: 1px solid #ececed; vertical-align: top; max-width: 340px; overflow-wrap: anywhere; }
.nw-grid tr:hover td { background: #f6f9fd; }
.nw-grid td.num { font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', monospace; font-size: 12px; white-space: nowrap; }
.nw-grid td.null { color: #a7aaad; font-style: italic; font-size: 11.5px; }
.nw-grid td.blob { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; }
.nw-grid td a { text-decoration: none; font-weight: 600; }
.nw-grid td a:hover { text-decoration: underline; }
.nw-grid td.rowlink { width: 1%; white-space: nowrap; }
.nw-thumb { display: block; height: 34px; width: auto; border-radius: 2px; border: 1px solid var(--border-soft); margin-bottom: 2px; }
.nw-empty { padding: 26px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.nw-pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); flex-wrap: wrap; }
.nw-pager .btn { padding: 5px 12px; font-size: 12.5px; }
.nw-pager .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.nw-pager-pos { font-variant-numeric: tabular-nums; }
.nw-pager-right { margin-left: auto; }

/* ── Structure ── */
.nw-struct { width: 100%; border-collapse: collapse; font-size: 13px; }
.nw-struct th { background: #f6f7f7; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: 8px 12px; text-align: left; border-bottom: 2px solid var(--border); }
.nw-struct td { padding: 7px 12px; border-bottom: 1px solid #f0f0f1; vertical-align: top; }
.nw-struct td code { font-size: 12px; }
.nw-struct .yes { color: var(--success); font-weight: 700; }
.nw-struct .dim { color: #a7aaad; }

.code-block { background: var(--code-bg); border-radius: var(--radius); padding: 12px 16px; overflow-x: auto; }
.code-block code { font-size: 12.5px; color: #c9d1d9; line-height: 1.7; display: block; white-space: pre; }

/* ── Row page ── */
.nw-record { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; border-top: 1px solid #f0f0f1; }
.nw-record dt, .nw-record dd { padding: 8px 14px; border-bottom: 1px solid #f0f0f1; font-size: 13px; }
.nw-record dt { font-weight: 600; color: var(--text-muted); background: #fafafa; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nw-record dd { overflow-wrap: anywhere; }
.nw-record dd.num { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.nw-record dd.null { color: #a7aaad; font-style: italic; }
.nw-record dd a { font-weight: 600; text-decoration: none; }
.nw-record dd a:hover { text-decoration: underline; }
.nw-record .nw-key { font-size: 9px; font-weight: 700; padding: 0 4px; border-radius: 2px; }
.nw-photo { display: block; max-width: 100%; height: auto; border: 1px solid var(--border-soft); border-radius: 3px; margin-bottom: 6px; image-rendering: auto; }
.nw-photo-note { font-size: 12px; color: var(--text-muted); }

/* ── SQL console ── */
.nw-console textarea {
  width: 100%; min-height: 150px; resize: vertical; padding: 12px 14px; border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.6;
  background: var(--code-bg); color: #e6edf3; border: 1px solid #3c434a; caret-color: #72aee6;
}
.nw-console textarea:focus { outline: none; border-color: var(--wp-blue); box-shadow: 0 0 0 3px rgba(34,113,177,.25); }
.nw-console-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.nw-console-hint { font-size: 12px; color: var(--text-muted); }
.nw-console-hint kbd { font-family: 'JetBrains Mono', monospace; font-size: 11px; background: #fff; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; }
.nw-result-meta { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nw-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.nw-example { display: block; padding: 9px 12px; border: 1px solid var(--border-soft); border-radius: var(--radius); text-decoration: none; color: var(--text); background: #fbfbfc; }
.nw-example:hover { border-color: var(--wp-blue); background: var(--wp-blue-light); }
.nw-example strong { display: block; font-size: 13px; color: var(--wp-blue-dark); }
.nw-example span { display: block; font-size: 12px; color: var(--text-muted); line-height: 1.45; margin-top: 2px; }
.nw-error-title { font-weight: 700; margin-bottom: 2px; }
.nw-error-msg { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }

/* ── Northwind ER diagram (shared markup with the SQLite3 guide) ── */
.nw-erd-wrap { overflow-x: auto; margin: 6px 0 4px; }
.nw-erd { display: block; width: 100%; min-width: 760px; height: auto; font-family: 'Inter', sans-serif; }
.nw-erd-box { fill: #ffffff; stroke: #8c8f94; stroke-width: 1; }
.nw-erd-head { fill: #2271b1; }
.nw-erd-title { fill: #ffffff; font-size: 11.5px; font-weight: 700; }
.nw-erd-count { fill: #cfe3f5; font-size: 11px; }
.nw-erd-col { fill: #1d2327; font-size: 11.5px; font-family: 'JetBrains Mono', monospace; }
.nw-erd-key { font-weight: 700; }
.nw-erd-tag { font-size: 9.5px; font-weight: 700; letter-spacing: .04em; }
.nw-erd-tag-pk { fill: #9a6b00; }
.nw-erd-tag-fk { fill: #2271b1; }
.nw-erd-edge { fill: none; stroke: #787c82; stroke-width: 1.4; }
.nw-erd-arrowhead { fill: #787c82; }
.nw-erd-link:hover .nw-erd-box, .nw-erd-link:focus .nw-erd-box { stroke: #2271b1; stroke-width: 2; }
.nw-erd-link:hover .nw-erd-head { fill: #135e96; }
.nw-erd-legend { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ── Phone / tablet: the sidebar stops being fixed and sits above the page ── */
@media (max-width: 900px) {
  .nw-sidebar { position: static; width: auto; max-height: none; border-right: none; border-bottom: 1px solid #3c434a; margin-top: var(--header-h); padding-bottom: 10px; }
  .nw-side-group { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px; }
  .nw-side-item { border-left: none; border-radius: 12px; padding: 4px 10px; background: rgba(255,255,255,.04); font-size: 12px; }
  .nw-side-item.active { border-left: none; }
  .nw-side-item svg { display: none; }
  .nw-side-label { padding: 12px 16px 6px; }
  .nw-main { margin-left: 0; margin-top: 0; padding: 18px 16px 32px; }
  .nw-stats { grid-template-columns: repeat(2, 1fr); }
  .nw-record { grid-template-columns: 1fr; }
  .nw-grid td { white-space: nowrap; max-width: none; }
  /* Views stay reachable from the Overview; as chips they pushed the page far down. */
  .nw-side-views { display: none; }
  .nw-record dt { border-bottom: none; padding-bottom: 2px; }
}
@media (max-width: 560px) {
  .nw-bar { padding: 0 12px; gap: 8px; }
  .nw-logo { font-size: 13px; }
  .nw-logo svg { display: none; }
  .nw-badge-ro { display: none; }
  .nw-title { font-size: 19px; }
}
