:root {
  --navy: #102a43;
  --navy-2: #243b53;
  --ink: #1f2933;
  --muted: #627d98;
  --line: #d9e2ec;
  --bg: #f3f6f9;
  --card: #ffffff;
  --orange: #e87722;
  --orange-dark: #c55f12;
  --teal: #0f766e;
  --red: #b42318;
  --amber: #b54708;
  --blue: #175cd3;
  --green: #067647;
  --shadow: 0 12px 30px rgba(16, 42, 67, 0.08);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(232, 119, 34, 0.09), transparent 30rem),
    linear-gradient(180deg, #eef3f8 0%, var(--bg) 32rem);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14px;
}

h1, h2, h3, p { margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: linear-gradient(100deg, var(--navy), #173b5e 62%, #1e4d70);
  color: #fff;
  border-bottom: 4px solid var(--orange);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 58px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.16);
}

.brand h1 { font-size: 21px; letter-spacing: 0.01em; font-weight: 650; }
.brand p { color: #b9d3e8; font-size: 12px; margin-top: 3px; letter-spacing: 0.03em; }

.local-pill {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #dceaf5;
  border-radius: 999px;
  padding: 7px 12px;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 26px 28px 40px;
  align-items: start;
}

.left-column, .right-column { min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.left-column .card { margin-bottom: 16px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 12px 12px 0 0;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.tab:hover { color: var(--navy); background: #eef3f8; }
.tab.active { background: var(--navy); color: #fff; }

.tab-panel { padding: 16px; }

.dropzone {
  border: 1.5px dashed #9fb3c8;
  background: #f8fafc;
  border-radius: 10px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragging {
  border-color: var(--orange);
  background: #fff7ef;
  outline: none;
  transform: translateY(-1px);
}

.drop-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e6eef6;
  color: var(--navy);
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
}

.dropzone strong { font-size: 13px; }
.dropzone span { font-size: 11.5px; color: var(--muted); }

.file-list { list-style: none; margin: 12px 0 4px; padding: 0; }
.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 6px;
  background: #fbfdff;
}
.file-list .file-name { font-weight: 600; word-break: break-all; }
.file-list .file-size { color: var(--muted); white-space: nowrap; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin: 14px 0;
}

.field-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; font-weight: 650; color: var(--navy-2); }
.field-grid .span-2 { grid-column: span 2; }
.optional { color: var(--muted); font-weight: 500; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  width: 100%;
  border: 1px solid #bcccdc;
  border-radius: 7px;
  padding: 8px 9px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  min-height: 34px;
}

input:focus, select:focus {
  border-color: var(--orange);
  outline: 2px solid rgba(232, 119, 34, 0.18);
  outline-offset: 0;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 650;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.btn.primary { width: 100%; background: var(--orange); color: #fff; box-shadow: 0 2px 0 var(--orange-dark); }
.btn.primary:hover { background: var(--orange-dark); }
.btn.primary:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.55; cursor: wait; }

.hint { font-size: 11px; line-height: 1.45; color: var(--muted); margin-top: 10px; }

.security-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: #f0f9f7;
  border-color: #b7e4dc;
}

.security-icon { font-size: 20px; line-height: 1; }
.security-card strong { font-size: 12.5px; color: var(--teal); }
.security-card p { font-size: 11.5px; line-height: 1.45; color: #3c6e66; margin-top: 3px; }

.error-banner {
  background: #fff1f0;
  border: 1px solid #f3b6b2;
  color: var(--red);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.45;
  word-break: break-word;
}

.empty-state {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 48px;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.6);
}

.empty-graphic {
  width: 74px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 2px solid #c7d5e3;
  border-radius: 9px;
  color: #8fa6bb;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}

.empty-state h2 { font-size: 22px; color: var(--navy); margin-bottom: 8px; }
.empty-state p { max-width: 520px; color: var(--muted); line-height: 1.55; font-size: 13px; }

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

.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.stat strong { font-size: 25px; color: var(--navy); line-height: 1.15; }
.stat-sub { font-size: 10.5px; color: var(--muted); }

.section-card { padding: 16px 18px; margin-bottom: 16px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--orange); font-weight: 750; }
.section-head h2 { font-size: 17px; color: var(--navy); margin-top: 2px; }
.page-head { margin: 4px 2px 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--navy-2);
  border: 1px solid #d5e1ec;
  padding: 4px 9px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.qa-list { display: flex; flex-direction: column; gap: 7px; }

.qa-item {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid #9fb3c8;
  border-radius: 7px;
  background: #fbfdff;
}

.qa-item.error { border-left-color: var(--red); background: #fff7f6; }
.qa-item.warning { border-left-color: var(--amber); background: #fffbf2; }
.qa-item.info { border-left-color: var(--blue); background: #f6f9ff; }

.qa-severity { font-size: 10px; text-transform: uppercase; font-weight: 800; letter-spacing: 0.05em; padding-top: 2px; }
.qa-item.error .qa-severity { color: var(--red); }
.qa-item.warning .qa-severity { color: var(--amber); }
.qa-item.info .qa-severity { color: var(--blue); }

.qa-message { font-size: 12px; line-height: 1.4; }
.qa-code { font-size: 10px; color: var(--muted); margin-top: 2px; font-family: Consolas, "Courier New", monospace; }
.qa-device { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

.device-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }

.device-card { padding: 15px 16px; }
.device-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.device-card h3 { font-size: 16px; color: var(--navy); }
.device-card .platform { font-size: 10.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }

.status-pill {
  font-size: 10px;
  font-weight: 750;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e7f6ec;
  color: var(--green);
  white-space: nowrap;
}
.status-pill.down { background: #fdecea; color: var(--red); }
.status-pill.idle { background: #fff4e5; color: var(--amber); }
.status-pill.ok { background: #e7f6ec; color: var(--green); }
.status-pill.warn { background: #fff4e5; color: var(--amber); }
.status-pill.bad { background: #fdecea; color: var(--red); }
.status-pill.muted { background: #f1f3f5; color: var(--muted); }

#monitoring-table th[data-sort] { user-select: none; }
#monitoring-table th.sort-asc::after { content: " ▲"; font-size: 9px; }
#monitoring-table th.sort-desc::after { content: " ▼"; font-size: 9px; }

.monitoring-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg, #f4f6f9);
  padding: 20px;
  overflow: auto;
}
.monitoring-fullscreen .monitoring-exit {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2001;
}

.kv { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 5px 10px; font-size: 11.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }

.mini-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 750; margin: 12px 0 6px; }

.link-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
  margin-top: 6px;
  font-size: 11px;
}
.link-line span { color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 11.5px; min-width: 620px; }
thead th {
  background: #eef3f8;
  color: var(--navy-2);
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 7px 9px; border-bottom: 1px solid #edf2f7; vertical-align: top; line-height: 1.35; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td.mono, .mono { font-family: Consolas, "Courier New", monospace; font-size: 10.5px; }
td.wrap { min-width: 190px; word-break: break-word; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--navy-2); margin: 4px 0 14px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--orange); }

.download-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.download-panel a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 650;
  color: var(--navy);
  background: #eef7f5;
  border: 1px solid #b7e4dc;
  padding: 9px 12px;
  border-radius: 8px;
}
.download-panel a:hover { background: #e0f2ee; border-color: var(--teal); }
.download-panel .download-note { font-size: 11px; color: var(--muted); width: 100%; }

.footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 28px 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #829ab1;
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 42, 67, 0.52);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 50;
}

.busy-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 260px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  text-align: center;
}
.busy-box strong { color: var(--navy); font-size: 14px; }
.busy-box span { color: var(--muted); font-size: 11.5px; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dbe6ef;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr); padding: 20px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .empty-state { min-height: 260px; }
  .device-grid { grid-template-columns: 1fr; }
  .topbar { padding: 14px 18px; }
  .local-pill { display: none; }
}

@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .span-2 { grid-column: span 1; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .qa-item { grid-template-columns: 70px minmax(0, 1fr); }
  .qa-device { grid-column: 2; }
  .footer { flex-direction: column; }
}
