/* ---- cards ---- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; }
.card-head .spacer { flex: 1; }
.card.flush { padding: 0; overflow: hidden; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; }
.section-title h3 { color: var(--muted); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, transform .08s;
  white-space: nowrap;
}
.btn:hover { border-color: #3a4552; background: #2b4753; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b2f38; font-weight: 600; }
.btn.primary:hover { background: #C0C4DA; border-color: #C0C4DA; }
.btn.ghost { background: transparent; }
.btn.danger { color: #EFB3A8; border-color: rgba(196, 112, 95, .4); background: rgba(196, 112, 95, .1); }
.btn.danger:hover { background: rgba(196, 112, 95, .18); }
.btn.small { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 30px; height: 30px; padding: 0; }
.btn .ico { width: 15px; height: 15px; }

/* ---- inputs ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted-2); }
input, select, textarea {
  height: 34px; padding: 0 10px;
  background: #14232b; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; width: 100%;
}
textarea { height: auto; min-height: 90px; padding: 9px 10px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 49%, var(--muted) 50%), linear-gradient(-45deg, transparent 49%, var(--muted) 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; background: rgba(255,255,255,.015); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.022); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---- badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface-2);
}
.badge.ok { color: var(--ok); border-color: rgba(127,174,90,.32); background: rgba(127,174,90,.10); }
.badge.warn { color: var(--warn); border-color: rgba(226,176,74,.32); background: rgba(226,176,74,.10); }
.badge.bad { color: #E9A396; border-color: rgba(226,96,122,.34); background: rgba(226,96,122,.10); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- kpi ---- */
.kpi-card { position: relative; overflow: hidden; }
.kpi-card::after {
  content: ""; position: absolute; left: 16px; right: 16px; top: 0; height: 2px;
  background: var(--hue, var(--accent)); opacity: .9;
}
.mdot { display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--hue, var(--muted)); margin-right: 6px; vertical-align: middle; }
.kpi { display: flex; flex-direction: column; gap: 3px; }
.kpi .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .sub { font-size: 12px; color: var(--muted); }

/* ---- meter ---- */
.meter { height: 6px; border-radius: 999px; background: #2b4753; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.meter.ok > span { background: var(--ok); }
.meter.hue > span { background: var(--hue, var(--accent)); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--danger); }

/* ---- code ---- */
pre.code {
  margin: 0; padding: 12px; border-radius: var(--radius-sm);
  background: #101e25; border: 1px solid var(--border);
  overflow: auto; max-height: 340px; white-space: pre-wrap; word-break: break-word;
  color: #c7d2dd;
}
.code-inline {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: #101e25; border: 1px solid var(--border); font-family: var(--mono); font-size: 12px;
  overflow-x: auto; white-space: nowrap;
}
.code-inline span { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* ---- toasts ---- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  min-width: 240px; max-width: 420px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: #25424e; border: 1px solid var(--border-strong); color: var(--text);
  box-shadow: 0 16px 34px -18px #000; font-size: 13px;
  display: flex; gap: 9px; align-items: flex-start;
  animation: toast-in .18s ease;
}
.toast.ok { border-color: rgba(127,174,90,.4); }
.toast.err { border-color: rgba(226,96,122,.45); }
.toast .ico { margin-top: 1px; flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 5, 8, 0.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 70;
}
.modal {
  width: min(620px, 100%); max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px;
  box-shadow: 0 40px 80px -30px #000; padding: 18px;
}
.modal.wide { width: min(920px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { font-size: 15px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 500;
  padding: 8px 12px; cursor: pointer;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }

.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .ico { width: 26px; height: 26px; color: var(--muted-2); display: block; margin: 0 auto 8px; }
