:root {
  --ink: #082038;
  --muted: #63788d;
  --blue: #0870c0;
  --sky: #36a4e8;
  --bg: #f4f7fa;
  --line: #d9e3ec;
  --card: #ffffff;
  --amber: #d99a2b;
  --red: #c54f5b;
  --teal: #00888a;
  --navy-2: #0d3151;
  --blue-soft: #eaf5fd;
  --teal-soft: #e7f5f5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(520px, 1.1fr) minmax(480px, 0.9fr);
  background: #fff;
}

.login-visual {
  padding: 42px;
  background:
    linear-gradient(rgba(8, 32, 56, 0.54), rgba(8, 32, 56, 0.76)),
    url("https://images.unsplash.com/photo-1598328969323-45016c50d8c9?auto=format&fit=crop&w=1600&q=80");
  background-size: cover;
  background-position: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-brand,
.agintel-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  object-position: 50% 38%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: #fff;
}

.login-brand span,
.eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-brand span,
.login-visual .eyebrow {
  color: #91bdd9;
}

.login-brand h1 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.15;
}

.login-insight {
  max-width: 680px;
}

.login-insight strong {
  display: block;
  max-width: 620px;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1.1;
}

.mini-flow {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-flow b {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.mini-flow i {
  width: 46px;
  height: 1px;
  background: rgba(255, 255, 255, 0.55);
}

.login-panel {
  width: min(520px, calc(100% - 80px));
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 18px;
}

.agintel-logo img {
  width: 76px;
  height: 76px;
  border-radius: 10px;
  border: 1px solid #d7e3ec;
  object-fit: cover;
  object-position: 50% 24%;
  box-shadow: 0 8px 22px rgba(8, 32, 56, 0.12);
}

.agintel-logo > span {
  color: #071f38;
  font-size: 44px;
  font-weight: 650;
  line-height: 1;
}

.agintel-logo > span span {
  color: var(--blue);
}

.login-panel h2 {
  margin: 4px 0 0;
  font-size: 42px;
  line-height: 1.05;
}

.login-form {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

select, input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #cddae7;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 700;
}

select:focus,
input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(8, 112, 192, 0.16);
  outline: none;
}

button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  min-height: 44px;
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #b9dff5;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.action-button::before {
  display: inline-block;
  min-width: 13px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}
.action-button[data-icon="add"]::before { content: "+"; }
.action-button[data-icon="edit"]::before { content: "✎"; }
.action-button[data-icon="delete"]::before { content: "×"; }
.action-button[data-icon="save"]::before { content: "✓"; }
.action-button[data-icon="cancel"]::before { content: "×"; }
.action-button[data-icon="refresh"]::before { content: "↻"; }
.action-button[data-icon="previous"]::before { content: "←"; }
.action-button[data-icon="next"]::before { content: "→"; }
.action-button:hover:not(:disabled) {
  border-color: var(--blue);
  background: #dff1fc;
}
.primary-button.action-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}
.primary-button.action-button:hover:not(:disabled) {
  border-color: #075f9e;
  background: #075f9e;
}
.action-button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.action-button:disabled {
  border-color: #d9e3ec;
  background: #eef3f7;
  color: #91a2b2;
  cursor: not-allowed;
}
.action-button.icon-only {
  width: 34px;
  padding: 0;
  font-size: 0;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 32, 56, 0.46);
}
.confirm-dialog {
  width: min(460px, 100%);
  padding: 26px;
  border: 1px solid #c7d7e6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(8, 32, 56, 0.24);
}
.confirm-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 50%;
  background: #fff3df;
  color: #a96f09;
  font-size: 22px;
  font-weight: 900;
}
.confirm-dialog h2 {
  margin: 0;
  font-size: 24px;
}
.confirm-dialog > p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}
.action-button.icon-only::before {
  min-width: 0;
  font-size: 16px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-note {
  color: var(--muted);
  font-size: 13px;
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  font-weight: 650;
  margin: 0;
}

footer {
  padding-top: 10px;
  display: grid;
  justify-items: start;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
}

aside {
  background: linear-gradient(180deg, #082038 0%, #0d3151 55%, #113a5c 100%);
  color: #fff;
  padding: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
}

aside h1 { margin: 0; font-size: 24px; }
.module-menu {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.module-group-button,
.module-screen {
  width: 100%;
  text-align: left;
}
.module-group {
  display: grid;
  gap: 2px;
}
.module-group-button {
  min-height: 38px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(145, 189, 217, 0.2);
  color: #fff;
}
.module-group.open .module-group-button {
  background: var(--blue);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 20px rgba(8, 112, 192, 0.22);
}
.module-screens {
  display: none;
  gap: 3px;
  padding: 4px 0 8px;
}
.module-group.open .module-screens {
  display: grid;
}
.module-screen {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  background: rgba(234, 245, 253, 0.08);
  color: #cde5f4;
  font-size: 13px;
  font-weight: 750;
}
.module-screen.active {
  background: #ffffff;
  color: #082038;
  box-shadow: inset 4px 0 0 var(--sky);
}
.nav-loading { color: #bdd2e4; font-size: 13px; }
.nav-logout {
  width: 100%;
  height: 44px;
  min-height: 44px;
  border: 1px solid rgba(145, 189, 217, 0.34);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 850;
}
.nav-logout::before {
  content: "⏻";
  display: inline-block;
  font-size: 18px;
  line-height: 1;
}
.nav-logout:hover,
.nav-logout:focus-visible {
  background: #ffffff;
  color: var(--blue);
  outline: none;
}

.content {
  padding: 24px 24px 54px;
  min-width: 0;
  min-height: 100vh;
}
.dashboard-copyright {
  position: fixed;
  left: 280px;
  right: 0;
  bottom: 12px;
  z-index: 4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  pointer-events: none;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0;
  background: var(--bg);
}
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.readonly-badge {
  padding: 7px 10px;
  border: 1px solid #b9dff5;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--blue);
}
h2 { margin: 0; font-size: 26px; }
.user-title {
  display: inline-grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
  min-height: 38px;
  max-width: 320px;
  min-width: 210px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.user-title::before {
  content: "U";
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
}
.user-title strong,
.user-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
article, .panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
article { padding: 14px; display: grid; gap: 6px; }
article span { color: var(--muted); font-size: 13px; }
article strong { font-size: 18px; overflow-wrap: anywhere; }
.panel { padding: 16px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; }
.screen-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.screen-heading h3 {
  margin: 0;
  font-size: 24px;
}
#screen-source {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.record-count,
.records-caption {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.required-mark {
  color: var(--red);
  font-weight: 900;
}
.screen-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(2, minmax(78px, 92px));
  gap: 8px;
}
.screen-actions input,
.screen-actions button {
  width: 100%;
  min-width: 0;
}
.screen-actions button {
  white-space: nowrap;
}
.screen-actions button:not(:disabled) {
  border-color: #b9dff5;
  background: var(--blue-soft);
  color: var(--blue);
}
.screen-actions button:disabled {
  border-color: #d9e3ec;
  background: #eef3f7;
  color: #91a2b2;
  cursor: not-allowed;
}
.prototype-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.record-form {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.record-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 13px;
  min-width: 0;
}
.record-fields > .field {
  min-width: 0;
}
.record-fields input,
.record-fields select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.record-fields .field span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.record-fields small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.editor-actions button:not(.primary-button) {
  padding: 0 14px;
  border: 1px solid #c7d7e6;
  background: #fff;
  color: var(--ink);
}
.editor-actions .action-button:not(.primary-button) {
  padding: 0 10px;
  border-color: #c7d7e6;
}
.column-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.column-metadata span {
  padding: 5px 8px;
  border: 1px solid #c7d7e6;
  background: #f4f8fb;
  color: var(--muted);
  font-size: 11px;
}
.column-metadata strong {
  color: var(--ink);
}
.empty-state {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 44px 20px;
  border: 1px dashed #c7d7e6;
  background: #f8fbfd;
  color: var(--muted);
  text-align: center;
}
.empty-state strong {
  color: var(--ink);
  font-size: 16px;
}
.row-edit {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid #b9dff5;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
}
.row-edit:disabled {
  border-color: #d9e3ec;
  background: #eef3f7;
  color: #91a2b2;
  cursor: not-allowed;
}
.row-edit.action-button.icon-only {
  min-height: 34px;
  padding: 0;
  font-size: 0;
}
.selected-row td {
  background: #e7f5f5;
}
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list span {
  border: 1px solid #c7d7e6;
  background: #edf4f9;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
}
.module-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.module-list button {
  min-height: 70px;
  padding: 12px;
  border: 1px solid #c7d7e6;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.module-list button.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(8, 112, 192, 0.12);
}
.module-list strong,
.module-list span {
  display: block;
}
.module-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
th, td {
  border-bottom: 1px solid #e1e8f0;
  text-align: left;
  padding: 8px;
}
th { background: #edf4f9; }
.table-link {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  text-align: left;
}
.preview-table {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
}
.preview-table table {
  min-width: 680px;
}
.preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.preview-table .select-column {
  width: 88px;
  min-width: 88px;
}
.preview-table td {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-table tbody tr {
  cursor: pointer;
}
.preview-table tbody tr:hover td {
  background: #f1f8fc;
}
.preview-table tbody tr.selected-row:hover td {
  background: #e7f5f5;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.pagination button {
  padding: 0 12px;
  border: 1px solid #b9dff5;
  background: var(--blue-soft);
  color: var(--blue);
}
.pagination button:disabled {
  border-color: #d9e3ec;
  background: #eef3f7;
  color: #91a2b2;
  cursor: not-allowed;
}
.pagination label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pagination select {
  min-height: 30px;
  padding: 0 8px;
  font-size: 13px;
}

.coa-workspace {
  overflow: hidden;
}
.coa-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
  margin: 14px 0;
}
.coa-toolbar button,
.coa-selection-actions button {
  padding: 0 10px;
}
.coa-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 14px;
  min-width: 0;
}
.coa-tree-panel,
.coa-entry-panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: #fbfdff;
}
.coa-tree-panel {
  max-height: 650px;
  overflow: auto;
}
.coa-tree-caption {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.coa-tree-caption strong {
  color: var(--ink);
  font-size: 14px;
}
.coa-tree,
.coa-tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.coa-tree > ul {
  padding: 8px;
}
.coa-tree ul ul {
  margin-left: 18px;
  border-left: 1px solid #d8e4ee;
}
.coa-node-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: stretch;
  gap: 2px;
  margin: 2px 0;
}
.coa-node-row.selected {
  outline: 2px solid rgba(8, 112, 192, 0.28);
  outline-offset: -2px;
}
.coa-node-toggle {
  min-height: 42px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}
.coa-node-toggle:disabled {
  color: #b4c2ce;
  cursor: default;
}
.coa-node-select {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
  min-height: 42px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.coa-node-select:hover,
.coa-node-row.selected .coa-node-select {
  border-color: #b9dff5;
  background: var(--blue-soft);
}
.coa-node-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}
.coa-node-code {
  grid-column: 1;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coa-level-badge {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.coa-entry-panel {
  padding: 18px;
}
.coa-entry-empty {
  display: grid;
  min-height: 220px;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}
.coa-entry-empty strong {
  color: var(--ink);
  font-size: 18px;
}
.coa-breadcrumb {
  margin: 6px 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.coa-selection-heading,
.coa-form-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.coa-selection-heading h3,
.coa-form-heading h3 {
  margin: 0;
  font-size: 22px;
}
.coa-selection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.coa-selection-actions button:disabled {
  border-color: #d9e3ec;
  background: #eef3f7;
  color: #91a2b2;
  cursor: not-allowed;
}
.coa-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 0;
}
.coa-details div {
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.coa-details dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.coa-details dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}
.coa-context-grid,
.coa-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.coa-context-grid {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f5f9fc;
}
.coa-context-grid input {
  background: #edf4f9;
  color: var(--muted);
}
.coa-form-grid {
  margin-top: 2px;
}

@media (max-width: 760px) {
  .dashboard { grid-template-columns: 1fr; }
  aside { position: static; }
  .dashboard-copyright { left: 0; }
  .status-grid { grid-template-columns: 1fr; }
  .screen-heading { display: grid; }
  .screen-actions { grid-template-columns: 1fr; }
  label { grid-template-columns: 1fr; gap: 4px; }
  .pagination { justify-content: space-between; flex-wrap: wrap; }
  .coa-toolbar,
  .coa-layout,
  .coa-context-grid,
  .coa-form-grid,
  .coa-details { grid-template-columns: 1fr; }
  .coa-selection-heading,
  .coa-form-heading { display: grid; }
  .coa-selection-actions { justify-content: flex-start; }
}
