@font-face {
  font-family: "IA Consolas";
  src: url("../fonts/Consolas.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "IA Consolas";
  src: url("../fonts/Consolas-Bold.ttf") format("truetype");
  font-weight: 700;
}

@font-face {
  font-family: "IA Segoe Icons";
  src: url("../fonts/SegoeIcons.ttf") format("truetype");
}

:root {
  --window: #f4f7fb;
  --panel: #ffffff;
  --text: #121c2d;
  --muted: #606e87;
  --icon: #1f65eb;
  --line: #c4cfe0;
  --focus: #e6f0ff;
  --active: #d5e8ff;
  --soft: #f8fafd;
  --command: #ebf2fc;
  --danger: #d32f2f;
  --good: #147d4f;
  --shadow: 0 12px 34px rgba(18, 28, 45, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--window);
  color: var(--text);
  font-family: "IA Consolas", Consolas, monospace;
  font-size: 14px;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.ia-icon {
  font-family: "IA Segoe Icons";
  line-height: 1;
  font-weight: 400;
}

.app-shell,
.main-layout {
  min-height: 100vh;
}

.main-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.side-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand-block,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--focus);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.brand-block strong,
.login-brand strong {
  display: block;
  font-size: 18px;
}

.brand-block span,
.login-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 1px;
  padding: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
}

.nav-item .ia-icon {
  width: 22px;
  color: inherit;
  font-size: 18px;
}

.nav-item:hover,
.nav-item:focus,
.nav-item.is-active {
  outline: 0;
  background: var(--focus);
  color: var(--icon);
}

.session-box {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.session-box span,
.session-box b {
  display: block;
}

.session-box b {
  color: var(--icon);
  margin-top: 3px;
}

.content-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top-bar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.top-title {
  font-size: 19px;
  font-weight: 700;
}

.top-subtitle,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.view-host {
  padding: 16px;
  min-width: 0;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel,
.redirect-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 14px;
  padding-bottom: 18px;
}

.login-panel label,
.edit-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.login-panel label {
  margin: 0 18px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
  outline: 0;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--icon);
  background: var(--focus);
}

.primary-button,
.ghost-button,
.icon-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  padding: 0 12px;
  text-decoration: none;
}

.primary-button {
  background: var(--icon);
  border-color: var(--icon);
  color: #fff;
  margin: 0 18px;
}

.edit-form .primary-button,
.command-row .primary-button,
.settings-panel .primary-button {
  margin: 0;
}

.ghost-button:hover,
.icon-button:hover,
.file-button:hover,
.primary-button:hover {
  opacity: .82;
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--icon);
}

.icon-button.is-danger {
  color: var(--danger);
}

.icon-button:disabled {
  opacity: .35;
  cursor: default;
}

.login-note,
.form-error {
  margin: 0 18px;
  color: var(--muted);
  font-size: 12px;
}

.form-error {
  color: var(--danger);
}

.command-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 10px;
  row-gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
}

.metric-card .ia-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--focus);
  color: var(--icon);
  font-size: 20px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  align-self: end;
}

.metric-card strong {
  font-size: 20px;
  font-weight: 400;
  line-height: 1.05;
  align-self: start;
}

.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  min-width: 0;
}

.panel-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: var(--active);
  border-bottom: 1px solid var(--line);
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-actions .icon-button {
  width: 36px;
  height: 34px;
  min-height: 34px;
  padding: 0 9px;
  background: var(--soft);
}

.panel-header span {
  color: var(--muted);
}

.search-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.search-line .ia-icon {
  color: var(--icon);
  width: 22px;
  text-align: center;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 400;
}

.data-table th:last-child {
  width: 1%;
  text-align: right;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tr:hover td {
  background: var(--focus);
}

.data-table small {
  display: block;
  color: var(--muted);
  max-width: 440px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-footer {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}

.table-link {
  border: 0;
  background: transparent;
  color: var(--icon);
  padding: 0;
  font-weight: 700;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  width: max-content;
  margin-left: auto;
}

.row-actions .icon-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.edit-form {
  padding: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .is-wide {
  grid-column: 1 / -1;
}

.check-row {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 38px;
  color: var(--text) !important;
}

.check-row input {
  width: auto;
  min-height: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--soft);
}

.status-pill.is-good {
  color: var(--good);
  background: #e9f8f1;
}

.status-pill.is-bad {
  color: var(--danger);
  background: #fff0f0;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 180px;
  color: var(--muted);
}

.empty-state .ia-icon {
  color: var(--icon);
  font-size: 28px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.settings-grid div {
  display: grid;
  gap: 5px;
  background: var(--panel);
  padding: 12px;
}

.settings-grid span {
  color: var(--muted);
  font-size: 12px;
}

.settings-panel .command-row,
.settings-panel .muted-text {
  margin: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 28, 45, .28);
}

.modal-panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 0 12px;
  background: var(--active);
  border-bottom: 1px solid var(--line);
}

.file-button input {
  display: none;
}

.redirect-box {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 28px;
  text-align: center;
}

.redirect-box .ia-icon {
  color: var(--icon);
  font-size: 34px;
}

.redirect-box span {
  color: var(--muted);
  word-break: break-word;
}

.raw-output {
  min-height: 100vh;
  background: #fff;
  color: #000;
  padding: 0;
}

.raw-output pre {
  margin: 0;
  padding: 22px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IA Consolas", Consolas, monospace;
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.42;
  tab-size: 2;
}

.raw-output.is-json pre {
  white-space: pre;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(460px, calc(100vw - 36px));
  background: var(--text);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.is-error {
  background: var(--danger);
}

code {
  color: var(--icon);
}

@media (max-width: 1000px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    padding: 6px;
  }

  .nav-item span {
    display: none;
  }

  .session-box {
    display: none;
  }

  .split-view,
  .metric-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .view-host {
    padding: 10px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }

  .top-bar {
    min-height: 60px;
  }
}
