/* ───────── Tokens ───────── */
:root {
  --bg: #ffffff;
  --card: #ffffff;
  --grid: #e3e3e3;
  --head: #f3f3f3;
  --head-text: #5c5c5c;
  --head-on: #d3ebdd;
  --text: #1d1d1f;
  --muted: #5f6368;
  --border: #d4d4d4;
  --accent: #107c41;
  --accent-ink: #0b5c30;
  --accent-weak: #e7f4ec;
  --title: #107c41;
  --title-text: #ffffff;
  --danger: #b42318;
  --c1: #107c41;
  --c2: #2563eb;
  --c3: #c2410c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .18);
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --col: 96px;
  --row: 28px;
  --gutter: 46px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1b1c1e;
  --card: #242528;
  --grid: #34363a;
  --head: #2a2c2f;
  --head-text: #a3a7ad;
  --head-on: #1f4d33;
  --text: #ececec;
  --muted: #a3a7ad;
  --border: #44464b;
  --accent: #3ccf7e;
  --accent-ink: #7be5aa;
  --accent-weak: #1d3a2b;
  --title: #0f5a31;
  --danger: #ff8a7a;
  --c1: #3ccf7e;
  --c2: #7aa7ff;
  --c3: #f0a35e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
/* ───────── Base ───────── */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { font: 500 11px var(--mono); padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--head); }

.app { height: 100dvh; display: flex; flex-direction: column; }

/* ───────── Title bar ───────── */
.titlebar { background: var(--title); color: var(--title-text); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; height: 44px; flex: none; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { display: grid; place-items: center; color: #fff; }
.logo rect { fill: rgba(255, 255, 255, .22); }
.filename { margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filename span { opacity: .65; font-weight: 400; }
.saved { font-size: 12px; opacity: .8; white-space: nowrap; }
.tbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 6px; background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; font-size: 13px; font-weight: 500; transition: background .15s; }
.tbtn:hover { background: rgba(255, 255, 255, .22); }
.tbtn.icon { padding: 0 8px; }
.tbtn:focus-visible { outline-color: #fff; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ───────── Formula bar ───────── */
.formulabar { display: flex; align-items: stretch; height: 30px; border-bottom: 1px solid var(--border); background: var(--bg); flex: none; font-family: var(--mono); font-size: 12.5px; }
.namebox { width: 84px; flex: none; display: grid; align-items: center; padding: 0 10px; border-right: 1px solid var(--border); font-weight: 500; }
.fx { width: 38px; flex: none; display: grid; place-items: center; color: var(--muted); font-style: italic; font-family: var(--sans); font-weight: 600; border-right: 1px solid var(--border); }
.fxtext { flex: 1; min-width: 0; padding: 0 12px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fxtext.typing::after { content: ''; display: inline-block; width: 1px; height: 14px; background: var(--text); margin-left: 1px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ───────── Sheet surface (grid, headers) ───────── */
.sheets { position: relative; flex: 1; min-height: 0; background: var(--bg); }
.sheet { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; }
.sheet[hidden] { display: none; }
.surface { display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); grid-template-rows: 24px auto; min-width: 760px; }
.corner, .colhead, .rowhead { background: var(--head); color: var(--head-text); font-size: 11.5px; position: sticky; z-index: 5; user-select: none; }
.corner { top: 0; left: 0; z-index: 7; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.corner::after { content: ''; position: absolute; right: 4px; bottom: 4px; border: 6px solid transparent; border-right-color: var(--border); border-bottom-color: var(--border); }
.colhead { top: 0; z-index: 6; display: flex; overflow: hidden; border-bottom: 1px solid var(--border); }
.colhead span { flex: none; width: var(--col); display: grid; place-items: center; border-right: 1px solid var(--border); }
.rowhead { left: 0; border-right: 1px solid var(--border); overflow: hidden; }
.rowhead span { display: grid; place-items: center; height: var(--row); border-bottom: 1px solid var(--border); }
.colhead span.on, .rowhead span.on { background: var(--head-on); color: var(--accent-ink); font-weight: 600; }
.colhead span.on { box-shadow: inset 0 -2px var(--accent); }
.rowhead span.on { box-shadow: inset -2px 0 var(--accent); }
.objects { position: relative; padding: 28px 28px calc(var(--row) * var(--extra, 12)) 28px; background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px), linear-gradient(to bottom, var(--grid) 1px, transparent 1px); background-size: var(--col) var(--row); min-width: 0; }

.selection { position: absolute; z-index: 4; border: 2px solid var(--accent); pointer-events: none; transition: left .08s, top .08s, width .08s, height .08s; }
.selection[hidden] { display: none; }
.selection .fill { position: absolute; right: -5px; bottom: -5px; width: 8px; height: 8px; background: var(--accent); border: 1px solid var(--bg); }

/* ───────── Objects (cards on the grid) ───────── */
.obj { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.obj-head { margin-bottom: 12px; }
.obj-head.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.obj-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.obj-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.eyebrow { margin: 0 0 4px; font: 600 11.5px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); font-weight: 500; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--head); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0a1f14; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li, .chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent-weak); color: var(--accent-ink); border: 1px solid transparent; }
.hl { font-weight: 700; color: var(--accent-ink); background: var(--accent-weak); padding: 0 3px; border-radius: 3px; }

/* Summary layout */
.summary-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
.hero { grid-column: span 8; display: flex; gap: 24px; align-items: center; }
.record { grid-column: span 4; padding: 0; overflow: hidden; align-self: stretch; }
.kpis { grid-column: span 12; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.chart-card { grid-column: span 7; }
.gantt-card { grid-column: span 5; }

.photo-frame { position: relative; flex: none; width: 168px; aspect-ratio: 3 / 4; border: 1px solid var(--accent); }
.photo-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-frame .h { position: absolute; width: 8px; height: 8px; background: var(--card); border: 1px solid var(--accent); }
.h.tl { left: -5px; top: -5px; } .h.tr { right: -5px; top: -5px; } .h.bl { left: -5px; bottom: -5px; } .h.br { right: -5px; bottom: -5px; }
.hero-text h2 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -.02em; }
.lede { margin: 0 0 16px; color: var(--muted); font-size: 15.5px; max-width: 54ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Record sheet */
.rec { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rec th, .rec td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.rec tr:last-child th, .rec tr:last-child td { border-bottom: 0; }
.rec th { width: 34%; background: var(--head); color: var(--head-text); font-weight: 500; font-size: 12.5px; border-right: 1px solid var(--grid); }
.rec td a { word-break: break-all; }
.rec button.copy { margin-left: 8px; padding: 1px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--card); }
.rec button.copy:hover { background: var(--head); }
.contact-rec th { width: 28%; }

/* KPI tiles */
.kpi { text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--accent); transition: transform .15s, box-shadow .15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.kpi .v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; font-weight: 600; }
.kpi .n { font-size: 12px; color: var(--muted); }

/* Bar chart (HTML so text stays crisp) */
.chart { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: minmax(110px, 36%) minmax(0, 1fr) 62px; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-radius: 4px; padding: 4px 6px; }
.bar:hover, .bar:focus-visible { background: var(--head); }
.bar .lab { font-size: 13px; line-height: 1.25; }
.bar .lab small { display: block; color: var(--muted); font-size: 11.5px; }
.bar .track { height: 14px; background: var(--head); border-radius: 2px; overflow: hidden; }
.bar .fillbar { display: block; height: 100%; width: 0; border-radius: 2px; transition: width .7s cubic-bezier(.2, .7, .2, 1); }
.bar .val { font: 600 13px var(--mono); text-align: right; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.fill-c1 { background: var(--c1); } .fill-c2 { background: var(--c2); } .fill-c3 { background: var(--c3); }

/* Gantt */
.gantt { position: relative; padding-top: 22px; }
.gantt .axis { position: absolute; left: 0; right: 0; top: 0; height: 18px; font-size: 11px; color: var(--muted); }
.gantt .tick { position: absolute; top: 0; bottom: -100px; border-left: 1px dashed var(--grid); padding-left: 4px; }
.g-row { position: relative; height: 34px; margin-top: 8px; }
.g-bar { position: absolute; top: 0; height: 100%; min-width: 6px; border-radius: 3px; color: #fff; font-size: 12px; font-weight: 600; padding: 0 8px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; border: 0; }
:root[data-theme="dark"] .g-bar { color: #0c1410; }
.g-bar.c1 { background: var(--c1); } .g-bar.c2 { background: var(--c2); } .g-bar.c3 { background: var(--c3); }
.g-note { margin-top: 14px; font-size: 12.5px; color: var(--muted); }

/* ───────── Excel-style tables ───────── */
.table-obj { padding: 0; overflow: hidden; }
.table-obj .obj-head { padding: 16px 16px 0; }
.tscroll { overflow: auto; max-width: 100%; }
.xl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.xl th, .xl td { border: 1px solid var(--grid); padding: 6px 10px; text-align: left; vertical-align: top; }
.xl thead th { position: sticky; top: 0; background: var(--head); color: var(--head-text); font-weight: 600; font-size: 12.5px; z-index: 1; white-space: nowrap; }
.xl .rn { width: 38px; min-width: 38px; background: var(--head); color: var(--head-text); text-align: center; font-size: 11.5px; padding: 6px 0; user-select: none; }
.xl .gc { width: 34px; min-width: 34px; text-align: center; padding: 4px; }
.xl tbody tr:not(.co):hover td { background: color-mix(in srgb, var(--accent-weak) 55%, transparent); }
.xl tr.co td { background: var(--head); font-weight: 600; }
.xl tr.co.open td { border-bottom-color: var(--accent); }
.xl tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { background: var(--accent-weak); box-shadow: inset 0 0 0 9999px var(--accent-weak); } 100% { box-shadow: none; } }
.grp { width: 22px; height: 22px; border: 1px solid var(--border); background: var(--card); border-radius: 3px; font: 600 14px/1 var(--mono); display: inline-grid; place-items: center; padding: 0; color: var(--accent-ink); }
.grp:hover { background: var(--accent-weak); border-color: var(--accent); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
.dot.c1 { background: var(--c1); } .dot.c2 { background: var(--c2); } .dot.c3 { background: var(--c3); }
.xl .sub td { font-weight: 400; }
.xl .sub .txt { padding-left: 24px; max-width: 70ch; }
.xl .sub .tags { margin-top: 6px; }
.kr { white-space: nowrap; font: 600 13px var(--mono); }
.kr.up { color: var(--accent-ink); } .kr.down { color: var(--c2); }
.kr small { font: 400 12px var(--sans); color: var(--muted); margin-left: 4px; white-space: normal; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.null { color: var(--muted); font-style: italic; }

/* Skills */
.skills-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.side-stack { display: grid; gap: 20px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select, .compose input, .compose textarea, .editor textarea { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; min-height: 34px; }
.filters input { width: 200px; }
.plain { padding: 0; margin: 0; font-size: 13.5px; }
.plain.list { list-style: none; display: grid; gap: 10px; }
.plain b { display: block; }
.plain small { color: var(--muted); }

/* SQL */
.sql-layout { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr); gap: 20px; align-items: start; }
.sql-main { display: grid; gap: 20px; min-width: 0; }
.schema .tbl { margin-bottom: 12px; }
.schema .tname { font: 600 13px var(--mono); background: var(--accent-weak); color: var(--accent-ink); border: 0; border-radius: 4px; padding: 3px 8px; }
.schema .tname:hover { filter: brightness(.96); }
.schema .tname small { font-weight: 400; opacity: .8; margin-left: 6px; }
.schema ul { list-style: none; margin: 4px 0 0 8px; padding: 0; font: 12px/1.6 var(--mono); color: var(--muted); }
.editor textarea { width: 100%; font: 13.5px/1.55 var(--mono); resize: vertical; min-height: 96px; tab-size: 2; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.examples button { font: 12px var(--mono); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); }
.examples button:hover { border-color: var(--accent); background: var(--accent-weak); }
.meta { font: 12px var(--mono); color: var(--muted); }
.sqlerr { margin: 0; padding: 10px 12px; border: 1px solid var(--danger); border-radius: 6px; color: var(--danger); font: 13px var(--mono); white-space: pre-wrap; }
.results .xl th, .results .xl td { white-space: nowrap; }

/* Tooltip */
.tip { position: fixed; z-index: 100; max-width: 260px; padding: 6px 9px; border-radius: 6px; background: #202124; color: #fff; font-size: 12px; line-height: 1.4; pointer-events: none; opacity: 0; transform: translateY(2px); transition: opacity .12s, transform .12s; box-shadow: var(--shadow-lg); }
.tip.on { opacity: 1; transform: none; }
:root[data-theme="dark"] .tip { background: #f1f3f4; color: #1d1d1f; }

/* Clickable rows + inspector lists */
tr.click, .xl tr[data-b], .xl tr.co, .xl tr[data-skill], .results tbody tr { cursor: pointer; }
.xl tr.sel td { background: var(--accent-weak) !important; box-shadow: inset 0 0 0 0 transparent; }
.xl tr.sel td:nth-child(2), .xl tr.sel td.rn { box-shadow: inset 3px 0 var(--accent); }
.insp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.insp-list button { width: 100%; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; line-height: 1.4; display: grid; gap: 2px; }
.insp-list button:hover { border-color: var(--accent); background: var(--accent-weak); }
.insp-list small { color: var(--muted); font-size: 12px; }
.insp-h { margin: 0; font: 600 11.5px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 5px 0; border-bottom: 1px solid var(--grid); }
.kv th { width: 38%; color: var(--muted); font-weight: 500; padding-right: 10px; font-family: var(--mono); font-size: 12px; }
.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini th, .mini td { border: 1px solid var(--grid); padding: 3px 6px; text-align: left; white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.mini th { background: var(--head); color: var(--head-text); font-weight: 600; }
.mini-wrap { overflow: auto; }
.opt { margin-left: 6px; font: 500 11px var(--sans); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; vertical-align: middle; }
.meta-hint { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.res-tools { display: flex; align-items: center; gap: 10px; }
.schema .tbl { margin-bottom: 14px; }
.schema .trow { display: flex; align-items: center; gap: 6px; }
.schema .why { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.schema .info { width: 22px; height: 22px; border: 1px solid var(--border); background: var(--card); border-radius: 50%; font: 600 12px/1 var(--sans); color: var(--muted); padding: 0; }
.schema .info:hover { border-color: var(--accent); color: var(--accent-ink); }
.schema li { cursor: help; }
.xl th[data-tip] { cursor: help; }

/* Ask in plain English */
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; min-height: 38px; }
.answer { margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--accent-weak); border-radius: 0 6px 6px 0; display: grid; gap: 8px; }
.answer[hidden] { display: none; }
.answer .a { font-size: 15px; font-weight: 600; margin: 0; }
.answer .code { background: var(--card); }
.answer .note { margin: 0; font-size: 12.5px; color: var(--muted); }
.answer.miss { border-left-color: var(--danger); background: transparent; border: 1px solid var(--border); border-left: 3px solid var(--danger); }

/* Contact */
.contact-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.contact-layout > .obj:first-child { padding: 16px 0 0; overflow: hidden; }
.contact-layout > .obj:first-child .obj-head { padding: 0 16px; }
.compose { display: grid; gap: 6px; }
.compose label { font-size: 12.5px; font-weight: 600; margin-top: 6px; }
.compose textarea { resize: vertical; }
.compose .btn { margin-top: 10px; justify-self: start; }

/* ───────── Inspector ───────── */
.inspector { position: absolute; z-index: 20; top: 12px; right: 12px; bottom: 12px; width: 340px; max-width: calc(100% - 24px); background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slidein .22s cubic-bezier(.2, .8, .2, 1); }
.inspector[hidden] { display: none; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
.insp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--head); border-radius: 8px 8px 0 0; }
.insp-head h3 { margin: 0; font-size: 14px; }
.x { width: 28px; height: 28px; border: 0; background: none; border-radius: 4px; color: var(--muted); }
.x:hover { background: var(--grid); color: var(--text); }
.insp-body { padding: 16px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.insp-big { font-size: 44px; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--accent-ink); }
.insp-big small { display: block; margin-top: 6px; font: 500 13px var(--sans); color: var(--muted); letter-spacing: 0; }
.insp-meta { font-size: 12.5px; color: var(--muted); }
.insp-meta b { color: var(--text); }
.insp-body p { margin: 0; }
.code { font: 12px/1.5 var(--mono); background: var(--head); border: 1px solid var(--grid); border-radius: 6px; padding: 8px 10px; overflow-wrap: anywhere; }

/* ───────── Tabs + status ───────── */
.bottom { flex: none; border-top: 1px solid var(--border); background: var(--head); }
.tabs { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; padding: 0 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; position: relative; padding: 8px 18px 7px; border: 0; background: none; color: var(--head-text); font-size: 13px; font-weight: 500; border-bottom: 3px solid transparent; }
.tab:hover { background: var(--grid); }
.tab[aria-selected="true"] { background: var(--bg); color: var(--accent-ink); font-weight: 600; border-bottom-color: var(--accent); }
.status { display: flex; gap: 16px; align-items: center; padding: 3px 12px; background: var(--accent); color: #fff; font-size: 12px; }
:root[data-theme="dark"] .status { background: var(--title); }
.status .hint { margin-left: auto; opacity: .85; }
.status .ready { min-width: 90px; }

/* ───────── Responsive ───────── */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero, .record, .chart-card, .gantt-card { grid-column: span 12; }
  .skills-layout, .sql-layout, .contact-layout { grid-template-columns: minmax(0, 1fr); }
  .sql-layout .schema { order: 2; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .saved, .status .hint, .tbtn span, .corner, .colhead, .rowhead, .fx { display: none; }
  .tbtn { padding: 0 8px; }
  .surface { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; min-width: 0; }
  .objects { padding: 12px 12px 72px; background-size: 64px 28px; }
  .selection { display: none; }
  .summary-grid { gap: 12px; }
  .hero { flex-direction: column; align-items: flex-start; gap: 20px; }
  .photo-frame { width: 132px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .v { font-size: 26px; }
  .bar { grid-template-columns: minmax(0, 1fr) 56px; row-gap: 4px; }
  .bar .track { grid-column: 1 / -1; grid-row: 2; }
  .filters input { width: 100%; flex: 1 1 100%; }
  .filters select { flex: 1 1 100%; }
  .xl .rn { display: none; }
  .experience-hide-m { display: none; }
  #expTable thead th:nth-child(4), #expTable td.role-c, #expTable thead th:nth-child(5), #expTable td.per-c { display: none; }
  .inspector { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 62%; max-width: none; }
  .formulabar { height: 28px; }
  .namebox { width: 56px; }
  .tab { padding: 10px 16px 9px; }
  .sub-mobile { display: block; }
  #expTable, #expTable tbody { display: block; width: 100%; }
  #expTable thead { display: none; }
  #expTable tr { display: block; padding: 8px 10px; border-bottom: 1px solid var(--grid); }
  #expTable tr[hidden] { display: none; }
  #expTable td, #expTable td.rn { border: 0; padding: 0; }
  #expTable td.rn, #expTable tr.sub td.gc, #expTable td.role-c, #expTable td.per-c { display: none; }
  #expTable tr.co { display: flex; align-items: flex-start; gap: 10px; background: var(--head); }
  #expTable tr.co td { background: none; }
  #expTable tr.co td:nth-child(3) { flex: 1; min-width: 0; }
  #expTable tr.co .kr { max-width: 42%; }
  #expTable tr.sub td { display: block; }
  #expTable tr.sub td.rn { display: none; }
  #expTable tr.sub .kr { padding-top: 6px; }
  #expTable tr.sub .txt { max-width: none; padding-left: 0; }
}
@media (min-width: 761px) { .sub-mobile { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ───────── Round 2 refinements ───────── */

/* Experience: calmer, easier to read when expanded */
.xl .hl { background: none; padding: 0; color: var(--accent-ink); }
.xl .chip { background: var(--head); color: var(--muted); font-size: 11.5px; }
.xl tr.co td { vertical-align: middle; padding: 12px 12px; }
.xl tr.co td.rn { vertical-align: middle; }
.xl tr.sub td { padding: 14px 16px; background: color-mix(in srgb, var(--accent-weak) 28%, var(--card)); border-bottom: 1px solid var(--grid); }
.xl tr.sub td.txt { padding-left: 24px; font-size: 14px; line-height: 1.7; max-width: 72ch; }
.xl tr.sub.c1 td.txt { box-shadow: inset 4px 0 var(--c1); }
.xl tr.sub.c2 td.txt { box-shadow: inset 4px 0 var(--c2); }
.xl tr.sub.c3 td.txt { box-shadow: inset 4px 0 var(--c3); }
.xl tr.sub .tags { margin-top: 10px; }
.kr b { display: block; font: 600 15px var(--mono); }
.kr small { display: block; margin: 2px 0 0; font: 400 12px/1.35 var(--sans); }
.xl tr.sub .kr { background: transparent; }

/* Skills */
.cat-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.catbtn { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 12.5px; }
.catbtn:hover { border-color: var(--accent); }
.catbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .catbtn[aria-pressed="true"] { color: #0a1f14; }
.skills-main { padding: 0 0 16px; }
.skills-main .obj-head { padding: 16px 16px 0; }
.skill-note { margin: 12px 16px 0; font-size: 12.5px; color: var(--muted); }
.skill-note .n, .pill .n { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font: 600 11px var(--sans); }
:root[data-theme="dark"] .skill-note .n, :root[data-theme="dark"] .pill .n { color: #0a1f14; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; padding: 14px 16px 0; }
.skill-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px 14px; background: var(--card); border-top: 3px solid var(--accent); }
.skill-card h4 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 10px; font-size: 13.5px; }
.skill-card h4 span { font: 500 12px var(--sans); color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: 13px; transition: border-color .12s, background .12s, transform .12s; }
.pill:hover { border-color: var(--accent); transform: translateY(-1px); }
.pill.used { background: var(--accent-weak); border-color: transparent; color: var(--accent-ink); font-weight: 500; }
.pill.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.plain.list li { padding-left: 12px; border-left: 3px solid var(--accent); }

/* SQL: one query card with distinct zones */
.obj.query { padding: 0; overflow: hidden; }
.askbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--accent-weak); border-bottom: 1px solid var(--border); }
.asklabel { font-weight: 700; color: var(--accent-ink); white-space: nowrap; }
.askbar input { flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; min-height: 38px; }
.askex { padding: 10px 16px 0; margin: 0; }
.query .answer { margin: 12px 16px 0; }
.ed { margin-top: 14px; background: #1e2430; color: #e6edf3; }
:root[data-theme="dark"] .ed { background: #12151b; }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #9aa4b2; }
.ed-title { font: 600 12px var(--mono); color: #7ee2a8; letter-spacing: .05em; }
.ed-sub { flex: 1; min-width: 0; }
.ed kbd { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); color: #cbd5e1; }
.ed textarea { display: block; width: 100%; background: transparent; color: inherit; border: 0; border-radius: 0; padding: 14px 16px; font: 13.5px/1.6 var(--mono); resize: vertical; min-height: 96px; }
.ed textarea:focus-visible { outline: none; box-shadow: inset 3px 0 #7ee2a8; }
.sqlex { padding: 10px 16px 12px; margin: 0; background: var(--head); border-top: 1px solid var(--border); }
.results .xl tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--head) 55%, transparent); }
.results .xl tbody tr:hover td { background: var(--accent-weak); }
.meta { background: var(--accent-weak); color: var(--accent-ink); padding: 2px 10px; border-radius: 999px; }
.schema { background: color-mix(in srgb, var(--head) 55%, var(--card)); }
@media (max-width: 760px) {
  .askbar { flex-wrap: wrap; }
  .asklabel { width: 100%; }
  .ed-head { flex-wrap: wrap; }
  .ed-sub { display: none; }
  .skill-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ───────── Round 3 ───────── */
/* Bounded grid with "add more rows" like Google Sheets */
.addrows { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; font-size: 13px; color: var(--muted); background: var(--head); border-top: 1px solid var(--border); min-width: 760px; position: sticky; left: 0; }
.addrows input { width: 64px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); min-height: 30px; }
@media (max-width: 760px) { .addrows { display: none; } }

/* Skills: tidy pills, packed cards */
.skill-grid { display: block; columns: 3 270px; column-gap: 14px; }
.skill-card { break-inside: avoid; margin-bottom: 14px; }
.pill { white-space: nowrap; max-width: 100%; }

/* SQL editor: light, calm code panel */
.ed { background: var(--head); color: var(--text); border-top: 1px solid var(--border); }
:root[data-theme="dark"] .ed { background: #1c1e21; }
.ed-head { border-bottom: 1px solid var(--grid); color: var(--muted); }
.ed-title { color: var(--accent-ink); }
.ed kbd { background: var(--card); border-color: var(--border); color: var(--text); }
.ed textarea { background: var(--card); margin: 12px 16px 14px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; color: var(--text); }
:root[data-theme="dark"] .ed textarea { background: #15171a; }
.ed textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; box-shadow: none; }
.sqlex { background: var(--card); }
@media (max-width: 760px) { .skill-grid { columns: 1; } }

/* ───────── Round 4 ───────── */
/* SQL card: grey header, white editor, grey footer, all flush */
.ed { background: var(--card); margin-top: 14px; border-top: 1px solid var(--border); }
:root[data-theme="dark"] .ed { background: var(--card); }
.ed-head { background: var(--head); }
.ed textarea { margin: 0; width: 100%; border: 0; border-radius: 0; background: var(--card); padding: 14px 16px; }
:root[data-theme="dark"] .ed textarea { background: var(--card); }
.ed textarea:focus-visible { outline: none; box-shadow: inset 3px 0 var(--accent); }
.sqlex { background: var(--head); border-top: 1px solid var(--border); }

/* Share dialog */
.dlg { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: rgba(0, 0, 0, .38); }
.dlg form { padding: 20px 22px 22px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-sub { margin: 4px 0 16px; color: var(--muted); }
.dlg-opts { display: grid; gap: 10px; }
.opt-card { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); transition: border-color .12s, background .12s; }
.opt-card:hover { border-color: var(--accent); background: var(--accent-weak); }
.opt-card b { font-size: 14.5px; }
.opt-card b i { font: 500 12px var(--sans); color: var(--muted); margin-left: 6px; }
.opt-card span { font-size: 13px; color: var(--muted); }

/* Resilience: keep the layout correct even if scripts load late or not at all */
.objects { grid-area: 2 / 2; }
.pending .sheets { visibility: hidden; }

.form-note { margin: 12px 0 0; font-size: 13px; line-height: 1.45; }
.form-note.ok { color: var(--green, #1a7f4b); }
.form-note.err { color: var(--muted, #6b7280); }
.form-note a { color: inherit; text-decoration: underline; }
