:root {
  --ink: #17191d;
  --muted: #626873;
  --line: #d9dce2;
  --paper: #f2f3f5;
  --panel: #ffffff;
  --blue: #092f87;
  --blue-dark: #061f5b;
  --blue-soft: #edf2fb;
  --orange: #ff9900;
  --orange-dark: #d97f00;
  --warning: #fff4dc;
  --shadow: 0 12px 34px rgba(24, 31, 48, .11);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Arial, "Segoe UI", sans-serif;
  background: var(--paper);
}

button, input, textarea { font: inherit; }
a { color: var(--blue); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 62px;
  padding: 0 max(20px, calc((100vw - 1520px) / 2));
  color: #fff;
  background: var(--blue);
  border-bottom: 4px solid var(--orange);
}

.brand {
  display: grid;
  grid-template-columns: 5px auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  color: #fff;
  text-decoration: none;
  line-height: 1;
}

.brand-line {
  grid-row: 1 / 3;
  width: 5px;
  background: var(--orange);
}

.brand-name { font-size: 22px; font-weight: 800; }
.brand-caption { margin-top: 4px; font-size: 11px; color: #cfd9ef; }
.site-links { display: flex; align-items: center; gap: 22px; }
.site-links a { color: #fff; text-decoration: none; font-size: 13px; }
.site-links a:hover { text-decoration: underline; }
.site-links .source-link { padding: 8px 12px; border: 1px solid rgba(255,255,255,.55); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.17fr) minmax(390px, .83fr);
  gap: 14px;
  width: min(1520px, calc(100vw - 28px));
  height: calc(100vh - 88px);
  margin: 13px auto;
}

.dialogue, .context-panel, .session-view {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.dialogue {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) max-content auto;
  overflow: hidden;
}

.dialogue > .notice { grid-row: 1; }
.dialogue > .mobile-tabs { grid-row: 2; }
.dialogue > .messages { grid-row: 3; }
.dialogue > .quick-prompts { grid-row: 4; }
.dialogue > .composer { grid-row: 5; }

.context-panel { min-height: 0; overflow: auto; }

.topbar {
  position: relative;
  min-height: 168px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 26px 22px;
  overflow: hidden;
  color: #fff;
  background-color: var(--blue-dark);
  background-image: url('/assets/penetron/tunnel.jpg');
  background-size: cover;
  background-position: center 49%;
}

.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(4, 19, 50, .72);
}

.topbar-copy, .topbar .status-pill, .image-credit { position: relative; z-index: 1; }
.topbar-copy { max-width: 680px; }

.topbar h1, .panel-head h2, .session-view h1 {
  margin: 0;
  line-height: 1.08;
  font-size: 38px;
  letter-spacing: 0;
}

.panel-head h2 { font-size: 22px; color: var(--ink); }
.kicker { margin: 0 0 8px; color: var(--orange); font-size: 12px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; }
.subtitle { margin: 10px 0 0; color: #edf2ff; max-width: 620px; line-height: 1.45; }

.image-credit {
  position: absolute;
  right: 14px;
  bottom: 10px;
  color: rgba(255,255,255,.72);
  font-size: 10px;
}

.notice {
  margin: 0;
  padding: 10px 24px;
  border-left: 5px solid var(--orange);
  background: var(--warning);
  color: #5b430c;
  font-size: 13px;
}

.status-pill, .task-list span {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #4d5563;
  background: #f6f7f9;
  font-size: 12px;
}

.topbar .status-pill { color: #fff; border-color: rgba(255,255,255,.55); background: rgba(5,20,55,.45); }
.messages { min-height: 0; overflow: auto; padding: 10px 24px 18px; }

.message {
  width: min(760px, 92%);
  margin: 12px 0;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  line-height: 1.5;
}

.message b { display: block; margin-bottom: 6px; color: var(--blue); font-size: 12px; }
.message.assistant { border-left: 4px solid var(--orange); }
.message.user { margin-left: auto; border-color: #c6d4ec; background: var(--blue-soft); }
.quick-prompts { display: flex; align-items: flex-start; align-content: flex-start; flex-wrap: wrap; gap: 7px; padding: 0 24px 14px; }

.quick-prompts button, .secondary, .primary, .icon-button, .icon-only, .link-button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.quick-prompts button { padding: 7px 9px; font-size: 13px; }
.quick-prompts button:hover, .secondary:hover, .icon-button:hover, .icon-only:hover { border-color: var(--orange); color: var(--blue); }
.composer { padding: 14px 24px 18px; border-top: 1px solid var(--line); background: #fafbfc; }
textarea, input { width: 100%; border: 1px solid #bdc2ca; border-radius: 4px; background: #fff; color: var(--ink); padding: 11px 12px; }
textarea:focus, input:focus { outline: 2px solid rgba(255,153,0,.28); border-color: var(--orange-dark); }
textarea { resize: vertical; min-height: 68px; }
.composer-actions, .panel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 9px; }
.primary, .secondary, .link-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 8px 13px; text-decoration: none; }
.primary { border-color: var(--orange-dark); color: #1d1d1d; background: var(--orange); font-weight: 700; }
.primary:hover { background: #ffad2f; }
.send-button { min-width: 145px; }
.secondary { color: var(--blue); background: #fff; }
.icon-button, .icon-only { display: inline-flex; align-items: center; justify-content: center; width: 41px; height: 39px; padding: 0; }
.icon-button input { display: none; }
.add-photo { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 20px 20px 16px; border-bottom: 4px solid var(--orange); background: #fff; }
.panel-block { margin: 0; padding: 17px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.panel-block h3, .panel-block h2, .material-card h4 { margin: 0 0 9px; font-size: 16px; }
.panel-block p { margin: 7px 0; color: var(--muted); line-height: 1.45; }
.panel-actions { margin: 0; padding: 18px 20px 24px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.section-heading a { font-size: 12px; }
.task-list, .materials, .image-pair { display: grid; gap: 9px; }
.task-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.task-list span { justify-content: center; min-width: 0; text-align: center; }
.materials { grid-template-columns: 1fr; }

.product-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 7px; }
.product-preview { display: grid; grid-template-rows: 110px auto; align-items: end; min-width: 0; padding: 8px 6px; color: var(--blue); text-decoration: none; text-align: center; border: 1px solid #e0e3e8; background: #fafbfc; }
.product-preview:hover { border-color: var(--orange); }
.product-preview img { display: block; width: 100%; height: 104px; object-fit: contain; }
.product-preview span { margin-top: 5px; font-size: 12px; font-weight: 700; }

.material-card { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 12px; padding: 12px; border-left: 4px solid var(--orange); background: #f7f8fa; }
.material-card:not(:has(.material-image)) { grid-template-columns: 1fr; }
.material-card p { margin: 5px 0; font-size: 13px; }
.material-image { display: block; width: 76px; height: 96px; object-fit: contain; background: #fff; }
.material-copy { min-width: 0; }
.preview-image { display: block; width: 100%; max-height: 280px; object-fit: contain; border: 1px solid var(--line); border-radius: 3px; background: #f0f2f5; }
figure { margin: 0; }
figcaption, small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.observation { padding: 11px; border-left: 3px solid var(--blue); background: var(--blue-soft); }
.observation b { color: var(--blue); }
ol, ul { padding-left: 20px; }
li + li { margin-top: 7px; }
.mobile-tabs { display: none; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; min-height: 36px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.tab.active { color: #fff; background: var(--blue); border-color: var(--blue); }

dialog { width: min(560px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 4px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 20, 45, .55); }
.lead-form { padding: 18px; }
.lead-form header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.lead-form h2 { margin: 0; }
.lead-form label { display: block; margin: 12px 0; color: #414752; }
.lead-form .consent { display: flex; align-items: flex-start; gap: 9px; color: var(--ink); font-size: 13px; }
.lead-form .consent input { width: auto; margin-top: 3px; }
.busy .primary, .busy .secondary, .busy .quick-prompts button, .busy .icon-button { opacity: .65; }
.plain-page { background: #edf0f4; }
.session-view { width: min(1280px, calc(100vw - 32px)); margin: 16px auto; overflow: hidden; }
.manager-grid { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 16px; padding: 16px; }
.manager-main, .manager-side { min-width: 0; }
.admin-stack { padding: 16px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: top; }
pre { max-height: 460px; overflow: auto; padding: 12px; border-radius: 4px; background: #101b35; color: #e7ecf6; }
.empty-state { padding: 24px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1040px) {
  .site-links a:not(.source-link) { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(350px, .82fr); }
  .topbar h1 { font-size: 33px; }
}

@media (max-width: 820px) {
  .site-header { height: 58px; padding: 0 14px; }
  .brand-caption, .site-links { display: none; }
  .brand { grid-template-rows: auto; }
  .brand-line { grid-row: 1; }
  .workspace { display: block; width: 100vw; height: calc(100vh - 58px); margin: 0; }
  .dialogue, .context-panel { height: calc(100vh - 58px); border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .context-panel { display: none; }
  .show-solution .dialogue { display: none; }
  .show-solution .context-panel { display: block; }
  .mobile-tabs { display: flex; }
  .topbar { min-height: 148px; padding: 21px 16px 18px; }
  .topbar h1 { font-size: 30px; }
  .panel-head { padding: 17px 16px 13px; }
  .notice { padding: 9px 16px; }
  .messages, .quick-prompts, .composer { padding-left: 16px; padding-right: 16px; }
  .message { width: 100%; }
  .panel-block { padding-left: 16px; padding-right: 16px; }
  .manager-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .topbar { min-height: 154px; }
  .topbar h1 { font-size: 27px; }
  .topbar .status-pill { display: none; }
  .image-credit { right: 10px; bottom: 7px; }
  .quick-prompts { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 10px; }
  .quick-prompts button { flex: 0 0 auto; }
  .composer-actions { align-items: stretch; }
  .primary, .secondary { flex: 1 1 auto; }
  .task-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-preview { grid-template-rows: 84px auto; }
  .product-preview img { height: 80px; }
}
