/* JSE app shell — sidebar + topbar + main + form / chat / compare
   primitives. Pages opt in by setting <html data-theme="light"> and
   wrapping content in .app > .sidebar + .main. Tokens live in
   style.css; marketing-only selectors live in jse-marketing.css. */

[data-theme="light"] body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.55; }
[data-theme="light"] a { color: inherit; text-decoration: none; }
[data-theme="light"] button { font-family: inherit; cursor: pointer; }

[data-theme="light"] .app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

/* ─── SIDEBAR ─── */
[data-theme="light"] .sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 14px 0;
  position: sticky; top: 0; height: 100vh;
}
[data-theme="light"] .sb-brand {
  padding: 4px 18px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
[data-theme="light"] .sb-brand .mark {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: "Newsreader", serif; font-size: 14px; font-weight: 500; font-style: italic;
}
[data-theme="light"] .sb-brand .pill {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px; letter-spacing: 0.12em;
  padding: 2px 6px; background: var(--card2);
  border: 1px solid var(--line); border-radius: 3px; color: var(--dim);
}

[data-theme="light"] .sb-section-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px; letter-spacing: 0.14em;
  color: var(--dim); padding: 14px 18px 6px;
  text-transform: uppercase;
}
[data-theme="light"] .sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 18px;
  font-size: 13px; color: var(--ink);
  cursor: pointer; border-left: 2px solid transparent;
  text-decoration: none;
}
[data-theme="light"] .sb-link:hover { background: var(--card2); }
[data-theme="light"] .sb-link.active { background: var(--card2); border-left-color: var(--accent); color: var(--ink); font-weight: 500; }
[data-theme="light"] .sb-link .ico { width: 14px; text-align: center; opacity: 0.6; flex-shrink: 0; font-family: "IBM Plex Mono", monospace; font-size: 13px; }
[data-theme="light"] .sb-link.active .ico { opacity: 1; color: var(--accent); }
[data-theme="light"] .sb-link .badge { margin-left: auto; font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--dim); }

[data-theme="light"] .sb-newchat {
  margin: 6px 14px 10px; padding: 8px 12px;
  border: 1px dashed var(--dim2); border-radius: 6px;
  font-size: 12.5px; color: var(--dim); cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  background: transparent;
  width: calc(100% - 28px);
}
[data-theme="light"] .sb-newchat:hover { border-color: var(--accent); color: var(--accent); }

[data-theme="light"] .sb-history { flex: 1; overflow-y: auto; padding: 0 6px; }
[data-theme="light"] .sb-hist-item { padding: 7px 12px; font-size: 12.5px; color: var(--dim); border-radius: 4px; cursor: pointer; line-height: 1.35; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
[data-theme="light"] .sb-hist-item:hover { background: var(--card2); color: var(--ink); }
[data-theme="light"] .sb-hist-item.current { background: rgba(31, 122, 82, 0.08); color: var(--ink); }
[data-theme="light"] .sb-hist-item .when { font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--dim); flex-shrink: 0; }
[data-theme="light"] .sb-hist-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

[data-theme="light"] .sb-footer {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
}
[data-theme="light"] .sb-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--card2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--dim);
}
[data-theme="light"] .sb-userline { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
[data-theme="light"] .sb-userline .name { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-theme="light"] .sb-userline .org { color: var(--dim); font-family: "IBM Plex Mono", monospace; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── MAIN + TOPBAR ─── */
[data-theme="light"] .main { display: flex; flex-direction: column; min-width: 0; }
[data-theme="light"] .topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
[data-theme="light"] .tb-left { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
[data-theme="light"] .tb-crumb { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--dim); display: flex; align-items: center; gap: 8px; }
[data-theme="light"] .tb-crumb .here { color: var(--ink); }
[data-theme="light"] .tb-credits {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 100px;
  font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--dim);
  text-decoration: none;
}
[data-theme="light"] .tb-credits b { color: var(--ink); font-weight: 500; }
[data-theme="light"] .tb-right { display: flex; align-items: center; gap: 8px; }
[data-theme="light"] .tb-iconbtn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px; cursor: pointer; color: var(--dim);
  background: transparent; border: none;
  font-size: 14px;
}
[data-theme="light"] .tb-iconbtn:hover { background: var(--card2); color: var(--ink); }
[data-theme="light"] .tb-link { font-size: 13px; color: var(--dim); padding: 4px 8px; border-radius: 5px; }
[data-theme="light"] .tb-link:hover { background: var(--card2); color: var(--ink); }

[data-theme="light"] .body { padding: 24px 32px 64px; min-width: 0; }
[data-theme="light"] .body.full { padding: 0; }
[data-theme="light"] .page-title { font-size: 26px; letter-spacing: -0.02em; font-weight: 500; margin: 0 0 4px; color: var(--ink); }
[data-theme="light"] .page-sub { color: var(--dim); font-size: 14px; margin: 0 0 24px; }

/* ─── FORMS ─── */
[data-theme="light"] label.fld-label,
[data-theme="light"] .fld-label {
  display: block; font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px; letter-spacing: 0.1em; color: var(--dim);
  margin-bottom: 6px; text-transform: uppercase;
}
[data-theme="light"] .input,
[data-theme="light"] textarea.input,
[data-theme="light"] select.input {
  width: 100%; padding: 9px 11px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 5px; font-size: 13px; font-family: inherit;
  color: var(--ink);
}
[data-theme="light"] .input:focus,
[data-theme="light"] textarea.input:focus,
[data-theme="light"] select.input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 82, 0.12);
}
[data-theme="light"] textarea.input {
  resize: vertical; min-height: 120px;
  font-family: "IBM Plex Mono", monospace; font-size: 12px; line-height: 1.5;
}

[data-theme="light"] .formcard { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
[data-theme="light"] .formcard .grouphead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
[data-theme="light"] .formcard .grouphead .glabel { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: 0.1em; color: var(--dim); }
[data-theme="light"] .formcard .grouphead .glinks { display: flex; gap: 14px; font-size: 12px; color: var(--dim); }
[data-theme="light"] .formcard .grouphead .glinks a:hover,
[data-theme="light"] .formcard .grouphead .glinks button:hover { color: var(--accent); cursor: pointer; }

[data-theme="light"] .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── BUTTONS ─── */
[data-theme="light"] .btn {
  display: inline-block; padding: 10px 18px; border-radius: 6px;
  font-size: 13px; font-weight: 500; border: none; cursor: pointer;
  transition: opacity 0.15s; text-decoration: none;
}
[data-theme="light"] .btn:hover { opacity: 0.9; }
[data-theme="light"] .btn-primary { background: var(--accent); color: var(--bg); }
[data-theme="light"] .btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--dim2); }
[data-theme="light"] .btn-danger { background: transparent; color: var(--fail); border: 1px solid rgba(185, 74, 74, 0.4); }
[data-theme="light"] .btn-danger:hover { background: rgba(185, 74, 74, 0.06); }
[data-theme="light"] .btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 5px; }

/* ─── ADMIN-SPECIFIC PRIMITIVES (data tables, status pills, etc.) ─── */
[data-theme="light"] .admin-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 20px; margin-bottom: 18px;
}
[data-theme="light"] .admin-card h2 {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; letter-spacing: 0.14em; color: var(--dim);
  margin: 0 0 16px; font-weight: 400; text-transform: uppercase;
}
[data-theme="light"] .admin-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
[data-theme="light"] .admin-toolbar input[type="text"],
[data-theme="light"] .admin-toolbar input[type="email"],
[data-theme="light"] .admin-toolbar input[type="number"],
[data-theme="light"] .admin-toolbar select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px;
  font-size: 13px; min-width: 200px; background: var(--card); color: var(--ink);
  font-family: inherit;
}
[data-theme="light"] .admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
[data-theme="light"] .admin-table th {
  text-align: left; padding: 8px 10px;
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px;
  letter-spacing: 0.1em; color: var(--dim);
  border-bottom: 1px solid var(--line);
  font-weight: 400; text-transform: uppercase;
}
[data-theme="light"] .admin-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
[data-theme="light"] .admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: "IBM Plex Mono", monospace; font-size: 12.5px; }
[data-theme="light"] .admin-table tfoot td { background: var(--card2); font-weight: 500; }
[data-theme="light"] .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
[data-theme="light"] .pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: 0.04em; }
[data-theme="light"] .pill-green { background: rgba(31, 122, 82, 0.12); color: var(--accent); }
[data-theme="light"] .pill-amber { background: rgba(184, 134, 42, 0.12); color: var(--warn); }
[data-theme="light"] .pill-red { background: rgba(185, 74, 74, 0.12); color: var(--fail); }
[data-theme="light"] .pill-grey { background: var(--card2); color: var(--dim); }
[data-theme="light"] .banner-ok { background: rgba(31, 122, 82, 0.08); color: var(--accent); border: 1px solid rgba(31, 122, 82, 0.3); padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
[data-theme="light"] .banner-error { background: rgba(185, 74, 74, 0.08); color: var(--fail); border: 1px solid rgba(185, 74, 74, 0.3); padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
[data-theme="light"] .empty { padding: 40px; text-align: center; color: var(--dim); font-size: 13px; }
[data-theme="light"] code.invite-link { display: block; padding: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 4px; word-break: break-all; font-family: "IBM Plex Mono", monospace; font-size: 11.5px; margin-top: 6px; color: var(--ink); }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  [data-theme="light"] .app { grid-template-columns: 1fr; }
  [data-theme="light"] .sidebar { position: static; height: auto; max-height: 50vh; border-right: none; border-bottom: 1px solid var(--line); }
}
