:root {
  --ink: #18211f;
  --muted: #586560;
  --paper: #f6f5f0;
  --line: #d8d9d1;
  --accent: #e75c31;
  --deep: #193c36;
  --soft: #efeee8;
  --white: #fff;
  --soft-green: #e6eee9;
  --soft-orange: #fbede7;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--deep); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
[hidden] { display: none !important; }

.topbar { height: 54px; display: flex; align-items: center; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--white); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--deep); color: #fff; font-size: 12px; }
.connection { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 12px; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--deep); display: inline-block; flex: 0 0 auto; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.button { min-height: 35px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.button:hover { border-color: var(--accent); }
.button-primary { color: #fff; border-color: var(--deep); background: var(--deep); font-weight: 650; }
.button-primary:hover { background: #24564d; border-color: #24564d; }
.button-secondary { color: var(--deep); }
.button-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.button-small { min-height: 29px; padding: 4px 9px; font-size: 12px; }

.workspace { min-height: calc(100vh - 79px); height: calc(100vh - 79px); display: grid; grid-template-columns: 225px minmax(430px, 1fr) 300px; grid-template-rows: minmax(0, 1fr); background: var(--paper); }
.sidebar, .inspector { min-height: 0; overflow: auto; background: #fbfaf7; }
.sidebar { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
.pane-heading { min-height: 37px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .055em; }
.muted { color: var(--muted); font-weight: 400; letter-spacing: 0; }
.tree-root { display: flex; align-items: center; gap: 7px; padding: 13px 12px 9px; font-weight: 650; }
.caret { color: var(--muted); }
.db-icon { color: var(--deep); }
.tree-row, .task-row { display: flex; width: 100%; align-items: center; gap: 7px; min-height: 31px; padding: 5px 12px; border: 0; background: transparent; text-align: left; color: var(--ink); font-size: 12px; cursor: pointer; }
.tree-row:hover, .task-row:hover { background: var(--soft); }
.tree-muted { color: var(--muted); cursor: default; }
.tree-section { font-weight: 650; }
.tree-count { margin-left: auto; color: var(--muted); font-size: 11px; }
.tree-child { padding-left: 31px; }
.tree-child.active { padding-left: 29px; background: var(--soft-green); box-shadow: inset 2px 0 var(--deep); color: var(--deep); font-weight: 650; }
.table-icon { color: var(--deep); }
.sidebar-separator { height: 1px; margin: 13px 0 0; background: var(--line); }
.task-summary { color: var(--accent); letter-spacing: 0; }
.task-row { gap: 9px; min-height: 33px; color: var(--muted); }
.task-row.selected { color: var(--ink); background: var(--soft); }
.task-state { width: 13px; color: var(--accent); font-weight: 700; }
.investigation-task { margin-top: 3px; color: var(--deep); }
.investigation-task.complete { color: var(--deep); background: var(--soft-green); font-weight: 650; }

.main-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.table-tabs { min-height: 39px; display: flex; align-items: stretch; overflow-x: auto; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.table-tab { display: inline-flex; align-items: center; gap: 8px; padding: 0 13px; border: 0; border-right: 1px solid var(--line); border-top: 2px solid transparent; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; cursor: pointer; }
.table-tab.active { border-top-color: var(--accent); background: var(--white); color: var(--deep); font-weight: 650; }
.table-tab i { margin-left: 6px; color: #8b938d; font-style: normal; font-weight: 400; }
.toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 45px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--white); }
.toolbar-title, .toolbar-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-title strong { font-size: 13px; }
.toolbar-actions { gap: 9px; }
.icon-button { min-width: 27px; min-height: 27px; padding: 2px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--soft); color: var(--deep); }
.toolbar-divider { height: 20px; border-left: 1px solid var(--line); }
.completion-banner { display: flex; align-items: center; gap: 11px; margin: 9px 11px 0; padding: 9px 12px; border: 1px solid #aebfb5; border-left: 3px solid var(--deep); border-radius: 6px; background: var(--soft-green); color: var(--deep); }
.completion-icon { display: grid; width: 25px; height: 25px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--deep); color: #fff; font-size: 15px; font-weight: 700; }
.completion-banner div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.completion-banner #submitWork { margin-left: auto; white-space: nowrap; }
.completion-banner strong { font-size: 13px; }
.completion-banner div span { color: var(--muted); font-size: 11px; }
.filters { display: flex; align-items: end; gap: 9px; padding: 9px 11px; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.filter-field { display: flex; min-width: 110px; flex-direction: column; gap: 3px; color: var(--muted); font-size: 10px; }
.filter-field:first-child { flex: 1 1 185px; }
.filter-field input, .filter-field select, .resume-row input, .auth-form input { width: 100%; min-height: 32px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); font-size: 12px; }
.filter-submit { min-height: 32px; padding: 5px 13px; }
.grid-scroll { min-height: 100px; flex: 1; overflow: auto; background: var(--white); }
.data-grid { min-width: 100%; }
.data-grid table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 12px; }
.data-grid th { position: sticky; top: 0; z-index: 1; height: 33px; padding: 0 9px; border-bottom: 1px solid var(--line); background: var(--soft); color: var(--muted); text-align: left; font-weight: 650; }
.data-grid td { height: 34px; padding: 0 9px; border-bottom: 1px solid #e8e8e1; }
.data-grid tbody tr { cursor: pointer; }
.data-grid tbody tr:hover { background: #f7f4ed; }
.data-grid tbody tr.selected { background: var(--soft-green); }
.data-grid tbody tr.selected td:first-child { box-shadow: inset 2px 0 var(--accent); }
.row-number { color: var(--muted); }
.cell-link { color: var(--deep); text-decoration: underline; text-decoration-color: #a8bdb5; text-underline-offset: 2px; cursor: pointer; }
.cell-status { color: var(--deep); }
.cell-edit { display: inline-flex; align-items: center; gap: 5px; }
.cell-edit button { padding: 2px 5px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--deep); cursor: pointer; opacity: .68; }
.cell-edit button:hover { border-color: var(--line); background: var(--white); opacity: 1; }
.grid-footer { display: flex; justify-content: space-between; gap: 10px; padding: 6px 11px; border-top: 1px solid var(--line); background: #fbfaf7; color: var(--muted); font-size: 11px; }
.task-panel { min-height: 108px; padding: 10px 13px 9px; border-top: 1px solid var(--line); background: var(--soft); }
.task-panel.collapsed { min-height: 35px; padding-bottom: 4px; }
.task-panel.collapsed #taskDescription, .task-panel.collapsed #taskHint, .task-panel.collapsed #taskFeedback { display: none; }
.task-panel-heading { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.task-panel-heading button { margin-left: auto; }
.task-panel-heading .accent-mark { color: var(--deep); }
.task-panel-heading .hint-toggle { margin-left: 4px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--deep); font-size: 10px; cursor: pointer; }
.task-panel-heading .hint-toggle:hover { border-color: var(--deep); }
.task-row.complete .task-state { color: var(--deep); }
.accent-mark { color: var(--accent); font-size: 10px; }
.task-panel p { max-width: 850px; margin: 6px 0 0 18px; color: var(--muted); font-size: 12px; }
.task-feedback { color: var(--deep) !important; }
.task-panel .task-hint { padding: 7px 9px; border-left: 2px solid var(--deep); background: var(--white); }

.inspector-heading { min-height: 39px; }
.inspector-content { padding: 12px; }
.empty-state { color: var(--muted); font-size: 12px; }
.record-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 11px; font-size: 14px; font-weight: 700; }
.record-chip { padding: 2px 7px; border-radius: 20px; background: var(--soft-orange); color: var(--accent); font-size: 10px; font-weight: 650; }
.detail-field { display: grid; grid-template-columns: minmax(95px, 38%) minmax(0, 1fr); align-items: center; gap: 7px; min-height: 34px; padding: 6px 0; border-bottom: 1px solid #e7e7e0; font-size: 11px; }
.detail-label { color: var(--muted); overflow-wrap: anywhere; }
.detail-value { min-width: 0; overflow-wrap: anywhere; }
.detail-value.editable { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px; }
.edit-button { padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); color: var(--deep); font-size: 10px; cursor: pointer; }
.edit-control { width: 100%; min-width: 0; max-width: 145px; min-height: 28px; flex: 1 1 95px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; }
.inline-actions { display: inline-flex; gap: 4px; }
.inline-actions button { border: 0; background: transparent; color: var(--deep); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: 10px; }
.edit-actions { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 3px; }
.icon-action { display: grid; width: 26px; height: 26px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--white); cursor: pointer; }
.icon-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.save-action { color: var(--deep); }
.cancel-action { color: var(--muted); }
.icon-action:hover { border-color: var(--deep); background: var(--soft-green); }
.relation-box { margin: 11px; padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }
.relation-box h3 { margin: 0 0 6px; color: var(--muted); font-size: 10px; letter-spacing: .045em; }
.relation-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; border-top: 1px solid var(--line); font-size: 11px; }
.relation-row button { padding: 3px 0; border: 0; background: transparent; color: var(--deep); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: 11px; }
.history-section { margin-top: 6px; }
.history-heading { border-top: 1px solid var(--line); }
.event-history { padding: 4px 12px 9px 20px; border-left: 2px solid #b9c9c0; margin: 12px 14px 10px; }
.event-item { position: relative; margin: 0 0 13px; }
.event-item::before { position: absolute; top: 3px; left: -26px; width: 8px; height: 8px; border: 2px solid #fbfaf7; border-radius: 50%; background: var(--deep); content: ""; }
.event-time { color: var(--muted); font-size: 10px; }
.event-title { margin-top: 2px; font-weight: 650; font-size: 11px; }
.event-description { margin-top: 2px; color: var(--muted); font-size: 11px; }
.statusbar { min-height: 25px; display: flex; align-items: center; gap: 17px; padding: 0 11px; border-top: 1px solid #31564e; background: var(--deep); color: #f4f6f2; font-size: 10px; }
.footer-note { margin-left: auto; }
.statusbar .connection-dot { width: 7px; height: 7px; background: #f4f6f2; }

.auth-screen { position: fixed; inset: 54px 0 25px; z-index: 3; display: grid; place-items: center; overflow: auto; padding: 20px; background: rgb(246 245 240 / 93%); }
.auth-card { width: min(100%, 440px); padding: 26px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.auth-kicker { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.auth-card h1 { margin: 12px 0 6px; font-size: clamp(22px, 4vw, 29px); letter-spacing: -.03em; }
.auth-card > p { margin: 0; font-size: 12px; }
.auth-form { display: grid; gap: 10px; margin-top: 18px; }
.auth-form label, .resume-form label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.auth-form input, .resume-row input { min-height: 36px; font-size: 13px; }
.auth-form .button { margin-top: 2px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 17px 0 13px; color: var(--muted); font-size: 10px; }
.auth-divider::before, .auth-divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.resume-row { display: flex; gap: 7px; margin-top: 4px; }
.resume-row input { min-width: 0; flex: 1; }
.auth-message { min-height: 19px; margin-top: 9px; color: var(--deep); font-size: 11px; overflow-wrap: anywhere; }
.privacy-note { margin-top: 4px !important; padding-top: 10px; border-top: 1px solid var(--line); }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 195px minmax(380px, 1fr) 265px; }
}
@media (max-width: 800px) {
  .workspace { height: auto; min-height: calc(100vh - 79px); grid-template-columns: 180px minmax(0, 1fr); }
  .sidebar { grid-row: 1; min-height: 430px; }
  .main-pane { grid-column: 2; grid-row: 1; min-height: 590px; }
  .inspector { grid-column: 1 / -1; grid-row: 2; min-height: 320px; border-top: 1px solid var(--line); border-left: 0; }
  .inspector-content { max-width: 700px; }
  .history-section { max-width: 700px; }
  .auth-screen { top: 54px; }
}
@media (max-width: 620px) {
  .topbar { height: auto; min-height: 52px; flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .brand { flex: 1 1 100%; }
  .top-actions { margin-left: 0; }
  .connection { margin-left: auto; }
  .workspace { display: flex; flex-direction: column; min-height: calc(100vh - 85px); }
  .sidebar { min-height: auto; max-height: 230px; border-right: 0; border-bottom: 1px solid var(--line); }
  .tree-muted, .tree-root, .sidebar-separator { display: none; }
  .main-pane { min-height: 570px; }
  .filters { flex-wrap: wrap; }
  .filter-field:first-child { flex-basis: 100%; }
  .filter-field { flex: 1; }
  .filter-submit { align-self: end; }
  .task-panel { min-height: 122px; }
  .grid-footer { flex-wrap: wrap; }
  .auth-screen { inset: 70px 0 25px; place-items: start center; }
  .auth-card { padding: 20px; }
}
