:root {
  --db-ink: #10233d;
  --db-muted: #65748a;
  --db-line: #dce4ed;
  --db-soft: #f3f7fa;
  --db-navy: #0d2541;
  --db-teal: #0d8c85;
  --db-teal-dark: #076a66;
  --db-coral: #ef6b57;
  --db-green: #23895b;
  --db-shadow: 0 16px 38px rgba(19, 42, 68, .10);
}

* { box-sizing: border-box; }
body:has(.db-app), body:has(.db-gate) { margin: 0; background: #edf3f7; color: var(--db-ink); font-family: Inter, "Segoe UI", system-ui, sans-serif; }
.db-app button, .db-app input, .db-app select, .db-app textarea, .db-gate button, .db-gate input { font: inherit; }
.db-topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 24px; background: var(--db-navy); color: #fff; position: sticky; top: 0; z-index: 30; box-shadow: 0 4px 18px rgba(0,0,0,.16); }
.db-brand { display: flex; align-items: center; gap: 12px; }
.db-brand img { width: 43px; height: 43px; }
.db-brand strong { display: block; font-size: 18px; letter-spacing: .01em; }
.db-brand small { display: block; color: #b9cadc; margin-top: 2px; }
.db-top-actions { display: flex; align-items: center; gap: 12px; }
.mode-badge { background: #ffcf5a; color: #4a3500; padding: 6px 10px; border-radius: 999px; font-size: 12px; text-transform: uppercase; }
.db-shell { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 310px minmax(0, 1fr); }
.db-sidebar { background: #fff; border-right: 1px solid var(--db-line); padding: 18px; position: sticky; top: 72px; height: calc(100vh - 72px); overflow: auto; z-index: 20; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 14px; }
.sidebar-heading span { display: block; color: var(--db-muted); font-size: 12px; text-transform: uppercase; font-weight: 800; letter-spacing: .09em; }
.sidebar-heading strong { display: block; margin-top: 4px; }
.sidebar-heading button, .sidebar-open { display: none; }
.db-input, .db-select, .db-filters select, .db-gate input { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cad6e2; border-radius: 9px; background: #fff; color: var(--db-ink); outline: none; }
.db-input:focus, .db-select:focus, .db-filters select:focus, .db-gate input:focus { border-color: var(--db-teal); box-shadow: 0 0 0 3px rgba(13,140,133,.12); }
.db-filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0 14px; }
.db-task-list { display: grid; gap: 8px; }
.task-card { width: 100%; text-align: left; border: 1px solid var(--db-line); background: #fff; border-radius: 11px; padding: 12px 12px 10px; cursor: pointer; color: var(--db-ink); position: relative; overflow: hidden; transition: .16s ease; }
.task-card:hover { border-color: #9ec9c5; transform: translateY(-1px); }
.task-card.active { border-color: var(--db-teal); background: #f0fbfa; box-shadow: 0 0 0 2px rgba(13,140,133,.10); }
.task-card span { display: block; color: var(--db-teal-dark); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.task-card strong { display: block; margin: 5px 0; font-size: 13px; line-height: 1.3; }
.task-card small { color: var(--db-muted); font-size: 11px; }
.task-card i { position: absolute; left: 0; bottom: 0; width: var(--progress); height: 3px; background: var(--db-teal); }
.db-main { min-width: 0; padding: 24px; }
.db-hero { max-width: 1700px; margin: 0 auto 12px; min-height: 86px; background: linear-gradient(135deg, #102e50 0%, #11465d 58%, #0d8c85 140%); color: #fff; border-radius: 13px; padding: 13px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; overflow: hidden; position: relative; }
.db-hero::after { content: ""; position: absolute; width: 260px; height: 260px; border: 42px solid rgba(255,255,255,.06); border-radius: 50%; right: -80px; top: -110px; }
.db-hero h1 { font-size: clamp(21px, 2vw, 29px); line-height: 1.12; margin: 2px 0 4px; max-width: 920px; }
.db-hero p:not(.eyebrow) { margin: 0; color: #d4e2ee; max-width: 880px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .11em; font-size: 11px; font-weight: 850; color: #75d7d0; }
.hero-score { min-width: 100px; text-align: center; padding: 8px 12px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); border-radius: 10px; backdrop-filter: blur(6px); z-index: 1; }
.hero-score strong { display: block; font-size: 24px; }
.hero-score span { font-size: 11px; color: #d4e2ee; }
.db-workspace { max-width: 1700px; margin: auto; display: grid; grid-template-columns: minmax(260px,.74fr) minmax(520px,1.5fr) minmax(280px,.78fr); gap: 16px; align-items: start; }
.db-panel { background: #fff; border: 1px solid var(--db-line); border-radius: 15px; box-shadow: var(--db-shadow); overflow: hidden; }
.task-panel, .sql-panel { padding: 18px; }
.panel-head { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.panel-head .step { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--db-teal); color: #fff; font-weight: 900; flex: 0 0 auto; }
.panel-head h2 { font-size: 17px; margin: 0; }
.panel-head p { color: var(--db-muted); font-size: 11px; margin: 2px 0 0; }
.panel-head .status-pill { margin-left: auto; }
.status-pill { border-radius: 99px; padding: 5px 8px; font-size: 10px; font-weight: 800; background: #e7edf2; color: var(--db-muted); }
.status-pill.ready { background: #dff5eb; color: #12673f; }
.status-pill.loading { background: #fff2cb; color: #795a00; }
.status-pill.error { background: #ffe5e1; color: #9d2c1e; }
.db-prose { font-size: 14px; line-height: 1.62; }
.source-note { margin-top: 10px; padding: 9px 11px; border-radius: 8px; background: var(--db-soft); color: var(--db-muted); font-size: 12px; }
.resource-list { display: grid; gap: 7px; margin: 14px 0; }
.resource-list a { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--db-ink); border: 1px solid var(--db-line); padding: 9px 10px; border-radius: 9px; background: #fbfdfe; }
.resource-list a:hover { border-color: var(--db-teal); }
.resource-list a > span { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: #ddf4f2; color: var(--db-teal-dark); font-weight: 900; }
.resource-list strong, .resource-list small { display: block; overflow-wrap: anywhere; }
.resource-list strong { font-size: 12px; }
.resource-list small { color: var(--db-muted); font-size: 10px; margin-top: 2px; }
.db-details { border-top: 1px solid var(--db-line); padding: 11px 0; }
.db-details summary { cursor: pointer; font-weight: 800; font-size: 13px; }
.db-details ol { padding-left: 20px; color: var(--db-muted); font-size: 12px; line-height: 1.5; }
.schema-browser { display: grid; gap: 7px; margin-top: 10px; }
.schema-table { border: 1px solid var(--db-line); border-radius: 8px; overflow: hidden; }
.schema-table summary { padding: 8px 9px; display: flex; justify-content: space-between; background: #f7fafc; }
.schema-table summary small { color: var(--db-muted); font-weight: 500; }
.schema-columns { display: grid; }
.schema-columns button { border: 0; border-top: 1px solid #eef2f5; background: #fff; display: flex; justify-content: space-between; gap: 8px; padding: 7px 9px; cursor: pointer; text-align: left; }
.schema-columns button:hover { background: #f0fbfa; }
.schema-columns code { color: #163b5a; }
.schema-columns em { color: var(--db-muted); font-size: 9px; font-style: normal; }
.preview-table { border: 0; width: 100%; padding: 7px; color: var(--db-teal-dark); background: #f4fbfa; cursor: pointer; font-size: 11px; font-weight: 750; }
.dialect-block { border: 1px solid var(--db-line); background: #f8fbfd; padding: 10px; border-radius: 10px; margin-bottom: 14px; }
.dialect-block > span { display: block; font-size: 10px; font-weight: 850; color: var(--db-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 7px; }
.dialect-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 8px; background: #e5edf3; }
.dialect-tabs button { border: 0; padding: 8px; border-radius: 6px; background: transparent; color: #53657a; cursor: pointer; font-size: 12px; font-weight: 800; }
.dialect-tabs button.active { background: #fff; color: var(--db-teal-dark); box-shadow: 0 2px 8px rgba(16,35,61,.10); }
.dialect-block small { display: block; margin-top: 7px; color: var(--db-muted); line-height: 1.35; }
.field-label, .editor-label { display: flex; justify-content: space-between; font-size: 11px; font-weight: 850; color: var(--db-muted); text-transform: uppercase; letter-spacing: .05em; margin: 11px 0 6px; }
.editor-label span { text-transform: none; font-weight: 500; letter-spacing: 0; }
.query-prompt { min-height: 76px; padding: 12px; border-left: 4px solid var(--db-coral); background: #fff7f4; border-radius: 8px; margin: 12px 0; font-size: 13px; line-height: 1.45; }
.query-prompt b { color: #a83827; }
.query-prompt p { margin: 4px 0 0; }
.passed-mark { display: inline-block; margin-top: 7px; color: var(--db-green); font-weight: 800; font-size: 11px; }
.sql-editor { width: 100%; height: 205px; resize: vertical; border: 1px solid #233f5e; border-radius: 10px; background: #0d1e31; color: #d9f8f4; padding: 14px 15px; font: 13px/1.55 Consolas, "Cascadia Code", monospace; tab-size: 2; outline: none; }
.sql-editor:focus { border-color: #3fd4c8; box-shadow: 0 0 0 3px rgba(13,140,133,.15); }
.sql-actions { display: flex; gap: 7px; flex-wrap: wrap; margin: 10px 0; }
.db-button { border: 1px solid #c9d4df; border-radius: 8px; padding: 9px 12px; background: #fff; color: var(--db-ink); font-weight: 800; cursor: pointer; text-decoration: none; font-size: 12px; }
.db-button:hover { filter: brightness(.97); }
.db-button:disabled { opacity: .48; cursor: not-allowed; }
.db-button.primary { background: var(--db-teal); color: #fff; border-color: var(--db-teal); }
.db-button.success { background: var(--db-green); color: #fff; border-color: var(--db-green); }
.db-button.ghost { background: transparent; color: inherit; }
.db-button.wide { width: calc(100% - 28px); margin: 14px; }
.query-message { min-height: 0; border-radius: 8px; padding: 0; font-size: 12px; line-height: 1.45; }
.query-message:not(:empty) { padding: 9px 11px; margin: 9px 0; }
.query-message.ok { background: #e1f5eb; color: #12673f; }
.query-message.warn { background: #fff3cd; color: #755600; }
.query-message.error { background: #ffe7e3; color: #962d1f; }
.result-head { display: flex; justify-content: space-between; margin: 14px 0 6px; font-size: 12px; }
.result-head span { color: var(--db-muted); }
.result-table { min-height: 170px; border: 1px solid var(--db-line); border-radius: 9px; overflow: hidden; }
.table-scroll { overflow: auto; max-height: 340px; }
.result-table table { border-collapse: collapse; width: 100%; font-size: 11px; }
.result-table th { position: sticky; top: 0; background: #e9f1f6; color: #25445f; text-align: left; }
.result-table th, .result-table td { padding: 7px 9px; border-right: 1px solid #dfe7ed; border-bottom: 1px solid #e8edf2; white-space: nowrap; }
.result-table tbody tr:nth-child(even) { background: #f8fafc; }
.table-note { font-size: 10px; color: var(--db-muted); padding: 7px; margin: 0; }
.empty-state { color: var(--db-muted); text-align: center; font-size: 12px; padding: 24px 14px; margin: 0; }
.feedback-panel { min-height: 380px; }
.db-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-bottom: 1px solid var(--db-line); background: #f6f9fb; }
.db-tabs button { border: 0; border-bottom: 3px solid transparent; background: transparent; padding: 13px 7px 10px; color: var(--db-muted); cursor: pointer; font-size: 11px; font-weight: 850; }
.db-tabs button.active { background: #fff; color: var(--db-teal-dark); border-bottom-color: var(--db-teal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.check-results { padding: 10px; display: grid; gap: 6px; max-height: 520px; overflow: auto; }
.check-row { display: flex; gap: 9px; align-items: center; width: 100%; border: 1px solid var(--db-line); background: #fff; border-radius: 8px; text-align: left; padding: 8px; cursor: pointer; }
.check-row > span { width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center; background: #edf1f4; color: var(--db-muted); font-weight: 900; }
.check-row strong, .check-row small { display: block; }
.check-row strong { font-size: 11px; }
.check-row small { color: var(--db-muted); font-size: 9px; margin-top: 2px; }
.check-row.passed { border-color: #a8dec6; background: #f3fcf7; }
.check-row.passed > span { background: var(--db-green); color: #fff; }
.check-row.failed { border-color: #f2c0b8; }
.check-row.failed > span { background: var(--db-coral); color: #fff; }
.oral-panel { padding: 13px; }
.oral-intro { color: var(--db-muted); font-size: 11px; line-height: 1.45; }
.oral-panel article { border-top: 1px solid var(--db-line); padding: 12px 0; display: grid; grid-template-columns: 22px 1fr; gap: 4px; }
.oral-panel article p { margin: 0; font-size: 12px; line-height: 1.45; }
.oral-score { grid-column: 2; display: flex; gap: 5px; margin-top: 7px; }
.oral-score button { width: 32px; height: 28px; border: 1px solid var(--db-line); background: #fff; border-radius: 6px; cursor: pointer; }
.oral-score button.active { background: var(--db-teal); color: #fff; border-color: var(--db-teal); }
.solution-panel { padding: 15px; font-size: 12px; line-height: 1.55; }
.solution-panel h3 { font-size: 16px; margin: 8px 0; }
.solution-panel h4 { margin-bottom: 4px; }
.solution-panel ol { padding-left: 20px; }
.solution-panel pre { max-width: 100%; overflow: auto; padding: 12px; border-radius: 8px; background: #0d1e31; color: #d9f8f4; white-space: pre-wrap; }
.solution-dialect { display: inline-block; padding: 4px 7px; border-radius: 6px; background: #ddf4f2; color: var(--db-teal-dark); font-size: 10px; font-weight: 850; }
.dialect-warning { padding: 9px; border-radius: 7px; background: #fff3cd; color: #705400; margin: 8px 0; }
.db-toast { position: fixed; right: 24px; bottom: 24px; transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s; padding: 12px 16px; border-radius: 10px; background: #10233d; color: #fff; box-shadow: var(--db-shadow); z-index: 100; font-size: 12px; }
.db-toast.show { opacity: 1; transform: translateY(0); }
.db-gate { min-height: 650px; display: grid; place-items: center; padding: 70px 20px; background: #fff; }
.db-gate-card { width: min(440px,100%); padding: 0; background: transparent; border: 0; box-shadow: none; }
.db-gate-card img { display: block; width: 72px; height: 72px; margin: 0 auto 26px; }
.db-gate-card h1 { margin: 0 0 10px; color: #162a45; font-size: clamp(28px,3vw,38px); line-height: 1.15; text-align: center; }
.db-gate-card > p:not(.eyebrow) { color: #687991; margin: 0 0 27px; font-size: 16px; text-align: center; }
.db-gate-card label { display: block; font-size: 12px; font-weight: 800; margin: 14px 0 6px; }
.db-gate-card input { min-height: 50px; background: #edf4ff; border: 1px solid #d3e0f5; border-radius: 11px; padding: 11px 13px; }
.db-gate-card input:focus { background: #fff; border-color: #2d67db; box-shadow: 0 0 0 3px #2d67db20; }
.db-gate-card .db-button { width: 100%; margin-top: 17px; min-height: 48px; border: 0; border-radius: 10px; background: #2d67db; color: #fff; font-weight: 750; }
.db-gate-card .db-button:hover { background: #2058c4; }

@media (max-width: 1380px) {
  .db-workspace { grid-template-columns: minmax(240px,.72fr) minmax(480px,1.4fr); }
  .feedback-panel { grid-column: 1 / -1; }
}
@media (max-width: 980px) {
  .db-shell { display: block; }
  .db-sidebar { position: fixed; left: 0; top: 72px; width: min(340px,90vw); transform: translateX(-105%); transition: transform .2s; box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  body.sidebar-visible .db-sidebar { transform: translateX(0); }
  .sidebar-heading button, .sidebar-open { display: inline-flex; }
  .sidebar-heading button { border: 0; background: transparent; font-size: 24px; cursor: pointer; }
  .sidebar-open { margin-bottom: 10px; border: 1px solid var(--db-line); background: #fff; border-radius: 8px; padding: 8px 10px; }
  .db-workspace { grid-template-columns: 1fr; }
  .feedback-panel { grid-column: auto; }
}
@media (max-width: 650px) {
  .db-topbar { padding: 0 12px; }
  .db-brand small, .db-top-actions > span { display: none; }
  .db-main { padding: 12px; }
  .db-hero { padding: 11px 13px; align-items: center; min-height: 72px; }
  .db-hero h1 { font-size: 19px; }
  .db-hero p:not(.eyebrow) { display: none; }
  .hero-score { min-width: 72px; padding: 7px; }
  .hero-score strong { font-size: 19px; }
  .task-panel, .sql-panel { padding: 13px; }
  .sql-actions .db-button { flex: 1 1 44%; }
}
