/* Ruang Konsultasi RUU Perkoperasian — jdih.simkopdes.com */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/PlusJakartaSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/PlusJakartaSans-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/PlusJakartaSans-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/PlusJakartaSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/PlusJakartaSans-ExtraBold.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --header-bg: #235264;
  --header-border: #173946;
  --header-hover: #1b4251;
  --accent-olive: #a5b951;
  --accent-olive-hover: #94a842;
  --accent-olive-soft: #eaefd7;
  --bg-canvas: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-subtle: #f7f9fc;
  --bg-active: #edf3f6;
  --text-primary: #1c2232;
  --text-secondary: #4d525f;
  --text-muted: #696e79;
  --border-light: #e5e8ef;
  --border-input: #cbd3df;
  --danger: #c62828;
  --danger-bg: #fef2f2;
  --success: #1b6e44;
  --success-bg: #ecfdf3;
  --warn: #9a5b00;
  --warn-bg: #fff8eb;
  --shadow-card: 0 4px 20px rgba(28, 34, 50, 0.05);
  --shadow-sm: 0 1px 3px rgba(28, 34, 50, 0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --header-height: 60px;

  /* Token turunan: dipakai aturan di bawah, ditimpa oleh tema di kaca.css */
  --bg-card: #ffffff;
  --on-brand: #ffffff;
  --on-brand-muted: rgba(255, 255, 255, 0.78);
  --brand-ink: var(--header-bg);
  --warn-border: #f2d49b;
  --danger-border: #f5c2c2;
  --success-border: #b7ebc9;
  --focus-ring: rgba(35, 82, 100, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--brand-ink);
  text-decoration: none;
}

/* Top Header Bar */
.topbar {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  color: var(--on-brand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo-wrap {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
}

.brand-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--on-brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--on-brand-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-brand);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.topbar-pill:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.38);
}

.topbar-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a5b951;
  display: inline-block;
}

.topbar-status-dot.warn {
  background: #f5b942;
}

.mobile-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-brand);
  cursor: pointer;
}

/* 3-Column Chat App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 340px;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* Left Sidebar */
.sidebar-left {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-top-action {
  padding: 14px 14px 10px;
}

.btn-new-chat {
  width: 100%;
  height: 40px;
  border: 1px solid #96ab43;
  border-radius: 10px;
  background: var(--accent-olive);
  color: #1c2232;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  box-shadow: 0 2px 6px rgba(165, 185, 81, 0.28);
}

.btn-new-chat:hover {
  background: var(--accent-olive-hover);
}

.btn-new-chat:active {
  transform: translateY(1px);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 16px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 6px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topic-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.topic-item:hover {
  background: var(--bg-canvas);
}

.topic-item.active {
  background: var(--bg-active);
  border-color: var(--border-light);
}

.topic-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.topic-item.active .topic-item-title {
  color: var(--brand-ink);
}

.topic-item-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-light);
  margin: 14px 4px 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  transition: background 0.12s ease;
}

.history-item:hover {
  background: var(--bg-canvas);
}

.history-item.active {
  background: var(--bg-active);
  color: var(--brand-ink);
  font-weight: 600;
}

.history-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-del {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}

.history-item:hover .history-del {
  opacity: 1;
}

.history-del:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.history-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px;
}

/* Center Chat Stage */
.chat-main {
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.chat-messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
}

.welcome-wrap {
  margin: auto;
  width: 100%;
  max-width: 680px;
  padding: 12px 0;
}

.welcome-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 34px 32px 30px;
  text-align: center;
}

.welcome-icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--bg-active);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

.welcome-subtitle {
  margin: 0 auto;
  max-width: 520px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.starter-prompts {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.prompt-chip {
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.prompt-chip:hover {
  border-color: var(--header-bg);
  background: var(--bg-active);
  color: var(--brand-ink);
}

.welcome-notice {
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.welcome-notice a {
  color: var(--brand-ink);
  font-weight: 700;
  text-decoration: underline;
}

/* Message Thread */
.thread-list {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-row {
  display: flex;
  flex-direction: column;
}

.msg-row.user {
  align-items: flex-end;
}

.msg-row.assistant {
  align-items: stretch;
}

.msg-user-bubble {
  max-width: 80%;
  background: var(--header-bg);
  color: var(--on-brand);
  padding: 12px 16px;
  border-radius: 14px 14px 4px 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

.msg-assistant-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.msg-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.msg-assistant-identity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.msg-sender-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.msg-meta-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

.meta-pill.model {
  background: var(--bg-active);
  border-color: var(--border-light);
  color: var(--brand-ink);
}

.thought-box {
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.thought-box summary {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-ink);
  cursor: pointer;
  user-select: none;
}

.thought-box-content {
  padding: 0 12px 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  line-height: 1.5;
  border-top: 1px solid var(--border-light);
  padding-top: 8px;
}

/* Markdown Typography */
.markdown-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

.markdown-body p {
  margin: 0 0 10px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 14px 0 8px;
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.35;
}

.markdown-body h1 { font-size: 17px; }
.markdown-body h2 { font-size: 15.5px; }
.markdown-body h3 { font-size: 14.5px; }

.markdown-body ul,
.markdown-body ol {
  margin: 6px 0 12px;
  padding-left: 22px;
}

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--header-bg);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 0 8px 8px 0;
}

.markdown-body code {
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.markdown-body pre {
  background: #1c2232;
  color: #f4f6fa;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 10px 0;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border-light);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: var(--bg-subtle);
  font-weight: 700;
}

.cite-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 19px;
  padding: 0 5px;
  margin: 0 1px;
  border-radius: 5px;
  background: var(--bg-active);
  border: 1px solid var(--border-light);
  color: var(--brand-ink);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: baseline;
  transition: all 0.12s ease;
}

.cite-badge:hover {
  background: var(--header-bg);
  color: var(--on-brand);
  border-color: var(--header-bg);
}

.msg-assistant-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ghost-sm {
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-ghost-sm:hover {
  background: var(--bg-canvas);
  color: var(--text-primary);
}

.streaming-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 13px;
}

.streaming-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--header-bg);
  animation: pulseDot 1.2s infinite ease-in-out;
}

.streaming-dots span:nth-child(2) { animation-delay: 0.2s; }
.streaming-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulseDot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Bottom Composer */
.composer-dock {
  background: var(--bg-canvas);
  padding: 10px 24px 16px;
}

.composer-inner {
  max-width: 820px;
  margin: 0 auto;
}

.composer-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-input);
  border-radius: 14px;
  padding: 9px 10px 9px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow: 0 2px 10px rgba(28, 34, 50, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-box:focus-within {
  border-color: var(--header-bg);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.composer-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  max-height: 150px;
  min-height: 24px;
  padding: 6px 0;
  color: var(--text-primary);
}

.composer-textarea::placeholder {
  color: #8b92a1;
}

.btn-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--header-bg);
  color: var(--on-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.btn-send:hover:not(:disabled) {
  background: var(--header-hover);
}

.btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-send.stop-mode {
  background: var(--danger);
}

.composer-meta-row {
  margin-top: 7px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.composer-topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.composer-pill-tag {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 600;
  color: var(--brand-ink);
}

/* Right Reference Sidebar */
.sidebar-right {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.right-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border-light);
  padding: 10px 14px 0;
  gap: 8px;
}

.right-tab-btn {
  border: none;
  background: transparent;
  padding: 8px 6px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.right-tab-btn.active {
  color: var(--brand-ink);
  border-bottom-color: var(--header-bg);
}

.tab-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-canvas);
  color: var(--text-secondary);
}

.right-tab-btn.active .tab-count {
  background: var(--bg-active);
  color: var(--brand-ink);
}

.right-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.right-empty-state {
  text-align: center;
  padding: 46px 18px;
  color: var(--text-muted);
}

.right-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-canvas);
  color: var(--text-muted);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.right-empty-state p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
}

.citation-card {
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.citation-card.highlighted {
  border-color: var(--header-bg);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.citation-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.citation-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--header-bg);
  color: var(--on-brand);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.citation-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.citation-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-ink);
  margin-top: 2px;
}

.citation-excerpt {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 6px 0 8px;
}

.citation-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.doc-search-input {
  width: 100%;
  border: 1px solid var(--border-input);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12.5px;
  margin-bottom: 12px;
  outline: none;
}

.doc-search-input:focus {
  border-color: var(--header-bg);
}

.doc-card {
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.doc-card:hover {
  border-color: var(--header-bg);
  background: var(--bg-subtle);
}

.doc-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.doc-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.doc-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-canvas);
  color: var(--text-secondary);
}

.doc-tag.code {
  background: var(--bg-active);
  color: var(--brand-ink);
}

.doc-card-summary {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 25, 38, 0.48);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 780px;
  max-height: 86vh;
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-subtitle {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.modal-close {
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-pre {
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 13.5px;
  color: var(--text-primary);
  margin: 0;
}

/* =========================================================================
   ADMIN CONSOLE STYLES (/admin)
   ========================================================================= */
.admin-page-body {
  min-height: 100vh;
  background: var(--bg-canvas);
}

.admin-login-shell {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.admin-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 30px 28px;
  box-shadow: var(--shadow-card);
}

.admin-login-card h1 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 700;
}

.admin-login-card p {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 22px 22px 48px;
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.kpi-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
}

.admin-tab-btn {
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-tab-btn:hover {
  border-color: var(--header-bg);
  color: var(--brand-ink);
}

.admin-tab-btn.active {
  background: var(--header-bg);
  border-color: var(--header-bg);
  color: var(--on-brand);
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.admin-card-desc {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border: 1px solid var(--border-input);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--header-bg);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.55;
}

.form-textarea.code-area {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--header-bg);
  color: var(--on-brand);
}

.btn-primary:hover {
  background: var(--header-hover);
}

.btn-olive {
  background: var(--accent-olive);
  border-color: #95aa43;
  color: #1c2232;
  font-weight: 700;
}

.btn-olive:hover {
  background: var(--accent-olive-hover);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-input);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-canvas);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-border);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.thinking-radio-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.thinking-option {
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-card);
}

.thinking-option:hover {
  border-color: var(--border-input);
}

.thinking-option.selected {
  border-color: var(--header-bg);
  background: var(--bg-active);
}

.thinking-option input {
  display: none;
}

.thinking-option-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-primary);
}

.thinking-option-desc {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-ok {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-muted {
  background: var(--bg-canvas);
  color: var(--text-secondary);
}

.badge-teal {
  background: var(--bg-active);
  color: var(--brand-ink);
}

.alert-banner {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.alert-banner.ok {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.alert-banner.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
}

.alert-banner.err {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.data-table th {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-subtle);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  background: #1c2232;
  color: var(--on-brand);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.err {
  background: var(--danger);
}

.toast.ok {
  background: var(--success);
}

.hidden {
  display: none !important;
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr) 290px;
  }
  .admin-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .mobile-toggle-btn {
    display: inline-flex;
  }
  .app-shell {
    grid-template-columns: 1fr;
    position: relative;
  }
  .sidebar-left,
  .sidebar-right {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    width: 290px;
    max-width: 86vw;
    z-index: 50;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease;
  }
  .sidebar-left {
    left: 0;
    transform: translateX(-105%);
  }
  .sidebar-left.mobile-open {
    transform: translateX(0);
  }
  .sidebar-right {
    right: 0;
    transform: translateX(105%);
  }
  .sidebar-right.mobile-open {
    transform: translateX(0);
  }
  .form-grid,
  .thinking-radio-grid {
    grid-template-columns: 1fr;
  }
}
