:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111d30;
  --text: #e8eef7;
  --muted: #8fa1b8;
  --line: #263750;
  --accent: #2588da;
  --accent-dark: #70c2ff;
  --accent-light: #1c2b42;
  --accent-line: #263750;
  --header-bg: #101a2b;
  --danger: #a93646;
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; min-height: 100%; margin: 0; overflow-x: hidden; }
body { min-height: 100vh; background: var(--bg); color: var(--text); }

#appHeader {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-height: 72px;
  padding: 0 max(4vw, 24px);
  border-bottom: 1px solid #223047;
  background: var(--header-bg);
}
#appHeader.hidden { display: none !important; }
.brand { color: #fff; font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.mobile-menu-wrap { position: relative; display: flex; align-items: center; }
#mainNav { display: flex; align-items: center; gap: 8px; }
#mainNav.hidden { display: none !important; }
#mainNav button {
  min-height: 40px;
  padding: 9px 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9fb0c7;
  font-weight: 500;
}
#mainNav button:hover, #mainNav button.active { background: #1c2b42; color: #fff; }
#mainNav button.nav-logout { margin-left: .4rem; color: #f2aab4; }
#mainNav button.nav-logout:hover { background: #44232d; color: #fff; }
.mobile-menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 9px;
  background: #1c2b42;
  color: #d7e5f7;
}
.mobile-menu-btn:before {
  display: block;
  width: 20px;
  height: 14px;
  margin: auto;
  background: linear-gradient(#d7e5f7,#d7e5f7) 0 0/100% 2px no-repeat,
              linear-gradient(#d7e5f7,#d7e5f7) 0 6px/100% 2px no-repeat,
              linear-gradient(#d7e5f7,#d7e5f7) 0 12px/100% 2px no-repeat;
  content: "";
}
.mobile-menu-btn:hover, .mobile-menu-btn.open { background: #273950; }

#appMain { width: 100%; max-width: none; min-height: calc(100vh - 72px); margin: 0; padding: 0; }
.login-wrap { display: grid; place-items: center; width: 100%; min-height: 100vh; padding: 32px 20px; }
.login-card {
  width: min(100%, 430px);
  padding: 42px;
  border: 1px solid #293b54;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 28px 80px #0007;
}
.login-card h1 { margin: 0; font-size: clamp(2rem, 9vw, 2.5rem); }
.eyebrow { margin: 8px 0 28px; color: #65b8ff; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.login-card form { display: grid; gap: 15px; }
.login-card label { display: grid; gap: 7px; color: #aab9cc; font-size: .9rem; }
.login-card input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #344761;
  border-radius: 9px;
  outline: none;
  background: #0b1423;
  color: var(--text);
  font: inherit;
}
.login-card input:focus { border-color: #62b7fb; box-shadow: 0 0 0 3px #62b7fb20; }
.code-input { padding-left: calc(13px + .35em) !important; text-align: center; font-size: 1.35rem !important; font-weight: 800 !important; letter-spacing: .35em; }
.login-card button, .ia-button { min-height: 44px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font: inherit; font-weight: 750; cursor: pointer; }
.login-card button:hover, .ia-button:hover { background: #3b9bea; }
.login-card button:disabled { opacity: .5; cursor: not-allowed; }
.login-error { padding: 13px 16px; border-radius: 9px; background: #632b35; color: #ffd7dc; }
.center { margin-top: 22px; color: var(--muted); font-size: .78rem; text-align: center; }

.shell { width: min(1180px, 92%); margin: 44px auto 80px; padding: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.page-head h1 { overflow: hidden; margin: 5px 0; font-size: clamp(2rem, 5vw, 3.25rem); text-overflow: ellipsis; }
.page-head p { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.55; }
.panel, .stat-card { border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.panel { margin: 20px 0; padding: 24px; }
.panel h2 { margin: 0 0 18px; font-size: 1.05rem; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; margin: 20px 0; }
.stat-card { min-width: 0; padding: 17px 18px; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { margin-top: 9px; font-size: 1.8rem; font-weight: 800; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
.data-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table th { background: #0e1828; color: #9fb0c7; font-size: .78rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #ffffff06; }
.empty { padding: 38px 16px; color: #778ba4; text-align: center; }
.inline-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1.3fr) auto; align-items: end; gap: 10px; margin: 0 0 18px; }
.inline-form label { display: grid; gap: 7px; color: #aab9cc; font-size: .88rem; }
.inline-form input { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid #344761; border-radius: 9px; background: #0b1423; color: var(--text); font: inherit; }
.inline-form input:focus { outline: 2px solid #62b7fb44; border-color: #62b7fb; }
.inline-form button { min-height: 42px; padding: 10px 15px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font: inherit; font-weight: 750; cursor: pointer; }
.inline-form button:hover { background: #3b9bea; }
.status-pill { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border: 1px solid #344761; border-radius: 999px; color: #9fb0c7; font-size: .78rem; font-weight: 700; }
.status-pill.good { border-color: #24644d; background: #173d33; color: #80dfb5; }
.status-pill.bad { border-color: #693643; background: #44232d; color: #f3a6b2; }
.muted { color: var(--muted); }
.alert-inline { margin: 0 0 14px; color: #ffb3bd; }

@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  #appHeader { position: relative; min-height: 72px; padding: 14px 4%; }
  .mobile-menu-wrap { margin-left: auto; }
  .mobile-menu-btn { display: block; }
  .mobile-menu-btn.hidden { display: none !important; }
  #mainNav {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    display: grid;
    width: min(250px, calc(100vw - 32px));
    gap: 4px;
    padding: 8px;
    overflow: visible;
    border: 1px solid #263750;
    border-radius: 12px;
    background: #101a2b;
    box-shadow: 0 22px 55px #0008;
  }
  #mainNav.hidden { display: none !important; }
  #mainNav button, #mainNav button:hover, #mainNav button.active,
  #mainNav button:focus, #mainNav button:focus-visible {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 42px;
    margin: 0;
    padding: 11px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #9fb0c7;
    text-align: left;
    line-height: 1.2;
    font-weight: 400;
    box-shadow: none;
    outline: 0;
    transform: none;
  }
  #mainNav button:hover, #mainNav button.active { background: #1c2b42; color: #fff; }
  #mainNav button.nav-logout { margin: 4px 0 0; color: #f2aab4; }
  #appMain { min-height: calc(100vh - 72px); }
  .shell { width: 100%; margin: 28px auto 56px; padding: 0 16px; }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: clamp(1.8rem, 8vw, 2.4rem); }
  .panel { padding: 18px; }
  .inline-form { grid-template-columns: 1fr; align-items: stretch; }
  .inline-form button { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.55rem; }
}

/* GIA Secrets nav typography: normal weight, shared inherited size, active-only highlight. */
#mainNav button, #mainNav button:focus, #mainNav button:focus-visible {
  font-size: inherit !important;
  font-weight: 400 !important;
  box-shadow: none !important;
  outline: 0 !important;
  transform: none !important;
}
@media (max-width: 700px) {
  #mainNav button, #mainNav button:focus, #mainNav button:focus-visible {
    background: transparent !important;
    color: #9fb0c7 !important;
  }
  #mainNav button:hover, #mainNav button.active {
    background: #1c2b42 !important;
    color: #fff !important;
  }
}

.grid-toolbar { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.grid-search { flex:1; min-width:0; min-height:42px; padding:10px 12px; border:1px solid #344761; border-radius:9px; background:#0b1423; color:var(--text); font:inherit; }
.grid-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; color:var(--muted); font-size:.86rem; }
.grid-pagination { display:flex; align-items:center; gap:8px; }
.grid-pagination button { min-height:36px; padding:7px 11px; border:1px solid var(--line); border-radius:8px; background:#1c2b42; color:#d7e5f7; }
.data-table tbody tr[data-grid-row] { cursor:pointer; }
.record-dialog { width:min(680px,calc(100vw - 28px)); max-height:85vh; padding:0; border:1px solid #344761; border-radius:16px; background:#111d30; color:var(--text); box-shadow:0 28px 80px #0009; }
.record-dialog::backdrop { background:#030813bb; }
.record-dialog-card { padding:24px; }
.record-dialog-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:18px; }
.record-dialog-head h2 { margin:0; }
.record-fields { display:grid; grid-template-columns:minmax(130px,.7fr) minmax(0,1.3fr); gap:10px 16px; }
.record-fields dt { color:var(--muted); }
.record-fields dd { min-width:0; margin:0; overflow-wrap:anywhere; }
.record-fields dd.multiline-value { white-space: pre-line; }
.record-edit-form { display:grid; gap:14px; }
.record-edit-form label { display:grid; gap:7px; color:#aab9cc; }
.record-edit-form input:not([type="checkbox"]) { width:100%; min-height:42px; padding:9px 12px; border:1px solid #344761; border-radius:9px; background:#0b1423; color:var(--text); font:inherit; }
.record-edit-form input:not([type="checkbox"]):focus, .record-edit-form textarea:focus, .record-edit-form select:focus { outline:2px solid #62b7fb44; border-color:#62b7fb; }
.record-edit-form select { min-height:42px; padding:9px 12px; border:1px solid #344761; border-radius:9px; background:#0b1423; color:var(--text); font:inherit; }
.record-edit-form textarea { width:100%; padding:10px 12px; border:1px solid #344761; border-radius:9px; background:#0b1423; color:var(--text); font:inherit; resize:vertical; }
.record-edit-actions { display:flex; justify-content:flex-end; gap:9px; }
.server-dialog-layout { display:flex; flex-direction:column; height:calc(85vh - 48px); max-height:calc(85vh - 48px); min-height:0; }
.server-dialog-layout > .record-dialog-head { flex:0 0 auto; }
.server-dialog-scroll { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:0 4px 12px 0; }
.server-edit-dock { flex:0 0 auto; grid-template-columns:1fr 1fr; gap:10px 16px; margin-top:10px; padding-top:14px; border-top:1px solid var(--line); }
.server-edit-dock > label:nth-of-type(3), .server-edit-dock .record-edit-actions { grid-column:1 / -1; }
@media (max-width:700px) { .grid-toolbar,.grid-footer { align-items:stretch; flex-direction:column; } .grid-pagination { justify-content:space-between; } .record-dialog-card { padding:20px; } }
@media (max-width: 380px) {
  .brand { font-size: 1.1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 30px 22px; }
}

/* IAExtractor renders in the shared GIA stylesheet, so explicitly retain its dark grid theme. */
#appMain .table-wrap table.data-table {
  display: table;
  background: var(--panel);
  color: var(--text);
  border: 0;
}
#appMain .table-wrap table.data-table thead { display: table-header-group; }
#appMain .table-wrap table.data-table tbody { display: table-row-group; }
#appMain .table-wrap table.data-table tbody tr[data-grid-row] {
  display: table-row;
  margin: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
}
#appMain .table-wrap table.data-table tbody tr[hidden] { display: none !important; }
#appMain .table-wrap table.data-table td { display: table-cell; border-bottom: 1px solid var(--line); }
#appMain .table-wrap table.data-table td::before { display: none; }
#appMain .table-wrap table.data-table tbody tr[data-grid-row]:hover { background: #ffffff08; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.switch .track {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 26px;
  border: 1px solid #52647b;
  border-radius: 999px;
  background: #26364b;
  transition: background .16s ease, border-color .16s ease;
}
.switch .track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #d7e2ef;
  content: "";
  transition: transform .16s ease, background .16s ease;
}
.switch input:checked + .track { border-color: #208c68; background: #147552; }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .track { outline: 3px solid #62b7fb66; outline-offset: 2px; }
.record-edit-form label.switch { display: inline-flex; min-height: 34px; }
.grid-toolbar .filter-switch { flex: 0 0 auto; min-height: 42px; padding: 0 8px; color: var(--muted); font-size: .9rem; }
.record-edit-form { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }

@media (max-width: 700px) {
  #appMain .table-wrap { overflow-x: auto; }
  #appMain .table-wrap table.data-table { min-width: 620px; }
}
