:root {
  --bg: #06101c;
  --sidebar: #07111e;
  --top: #050d18;
  --panel: #0b1929;
  --panel2: #0d1d30;
  --border: #182d43;
  --border2: #203c58;
  --text: #dce9f6;
  --muted: #6d849c;
  --green: #25df8f;
  --blue: #268cff;
  --cyan: #43c6ff;
  --red: #ef4555;
  --amber: #ffa729;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 12px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.ok {
  color: var(--green) !important;
}

.bad {
  color: var(--red) !important;
}

.warn {
  color: var(--amber) !important;
}

/* APP */

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: var(--sidebar);
  border-right: 1px solid #14283d;
  overflow-y: auto;
  z-index: 20;
}

.workspace {
  margin-left: 220px;
  min-height: 100vh;
}

.sidebar-brand {
  height: 62px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #14283d;
}

.logo-ring {
  width: 35px;
  height: 35px;
  border: 2px solid #36d98c;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #44e79b;
  font-size: 20px;
  box-shadow: 0 0 18px rgba(37,223,143,.12);
}

.logo-title {
  font-size: 14px;
  font-weight: 700;
}

.logo-sub {
  margin-top: 2px;
  color: #60788f;
  font-size: 8px;
}

.side-section {
  padding: 14px 10px 0;
}

.side-label {
  padding: 0 8px 6px;
  font-size: 8px;
  color: #50667b;
  letter-spacing: .12em;
  font-weight: 700;
}

.side-item {
  height: 33px;
  padding: 0 9px;
  margin: 2px 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #8499ad;
  text-decoration: none;
  border-radius: 4px;
  font-size: 11px;
}

.side-item:hover {
  background: #0d1d2e;
  color: #dceaf7;
}

.side-item.active {
  background: #10243a;
  color: #eaf4ff;
  border-left: 2px solid var(--green);
}

.side-item.active span {
  color: var(--green);
}

.side-item.disabled {
  opacity: .75;
}

.sidebar-version {
  padding: 25px 17px;
  color: #44596e;
  font-size: 8px;
}

/* TOPBAR */

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 56px;
  background: rgba(5,13,24,.97);
  border-bottom: 1px solid #14283d;
  padding: 0 17px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-title {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
  font-size: 12px;
}

.top-icon {
  color: var(--green);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 11px;
}

.top-select,
.icon-button,
.logout-small {
  border: 1px solid #1b334b;
  background: #081521;
  color: #91a6b9;
  height: 31px;
  border-radius: 4px;
}

.top-select {
  width: 95px;
  padding: 0 8px;
}

.probe-online {
  height: 31px;
  border: 1px solid #183348;
  background: #081521;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: 4px;
  font-size: 10px;
}

.dot-green {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: var(--green);
  box-shadow: 0 0 8px rgba(37,223,143,.8);
}

.clock {
  min-width: 62px;
  text-align: center;
  font-size: 9px;
}

.clock strong,
.clock span {
  display: block;
}

.clock span {
  color: #657c91;
}

.icon-button {
  width: 30px;
}

.top-user {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
}

.avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #526171;
  color: #dce9f6;
}

.logout-small {
  padding: 0 9px;
}

/* CONTENT */

.dashboard-content {
  padding: 12px;
  max-width: none;
}

.overview-row {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(150px, .85fr))
    minmax(330px, 1.8fr);
  gap: 9px;
  margin-bottom: 10px;
}

.dashboard-card,
.idc-card,
.matrix-card {
  background:
    linear-gradient(
      180deg,
      rgba(13,29,48,.98),
      rgba(8,22,36,.98)
    );
  border: 1px solid var(--border);
  border-radius: 4px;
}

.idc-card {
  padding: 12px;
  min-height: 138px;
}

.idc-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.idc-head strong,
.idc-head span {
  display: block;
}

.idc-head strong {
  font-size: 11px;
}

.idc-head div > span {
  color: #6d8499;
  font-size: 8px;
  margin-top: 2px;
}

.idc-badge {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  display: grid !important;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 10px;
}

.vt .idc-badge {
  background: #d83c48;
}

.cmc .idc-badge {
  background: #1486db;
}

.fpt .idc-badge {
  background: #e88811;
}

.vnpt .idc-badge {
  background: #7250c9;
}

.idc-status {
  margin: 8px 0;
  color: #668097;
  font-size: 8px;
}

.idc-metrics {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.idc-metrics span,
.idc-metrics strong {
  display: block;
}

.idc-metrics span {
  font-size: 8px;
  color: #70869a;
}

.idc-metrics strong {
  margin-top: 2px;
  color: #39e89b;
  font-size: 13px;
}

.mini-chart {
  height: 22px;
  margin-top: 8px;
  opacity: .8;
  background:
    linear-gradient(
      170deg,
      transparent 0 38%,
      rgba(39,139,255,.65) 39% 42%,
      transparent 43% 53%,
      rgba(39,139,255,.6) 54% 57%,
      transparent 58%
    );
}

.matrix-card {
  padding: 10px;
}

.card-head {
  min-height: 31px;
  border-bottom: 1px solid #1b344c;
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
}

.card-head span {
  color: #638099;
  font-size: 8px;
  font-weight: 400;
}

.green-title {
  color: #31de91;
}

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

.matrix-table {
  font-size: 8px;
}

.matrix-table th,
.matrix-table td {
  border-bottom: 1px solid #172c40;
  padding: 5px;
  text-align: center;
}

.matrix-table th {
  color: #8196aa;
}

/* LIVE TEST */

.live-test-card {
  padding: 10px 12px;
  margin-bottom: 10px;
}

.live-source-grid {
  display: grid;
  grid-template-columns:
    1fr 1.2fr 1.2fr 1.15fr
    1.35fr 112px;
  align-items: end;
  gap: 8px;
}

.compact-field,
.tiny-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compact-field > span,
.tiny-field > span {
  color: #6f879d;
  text-transform: uppercase;
  font-size: 7px;
  letter-spacing: .07em;
  font-weight: 700;
}

.compact-field input,
.compact-field select,
.tiny-field input,
.tiny-field select {
  border: 1px solid #1f3c59;
  background: #071726;
  color: #d5e6f7;
  border-radius: 3px;
  outline: none;
}

.compact-field input,
.compact-field select {
  height: 34px;
  padding: 0 8px;
  font-size: 10px;
}

.tiny-field input,
.tiny-field select {
  height: 27px;
  padding: 0 7px;
  font-size: 9px;
}

.tool-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.test-btn {
  height: 16px;
  border: 1px solid #28455f;
  border-radius: 3px;
  background: #0a1a29;
  color: #7892a9;
  font-size: 7px;
  font-weight: 700;
}

.test-btn.active {
  color: #fff;
  background: #186dba;
  border-color: #3197e7;
}

.start-test {
  height: 34px;
  border: 1px solid #31cd8b;
  border-radius: 3px;
  background: #13a969;
  color: white;
  font-size: 9px;
  font-weight: 700;
}

.advanced-row {
  display: flex;
  align-items: end;
  gap: 7px;
  margin-top: 8px;
}

.tiny-field {
  width: 92px;
}

.source-inline {
  flex: 1;
  min-height: 27px;
  padding: 7px 8px;
  color: #59778e;
  background: #081725;
  border: 1px solid #162f47;
  border-radius: 3px;
  font: 8px ui-monospace, monospace;
}

/* MAIN GRID */

.dashboard-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.45fr) minmax(280px, .85fr);
  gap: 10px;
}

.dashboard-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-right > .dashboard-card,
.result-card,
.visualization-card,
.latency-card,
.empty-result {
  padding: 10px 12px;
}

.result-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, .9fr);
  gap: 10px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 9px;
}

.metric-strip > div {
  padding: 8px;
  background: #0a1b2c;
  border: 1px solid #19344e;
  border-radius: 3px;
}

.metric-strip span,
.metric-strip strong,
.metric-strip small {
  display: block;
}

.metric-strip span {
  color: #6a849b;
  font-size: 7px;
  text-transform: uppercase;
}

.metric-strip strong {
  color: #37e498;
  margin-top: 4px;
  font-size: 13px;
}

.metric-strip small {
  margin-top: 2px;
  color: #617d94;
  font-size: 7px;
}

.network-section {
  margin-top: 6px;
}

.sub-head {
  padding: 7px 0;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #193249;
  font-size: 9px;
  font-weight: 700;
}

.table-scroll {
  overflow: auto;
}

.data-table {
  font: 8px ui-monospace, monospace;
}

.data-table th,
.data-table td,
.right-table th,
.right-table td {
  padding: 6px 7px;
  border-bottom: 1px solid #173047;
  text-align: left;
  white-space: nowrap;
}

.data-table th,
.right-table th {
  color: #618099;
  text-transform: uppercase;
  font-size: 7px;
}

.data-table td {
  color: #96abc0;
}

.data-table td.host {
  color: #d6e7f8;
}

.route-map {
  height: 180px;
  border: 1px solid #162f45;
  background:
    radial-gradient(
      circle at 50% 50%,
      rgba(20,82,101,.16),
      transparent 65%
    ),
    #081725;
}

.route-map svg {
  width: 100%;
  height: 100%;
}

.route-path {
  fill: none;
  stroke: #2ed694;
  stroke-width: 3;
}

.route-node {
  stroke: #081725;
  stroke-width: 3;
}

.route-node.green { fill: #24df91; }
.route-node.amber { fill: #ffad20; }
.route-node.red { fill: #e84654; }

.intel-mini {
  margin-top: 8px;
}

.intel-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 8px;
}

.intel-row span {
  color: #617b92;
}

.intel-row strong {
  font-weight: 500;
  color: #9db5ca;
}

/* LATENCY */

.latency-card {
  margin-top: 10px;
}

.latency-chart-shell {
  height: 165px;
  border: 1px solid #17334c;
  background: #071725;
}

.latency-chart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-grid {
  stroke: rgba(100,132,160,.18);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis-label {
  fill: #607d94;
  font: 10px ui-monospace, monospace;
}

.latency-line {
  fill: none;
  stroke: #3c9dff;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.latency-point {
  fill: #55b7ff;
  stroke: #c6e9ff;
  stroke-width: 1.5;
}

.latency-timeout-point {
  fill: #ffa729;
}

.chart-legend {
  padding-top: 5px;
  display: flex;
  justify-content: space-between;
  color: #617d94;
  font-size: 7px;
}

/* RIGHT */

.right-table {
  font-size: 8px;
}

.online-label {
  color: #29d991 !important;
}

.placeholder-list > div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #162d42;
  font-size: 8px;
}

.placeholder-list span {
  color: #60798f;
}

.placeholder-list strong {
  color: #9bafc2;
  font-weight: 500;
}

.empty-small,
.empty-message {
  color: #526d83;
  text-align: center;
  padding: 26px 10px;
  font-size: 9px;
}

.raw-card {
  margin-top: 10px;
  padding: 10px;
}

.raw-card summary {
  color: #617d94;
  font-size: 8px;
  cursor: pointer;
}

.raw-card pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 8px ui-monospace, monospace;
  color: #7894aa;
}

/* MESSAGES */

.message {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #61303a;
  background: #24141b;
  color: #ff8f9b;
  border-radius: 3px;
  font-size: 9px;
}

/* LOGIN - giữ login hiện tại dùng được */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: 390px;
  max-width: calc(100% - 30px);
}

.login-card {
  padding: 27px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 6px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #1e7ce2;
  display: grid;
  place-items: center;
}

.login-copy {
  margin: 30px 0 20px;
}

.login-copy h1 {
  margin: 5px 0;
}

.login-card .field {
  display: block;
  margin-bottom: 12px;
}

.login-card .field span {
  display: block;
  margin-bottom: 5px;
  color: #6c849a;
  font-size: 9px;
}

.login-card input {
  width: 100%;
  height: 37px;
  border: 1px solid #23415e;
  background: #071725;
  border-radius: 3px;
  padding: 0 9px;
}

.login-btn {
  width: 100%;
  height: 37px;
  background: #1879df;
  border: 0;
  border-radius: 3px;
  color: white;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  color: #506a80;
  font-size: 8px;
}

@media (max-width: 1400px) {
  .overview-row {
    grid-template-columns: repeat(4, 1fr);
  }

  .matrix-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  .sidebar {
    width: 185px;
  }

  .workspace {
    margin-left: 185px;
  }

  .dashboard-main-grid,
  .result-top-grid {
    grid-template-columns: 1fr;
  }

  .live-source-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
