/* DA brand: Dependable Blue #001993 primary; DA Blue #0277B7 and Highlight Red
   #BE1E2D for text highlighting only; white; no gradients. */
:root {
  --dependable: #001993;
  --dablue: #0277B7;
  --red: #BE1E2D;
  --white: #FFFFFF;
  --ink: #111111;
  --line: #D5D8E2;
  --muted: #5B6070;
  --surface: #F6F7FB;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  font-family: 'Roboto Condensed', Arial, sans-serif;
  background: var(--white);
  color: var(--ink);
}
h1, h2, h3 {
  font-family: 'Bebas Neue', 'Bebas Neue Pro', Impact, sans-serif;
  text-transform: uppercase;
  letter-spacing: .5px;
}
button, input, select, textarea { font: inherit; }
button, input, select, textarea, [tabindex="0"] { scroll-margin: 1rem; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid var(--dablue);
  outline-offset: 2px;
}

header {
  min-height: 64px;
  background: var(--dependable);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
}
header h1 { margin: 0; font-size: 28px; flex: 1 1 auto; }
.logo-slot { flex: 0 0 auto; min-width: 40px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 2px solid var(--white); color: var(--white); font-family: 'Bebas Neue', Impact, sans-serif; font-size: 24px; line-height: 1; }
.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 14px;
  text-align: right;
}
#clock { font-size: 14px; opacity: .92; }
.connection-status { min-width: 66px; font-size: 13px; font-weight: 700; }
.connection-status:not(:empty)::before { content: '\25CF'; margin-right: 5px; }
.connection-status[data-kind="success"]::before { color: #71E096; }
.connection-status[data-kind="pending"]::before { color: #FFD166; }
.connection-status[data-kind="error"]::before { color: #FF8792; }
.header-action {
  border: 1px solid var(--white);
  background: transparent;
  color: var(--white);
  padding: 6px 12px;
  font-family: 'Bebas Neue', Impact, sans-serif;
  text-transform: uppercase;
  cursor: pointer;
}
.zigzag {
  height: 12px;
  background: var(--dependable);
  clip-path: polygon(0 0,4% 100%,8% 0,12% 100%,16% 0,20% 100%,24% 0,28% 100%,32% 0,36% 100%,40% 0,44% 100%,48% 0,52% 100%,56% 0,60% 100%,64% 0,68% 100%,72% 0,76% 100%,80% 0,84% 100%,88% 0,92% 100%,96% 0,100% 100%,100% 0);
}

.auth-panel { width: min(520px, 100%); margin: 28px auto; }
.auth-panel form > label { display: block; margin-bottom: 6px; font-weight: 700; }
.auth-panel #token { flex: 1 1 260px; }

nav#tabs {
  display: flex;
  gap: 4px;
  max-width: 100%;
  overflow-x: auto;
  padding: 12px 20px 0;
  scrollbar-width: thin;
}
nav#tabs button {
  flex: 0 0 auto;
  font-family: 'Bebas Neue', Impact, sans-serif;
  text-transform: uppercase;
  font-size: 16px;
  background: var(--white);
  border: 2px solid var(--dependable);
  color: var(--dependable);
  padding: 7px 14px;
  cursor: pointer;
}
nav#tabs button.active { background: var(--dependable); color: var(--white); }
.tab, .panel { min-width: 0; padding: 16px 20px; }
.app-status { margin: 8px 20px 0; }
.status-message, .inline-status { min-height: 1.2em; }
.status-message:empty, .inline-status:empty { display: none; }
.status-message[data-kind="error"], .inline-status[data-kind="error"] { color: var(--red); font-weight: 700; }
.status-message[data-kind="success"], .inline-status[data-kind="success"] { color: var(--dablue); font-weight: 700; }
.status-message[data-kind="pending"], .inline-status[data-kind="pending"] { color: var(--muted); font-weight: 700; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card { border: 2px solid var(--dependable); padding: 12px 18px; min-width: 0; }
.card .num { font-family: 'Bebas Neue', Impact, sans-serif; font-size: clamp(30px, 5vw, 40px); color: var(--dependable); overflow-wrap: anywhere; }
.card .label { font-size: 13px; text-transform: uppercase; }
.toolbar, .form-row, .inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.toolbar { margin: 10px 0 18px; }
.form-block { margin: 12px 0; padding: 12px; background: var(--surface); }
.form-row > label:not(.checkbox-label) { font-weight: 700; }
.inline-form { min-width: 230px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 7px; }
.checkbox-label input { margin: 0; }

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 14px; }
table.table-wide { min-width: 980px; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-family: 'Bebas Neue', Impact, sans-serif;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  background: var(--dependable);
  color: var(--white);
  padding: 7px 8px;
}
td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
tbody tr:nth-child(even) { background: var(--surface); }
tbody tr:hover { background: #EEF3FF; }

input, select, textarea {
  min-height: 34px;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid #8D93A3;
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
}
input[type="file"] { max-width: min(100%, 360px); }
button.action {
  min-height: 34px;
  background: var(--dependable);
  color: var(--white);
  border: 2px solid var(--dependable);
  padding: 6px 13px;
  font-family: 'Bebas Neue', Impact, sans-serif;
  text-transform: uppercase;
  font-size: 15px;
  white-space: nowrap;
  cursor: pointer;
}
button.action.secondary { background: var(--white); color: var(--dependable); }
button:disabled { cursor: wait; opacity: .58; }
.setting-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 360px) auto minmax(70px, auto);
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.setting-row > label { font-weight: 700; }
.setting-row .checkbox-label { grid-column: 1 / 3; }

.hl-blue { color: var(--dablue); font-weight: 700; }
.hl-red { color: var(--red); font-weight: 700; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border: 1px solid currentColor; white-space: nowrap; }
.feed { padding-left: 22px; }
.feed li { margin-bottom: 7px; overflow-wrap: anywhere; }
.section-title { margin-top: 24px; border-bottom: 3px solid var(--dependable); padding-bottom: 4px; }
.mono { font-family: Consolas, 'Courier New', monospace; font-size: 12px; overflow-wrap: anywhere; }
.chart-legend-row { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.chart-legend { font-weight: 700; }
.series-text-0 { color: var(--dependable); }
.series-text-1 { color: var(--dablue); }
.series-text-2 { color: var(--red); }
.chart-line.series-0 { stroke: var(--dependable); }
.chart-line.series-1 { stroke: var(--dablue); }
.chart-line.series-2 { stroke: var(--red); }
.chart-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.trend-chart { display: block; width: 100%; max-width: 900px; min-width: 540px; }
.vd-toolbar > label { font-weight: 700; }
.muted-note { color: var(--muted); font-size: 13px; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 170px;
}
button.action.compact { min-height: 30px; padding: 4px 9px; font-size: 13px; }
.copy-figure {
  min-width: 72px;
  min-height: 44px;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--dablue);
  background: var(--white);
  color: var(--dependable);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.copy-figure:hover { background: #EEF3FF; }
.copy-figure-number { font-size: 1.15em; }
.copy-figure-hint {
  color: var(--dablue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.copy-figure[data-copy-state="copied"] { background: #E8F8EE; border-color: #168447; }
.copy-figure[data-copy-state="copied"] .copy-figure-hint { color: #126B3B; }

.dashboard-dialog {
  width: min(920px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 3px solid var(--dependable);
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 18px 60px rgba(0, 25, 147, .28);
}
.dashboard-dialog::backdrop { background: rgba(4, 10, 35, .62); }
#message-agent-dialog { width: min(640px, calc(100% - 24px)); }
.dialog-shell {
  max-height: calc(100dvh - 30px);
  margin: 0;
  padding: 20px;
  overflow: auto;
}
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  border-bottom: 3px solid var(--dependable);
}
.dialog-heading h2 { margin: 0; color: var(--dependable); }
.dialog-context { margin: 3px 0 12px; color: var(--muted); overflow-wrap: anywhere; }
.dialog-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 2px solid var(--dependable);
  background: var(--white);
  color: var(--dependable);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.dialog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.dialog-toolbar label, .dialog-shell > label { font-weight: 700; }
.dialog-results { min-height: 90px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
#message-agent-body { width: 100%; resize: vertical; }
.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.empty-state {
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  color: var(--muted);
}
.empty-state p { margin-bottom: 0; }
.submissions-table { min-width: 760px; }
.submission-count { color: var(--dependable); font-size: 18px; font-weight: 700; }
.submission-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.flag-review { color: var(--red); }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 760px) {
  header { align-items: flex-start; flex-wrap: wrap; padding: 10px 12px; }
  header h1 { font-size: 25px; }
  .header-meta { flex: 1 1 100%; justify-content: space-between; text-align: left; }
  nav#tabs { padding: 10px 12px 0; }
  .tab, .panel { padding: 14px 12px; }
  .app-status { margin-inline: 12px; }
  .setting-row { grid-template-columns: minmax(0, 1fr) auto; }
  .setting-row > label, .setting-row > input { grid-column: 1 / -1; }
  .setting-row .checkbox-label { grid-column: 1 / -1; }
  .setting-row .inline-status { grid-column: 1 / -1; }
  .trend-chart { min-width: 500px; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .card { padding: 10px 12px; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .form-row { align-items: stretch; }
  .form-row > input:not([type="checkbox"]):not([type="file"]), .form-row > button { flex: 1 1 100%; width: 100%; }
  .inline-form input { flex: 1 1 130px; }
  nav#tabs button { padding-inline: 11px; }
  .dashboard-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); }
  .dialog-shell { max-height: calc(100dvh - 18px); padding: 14px; }
  .dialog-heading { gap: 8px; }
  .dialog-toolbar { align-items: stretch; }
  .dialog-toolbar input, .dialog-toolbar .action { width: 100%; }
  .dialog-actions { align-items: stretch; }
  .dialog-actions .action { flex: 1 1 50%; }
  .message-meta { flex-direction: column; gap: 2px; }
  .vd-toolbar input { width: 100%; }
  .row-actions { min-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}