:root {
  --ink: #162c4c;
  --muted: #657895;
  --blue: #1769aa;
  --blue-dark: #104d80;
  --line: #c6d8eb;
  --surface: rgba(255, 255, 255, .9);
  --shadow: 0 16px 40px rgba(36, 82, 130, .12);
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #d7ecfb 0%, #f7fbff 52%, #c8e0f5 100%);
  font-family: Georgia, 'Times New Roman', serif;
}
button, input { font: inherit; }
.app-shell { width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 48px; }
.topbar, .control-panel, .workspace-panel { border: 1px solid rgba(147, 184, 216, .6); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 32px; background: linear-gradient(120deg, rgba(255,255,255,.96), rgba(231,245,255,.88)); }
.eyebrow { margin: 0 0 7px; color: var(--blue); font: 700 11px 'Segoe UI', Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; color: var(--blue-dark); font-size: clamp(34px, 5vw, 64px); line-height: .95; }
h2 { margin-bottom: 0; font-size: 24px; }
.subtitle { max-width: 620px; margin-bottom: 0; color: var(--muted); font: 15px 'Segoe UI', Arial, sans-serif; }
.back-link { padding: 10px 14px; border: 1px solid #9fc3e4; border-radius: 8px; color: var(--blue-dark); background: #eef7ff; font: 600 13px 'Segoe UI', Arial, sans-serif; text-decoration: none; white-space: nowrap; }
.control-panel, .workspace-panel { margin-top: 20px; padding: 24px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.status-pill { padding: 7px 10px; border: 1px solid #b5d3eb; border-radius: 999px; color: var(--blue-dark); background: #e9f5ff; font: 600 12px 'Segoe UI', Arial, sans-serif; }
.import-row, .table-tools { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.file-picker { display: inline-flex; align-items: center; min-height: 42px; padding: 0 16px; border-radius: 8px; color: #fff; background: var(--blue); font: 600 13px 'Segoe UI', Arial, sans-serif; cursor: pointer; }
.file-picker:hover { background: var(--blue-dark); }
.file-picker input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.button { min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font: 600 13px 'Segoe UI', Arial, sans-serif; }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-quiet { border-color: #b8cfe5; color: var(--blue-dark); background: #f7fbff; }
.message, .table-summary { margin: 14px 0 0; color: var(--muted); font: 13px 'Segoe UI', Arial, sans-serif; }
.message.error { color: #a63d3d; }
.row-editor { margin-top: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: #f7fbff; }
.row-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.row-editor-heading h3 { margin: 0; color: var(--blue-dark); font-size: 20px; }
.row-editor-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 18px 0; }
.row-editor-field { display: grid; gap: 6px; color: var(--muted); font: 600 11px 'Segoe UI', Arial, sans-serif; }
.row-editor-field input { width: 100%; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font: 13px 'Segoe UI', Arial, sans-serif; }
.row-editor-field input:focus { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 3px rgba(23,105,170,.12); }
.table-heading { align-items: center; }
.table-tools { margin-top: 0; }
.search-box input { width: 230px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--ink); background: #fff; font: 13px 'Segoe UI', Arial, sans-serif; }
.search-box input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,170,.12); }
.sheet-tabs { display: flex; gap: 8px; overflow-x: auto; margin-top: 22px; padding-bottom: 3px; }
.sheet-tab { flex: 0 0 auto; padding: 9px 13px; border: 1px solid #b7cfe5; border-radius: 7px; color: var(--blue-dark); background: #eff7fe; cursor: pointer; font: 600 12px 'Segoe UI', Arial, sans-serif; }
.sheet-tab.active { color: #fff; border-color: var(--blue); background: var(--blue); }
.table-frame { position: relative; overflow: auto; max-height: 680px; margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; color: var(--ink); font: 12px 'Segoe UI', Arial, sans-serif; }
#data-table thead { position: sticky; top: 0; z-index: 8; background: #fff; }
#data-table thead tr:first-child { height: 28px; }
#data-table thead tr:nth-child(2) { height: 52px; }
#data-table thead .column-letter-row th { position: sticky; top: 0; z-index: 2; height: 28px; padding: 5px 8px; color: #fff !important; background: #1769aa !important; }
#data-table thead tr:nth-child(2) th { position: sticky; top: 28px; z-index: 2; height: 52px; }
th, td { min-width: 130px; padding: 11px 12px; border-right: 1px solid #d8e5f1; border-bottom: 1px solid #d8e5f1; text-align: left; vertical-align: top; white-space: pre-wrap; }
th { position: sticky; top: 28px; z-index: 1; color: #fff; background: var(--blue-dark); font-size: 11px; }
.column-letter { position: sticky; top: 0; min-width: 130px; height: 28px; padding: 5px 8px; color: #fff; background: #1769aa; text-align: center; }
.coordinate-corner, .row-number-heading, .row-number { min-width: 48px; width: 48px; padding: 8px 6px; text-align: center; }
.coordinate-corner, .row-number-heading { background: #104d80; }
.row-number { position: sticky; left: 0; z-index: 2; color: #52708d; background: #edf6fd; font-weight: 600; }
#data-table th:first-child, #data-table td:first-child { position: sticky; left: 0; z-index: 4; width: 48px; min-width: 48px; max-width: 48px; background: #edf6fd; }
#data-table th:nth-child(2), #data-table td:nth-child(2) { position: sticky; left: 48px; z-index: 3; width: 140px; min-width: 140px; background: #fff; }
#data-table th:nth-child(3), #data-table td:nth-child(3) { position: sticky; left: 188px; z-index: 3; width: 240px; min-width: 240px; background: #fff; }
#data-table th:nth-child(4), #data-table td:nth-child(4) { position: sticky; left: 428px; z-index: 3; width: 180px; min-width: 180px; background: #fff; }
#data-table thead .column-letter-row th:nth-child(-n+4) { z-index: 12; }
#data-table thead tr:nth-child(2) th:nth-child(-n+4) { z-index: 11; }
#data-table thead .column-letter-row th:first-child, #data-table thead .column-letter-row th:nth-child(2), #data-table thead .column-letter-row th:nth-child(3), #data-table thead .column-letter-row th:nth-child(4) { background: #1769aa; }
#data-table thead tr:nth-child(2) th:first-child, #data-table thead tr:nth-child(2) th:nth-child(2), #data-table thead tr:nth-child(2) th:nth-child(3), #data-table thead tr:nth-child(2) th:nth-child(4) { background: var(--blue-dark); }
tbody tr:nth-child(even) { background: #f7fbff; }
tbody tr:hover { background: #e7f3ff; }
.empty-state { padding: 60px 20px; color: var(--muted); font: 14px 'Segoe UI', Arial, sans-serif; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
  .app-shell { width: min(100% - 20px, 1500px); padding-top: 10px; }
  .topbar, .panel-heading, .import-row, .table-heading { flex-direction: column; }
  .topbar, .control-panel, .workspace-panel { padding: 18px; }
  .table-tools, .search-box, .search-box input, .file-picker, .button { width: 100%; }
  .table-tools { align-items: stretch; }
}
