:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #2B333C;
  background: #EEF1F4;
  line-height: 1.45;
  font-synthesis: none;
  --brand-900: #0F3E63;
  --brand-700: #15507F;
  --brand-600: #1F6FB2;
  --brand-100: #DCE9F5;
  --brand-050: #EEF4FA;
  --brand-line: #BBD3E8;
  --text: #2B333C;
  --text-2: #5A6673;
  --muted: #8A929B;
  --line: #D6DCE2;
  --line-soft: #EFF1F4;
  --field-line: #C9D0D8;
  --surface: #FFFFFF;
  --bg: #EEF1F4;
  --thead-bg: #EDF1F5;
  --thead-text: #3A444E;
  --ok: #1E6B41;
  --ok-soft: #E4F2E9;
  --ok-line: #A9D3B9;
  --warn: #8A6D1F;
  --warn-soft: #FDF6E7;
  --warn-line: #EAD9A8;
  --danger: #B3261E;
  --danger-soft: #FBE9E9;
  --danger-line: #E4A9A5;
  --focus: rgba(21, 80, 127, .22);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { border: 0; }

button, .button {
  min-height: 40px;
  border-radius: 8px;
  background: var(--brand-700);
  color: #fff;
  padding: 9px 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
button:hover { background: var(--brand-900); }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.secondary { color: var(--brand-700); background: var(--brand-050); border: 1px solid var(--brand-line); }
.secondary:hover { color: var(--brand-900); background: var(--brand-100); }
.danger { color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line); }
.danger:hover { color: #8E1E18; background: #F7DADA; }
.text-button { width: 100%; color: var(--brand-700); background: transparent; margin-top: 4px; }
.text-button:hover { color: var(--brand-900); background: var(--brand-050); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: min(520px, 100%);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(21, 80, 127, .10);
}
.auth-card-head { display: flex; align-items: center; gap: 14px; padding: 26px 34px; color: #fff; background: var(--brand-700); }
.auth-card-head strong { display: block; font-size: 21px; }
.auth-card-head span { display: block; margin-top: 2px; color: #DCE9F5; font-size: 13px; }
.auth-card-body { padding: 30px 34px 34px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: block;
  flex: 0 0 auto;
}
.brand-mark.small { width: 38px; height: 38px; }
.brand { display: inline-block; margin-left: 10px; color: var(--brand-700); font-weight: 800; letter-spacing: .01em; }
.auth-card h1 { margin: 0 0 5px; font-size: 30px; }
.auth-card-body > p { margin: 0 0 22px; color: var(--text-2); }

label { display: grid; gap: 6px; margin: 14px 0; color: var(--text); font-size: 14px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 92px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--brand-700); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: 9px; min-height: 42px; margin: 14px 0; }
.checkbox-row input { width: 18px; min-height: 18px; }
.checkbox-row label { display: inline; margin: 0; }
.field-help { margin: -7px 0 12px; color: var(--muted); font-size: 12px; }

#dashboard { min-height: 100vh; }
.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 28px;
  background: var(--brand-700);
  color: #fff;
}
.topbar-brand, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar strong { display: block; font-size: 18px; }
#identity { display: block; margin-top: 1px; color: #DCE9F5; font-size: 13px; }
.header-button { min-height: 36px; padding: 7px 12px; color: #eef7f4; background: transparent; border: 1px solid rgba(255,255,255,.24); }
.header-button:hover { color: #fff; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.4); }

#navigation {
  display: flex;
  gap: 6px;
  padding: 14px 28px;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.nav-tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 9px 15px;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  white-space: nowrap;
}
.nav-tab:hover { color: var(--brand-700); background: var(--brand-050); border-color: var(--brand-line); }
.nav-tab.active, .nav-tab.active:hover { color: var(--brand-700); background: var(--brand-100); border-color: var(--brand-line); }

.workspace { width: min(1480px, 100%); margin: 0 auto; padding: 28px; }
.workspace-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.workspace-head h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.workspace-head p { margin: 4px 0 0; color: var(--text-2); }
.workspace-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.filters label { margin: 0; }
.filters button { min-height: 42px; }
.filter-actions { display: flex; align-items: center; gap: 6px; }
.filter-actions .compact { width: auto; min-height: 42px; margin: 0; padding: 8px 10px; }

.message { min-height: 20px; margin: 9px 0; color: var(--danger); font-size: 14px; }
.message:empty { margin: 0; min-height: 0; }
.message.ok { color: var(--ok); }
.message.error { color: var(--danger); }

.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 12px 13px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
th { position: sticky; top: 0; z-index: 1; color: var(--thead-text); background: var(--thead-bg); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
td { max-width: 320px; color: var(--text); font-size: 14px; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .14s ease; }
tbody tr:hover { background: var(--brand-050); }
td.actions { width: 1%; max-width: none; white-space: nowrap; }
td.actions button { min-height: 34px; margin: 2px 4px 2px 0; padding: 6px 10px; font-size: 12px; }
.cell-main { color: var(--text); font-weight: 650; }
.cell-sub { margin-top: 2px; color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--text-2); background: #F0F2F5; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.yes, .badge.success { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.badge.no, .badge.danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.badge.info { color: var(--brand-700); background: var(--brand-100); border-color: var(--brand-line); }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.badge.neutral { color: var(--muted); background: #F0F2F5; border-color: var(--line); }
.empty { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 5px; color: var(--text); font-size: 16px; }
.loading-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--brand-600); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }

dialog { width: min(680px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 14px; color: var(--text); box-shadow: 0 28px 90px rgba(21, 32, 43, .28); }
dialog:has(.detail-view) { width: min(1080px, calc(100% - 28px)); }
dialog::backdrop { background: rgba(21, 32, 43, .50); }
.modal-card { margin: 0; padding: 24px; overflow-y: auto; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.modal-head h2 { margin: 0; font-size: 23px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.icon-button { width: 36px; min-height: 36px; padding: 0; border-radius: 50%; color: var(--text-2); background: var(--brand-050); font-size: 24px; line-height: 1; }
.icon-button:hover { color: var(--brand-900); background: var(--brand-100); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.config-section { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.config-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.config-section h3 { margin: 0 0 10px; font-size: 16px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 8px; }
.inline-form label { margin: 0; }
.item-list { display: grid; gap: 7px; margin-top: 10px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; }
.list-item button { min-height: 32px; padding: 5px 9px; }

.detail-view { display: grid; gap: 20px; }
.detail-section { min-width: 0; }
.detail-section h3 { margin: 0 0 10px; font-size: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.detail-grid > div { min-width: 0; padding: 10px 12px; background: #fff; }
.detail-grid dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.detail-grid dd { margin: 3px 0 0; overflow-wrap: anywhere; color: var(--text); }
.detail-table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.detail-table { min-width: 680px; }
.detail-table th { position: static; }
.detail-table th, .detail-table td { padding: 9px 10px; }
.attachment-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.message-body, .json-details pre { max-height: 360px; margin: 0; overflow: auto; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: #F7F9FB; color: var(--text); font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.json-details { border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.json-details summary { padding: 11px 13px; cursor: pointer; color: var(--brand-700); font-weight: 700; }
.json-details[open] summary { border-bottom: 1px solid var(--line); }
.json-details pre { max-height: 460px; border: 0; border-radius: 0 0 9px 9px; }

@media (max-width: 900px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters button { width: 100%; }
}

@media (max-width: 700px) {
  .auth-card-head { padding: 22px 24px; }
  .auth-card-body { padding: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .topbar-actions { gap: 6px; }
  .header-button { width: auto; padding: 7px 9px; font-size: 12px; }
  #navigation { padding: 10px 16px; }
  .nav-tab { min-height: 38px; padding: 7px 11px; }
  .workspace { padding: 20px 16px; }
  .workspace-head { align-items: flex-start; flex-direction: column; }
  .workspace-actions, .workspace-actions button { width: 100%; }
  .filters { grid-template-columns: 1fr; }
  .filter-actions { width: 100%; }
  .filter-actions button { flex: 1; }
  dialog { width: calc(100% - 16px); max-height: calc(100vh - 16px); }
  .modal-card { padding: 19px; }
  .inline-form { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
