/* ============================================================
   AERONAV — Component library (Levels 2–3)
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-button);
  border: 1px solid var(--border-strong); background: var(--surface-primary);
  color: var(--text-primary); white-space: nowrap;
  /* авиационный стиль: капитель, разрядка */
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  transition: background var(--motion-fast), border-color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-tertiary); border-color: var(--text-tertiary); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-active); border-color: var(--blue-active); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-tertiary); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 11px; border-radius: 7px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 12.5px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- Command bar ---------- */
.commandbar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); background: var(--surface-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-card);
  box-shadow: var(--elev-card); margin-bottom: var(--sp-4);
}
.commandbar .vr { margin: 0 4px; height: 22px; align-self: center; }

/* ---------- Inputs & selects ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.input, .select {
  height: 34px; padding: 0 12px; border-radius: var(--radius-field);
  border: 1px solid var(--border-strong); background: var(--surface-primary);
  color: var(--text-primary); font-size: 14px; width: 100%;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.input:focus, .select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.search {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border-radius: var(--radius-field); border: 1px solid var(--border-strong); background: var(--surface-primary);
  color: var(--text-tertiary); min-width: 220px;
}
.search input { border: 0; outline: none; background: transparent; font-size: 14px; color: var(--text-primary); width: 100%; }
.search svg { width: 16px; height: 16px; flex: none; }

/* switch */
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background var(--motion-fast); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform var(--motion-fast); }
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-elevated); border: 1px solid var(--border-default);
  border-radius: var(--radius-card); box-shadow: var(--elev-card);
}
.card-head { display: flex; align-items: center; gap: 10px; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-subtle); }
.card-head h3 { font-size: var(--fs-card); font-weight: 600; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: var(--sp-4); }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: var(--sp-4); }
.cols-2 { grid-template-columns: repeat(2,1fr); }
.cols-3 { grid-template-columns: repeat(3,1fr); }
.cols-4 { grid-template-columns: repeat(4,1fr); }
.cols-12 { grid-template-columns: repeat(12,1fr); }
@media (max-width: 1500px){ .cols-4 { grid-template-columns: repeat(2,1fr);} }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1;
  background: var(--surface-tertiary); color: var(--text-secondary); white-space: nowrap;
}
.badge .num { font-variant-numeric: tabular-nums; }
.badge.solid-blue { background: var(--blue); color: #fff; }
.badge.count { background: var(--red); color: #fff; min-width: 20px; justify-content: center; padding: 0 6px; }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.status .led { width: 8px; height: 8px; border-radius: 999px; background: var(--text-tertiary); flex: none; box-shadow: 0 0 0 3px transparent; }
.status.normal   .led { background: var(--green); }
.status.degraded .led { background: var(--amber); }
.status.unavailable .led { background: var(--red); }
.status.unknown  .led { background: var(--text-tertiary); }
.status.active   .led { background: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.status.live .led { animation: pulseRing 2s infinite; }

.sev { display:inline-flex; align-items:center; gap:6px; height:20px; padding:0 8px; border-radius:6px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
.sev.info { background: var(--blue-wash); color: var(--blue-info); }
.sev.notice { background: var(--surface-tertiary); color: var(--text-secondary); }
.sev.warning { background: var(--amber-wash); color: var(--amber); }
.sev.critical { background: var(--red-wash); color: var(--red); }
.sev.emergency { background: var(--red-emergency); color: #fff; }

/* object-state pills */
.pill { display:inline-flex; align-items:center; height:22px; padding:0 10px; border-radius:999px; font-size:12px; font-weight:600; border:1px solid var(--border-default); color: var(--text-secondary); background: var(--surface-secondary); }
.pill.ready { color: var(--green); background: var(--green-wash); border-color: transparent; }
.pill.active { color: var(--blue); background: var(--blue-wash); border-color: transparent; }
.pill.planned { color: var(--blue-info); }
.pill.paused { color: var(--amber); background: var(--amber-wash); border-color: transparent; }
.pill.returning { color: var(--purple-nav); }
.pill.draft { color: var(--text-tertiary); }

/* ---------- Data table ---------- */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-table); }
table.data thead th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; color: var(--text-tertiary);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  padding: 9px var(--sp-3); background: var(--surface-secondary); border-bottom: 1px solid var(--border-default); white-space: nowrap;
}
table.data tbody td { padding: 9px var(--sp-3); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
table.data tbody tr { transition: background var(--motion-fast); cursor: default; }
table.data tbody tr:hover { background: var(--surface-secondary); }
table.data tbody tr.sel { background: var(--blue-wash); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12px; }
.checkcell { width: 34px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-default); }
.tab { height: 36px; padding: 0 14px; border: 0; background: transparent; color: var(--text-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; position: relative; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--blue); }
.tab.active::after { content:""; position:absolute; left:8px; right:8px; bottom:-1px; height:2px; background: var(--blue); border-radius:2px; }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: var(--sp-4); }
.kpi .kpi-k { font-size: 12px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; }
.kpi .kpi-v { font-size: 30px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .kpi-v small { font-size: 15px; color: var(--text-tertiary); font-weight: 500; margin-left: 3px; }
.kpi .kpi-delta { font-size: 12px; font-weight: 600; }
.kpi .kpi-delta.up { color: var(--green); } .kpi .kpi-delta.down { color: var(--red); }

/* single ring gauge (used sparingly) */
.ring { --v: 0; --c: var(--blue); width: 76px; height: 76px; border-radius: 999px; flex:none;
  background: conic-gradient(var(--c) calc(var(--v)*1%), var(--surface-tertiary) 0);
  display: grid; place-items: center; position: relative; }
.ring::before { content:""; position:absolute; inset:9px; border-radius:999px; background: var(--surface-elevated); }
.ring .ring-v { position: relative; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- Data value + provenance (SIGNATURE) ---------- */
.dv { position: relative; display: inline-flex; align-items: baseline; gap: 4px; cursor: help;
  border-bottom: 1px dashed transparent; }
.dv .dv-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.dv .dv-unit { font-size: .8em; color: var(--text-tertiary); font-weight: 500; }
.dv[data-prov="measured"] { border-bottom-color: transparent; }
.dv[data-prov="computed"] .dv-val { color: var(--cyan-computed); }
.dv[data-prov="computed"] { border-bottom: 1px dashed var(--cyan-computed); }
.dv[data-prov="forecast"] .dv-val { color: var(--purple-nav); }
.dv[data-prov="forecast"] { border-bottom: 1px dotted var(--purple-nav); }
.dv .conf { width: 26px; height: 4px; border-radius: 2px; background: var(--surface-tertiary); overflow: hidden; align-self: center; }
.dv .conf > i { display: block; height: 100%; background: var(--green); }

.dv-pop {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  min-width: 216px; background: var(--surface-elevated); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--elev-overlay);
  padding: 10px 12px; opacity: 0; pointer-events: none; transition: opacity var(--motion-fast), transform var(--motion-fast); z-index: 90;
}
.dv:hover .dv-pop { opacity: 1; transform: translateX(-50%) translateY(0); }
.dv-pop .pk { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding: 3px 0; }
.dv-pop .pk .kk { color: var(--text-tertiary); }
.dv-pop .pk .vv { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.dv-pop .pt { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-tertiary); margin-bottom: 4px; display:flex; align-items:center; gap:6px; }
.prov-key { display:inline-flex; align-items:center; gap:5px; font-size:11px; color: var(--text-tertiary); }
.prov-key .swatch { width:14px; height:0; border-bottom-width:2px; }
.swatch.measured { border-bottom:2px solid var(--prov-measured); }
.swatch.computed { border-bottom:2px dashed var(--prov-computed); }
.swatch.forecast { border-bottom:2px dotted var(--prov-forecast); }

/* ---------- Alert item ---------- */
.alert { display: flex; gap: 10px; padding: 10px var(--sp-3); border-left: 3px solid var(--border-strong); border-radius: 0 8px 8px 0; background: var(--surface-secondary); transition: background var(--motion-fast); }
.alert:hover { background: var(--surface-tertiary); }
.alert.warning { border-left-color: var(--amber); }
.alert.critical { border-left-color: var(--red); }
.alert.info { border-left-color: var(--blue-info); }
.alert .a-title { font-weight: 600; font-size: 13px; }
.alert .a-meta { font-size: 12px; color: var(--text-tertiary); }
.alert .a-time { margin-left: auto; font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); white-space: nowrap; }

/* ---------- Progress ---------- */
.bar { height: 6px; border-radius: 999px; background: var(--surface-tertiary); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width var(--motion-slow) var(--ease); }
.bar.green > i { background: var(--green); } .bar.amber > i { background: var(--amber); } .bar.red > i { background: var(--red); }

/* ---------- Property inspector rows ---------- */
.prop { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); }
.prop .pk { color: var(--text-secondary); font-size: 13px; }
.prop .pv { font-weight: 600; font-size: 13px; text-align: right; }
.prop:last-child { border-bottom: 0; }
.insp-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-tertiary); margin: var(--sp-4) 0 var(--sp-2); }
.insp-section-title:first-child { margin-top: 0; }

/* ---------- Stepper ---------- */
.stepper { display: flex; flex-direction: column; gap: 2px; }
.step { display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; align-items: flex-start; }
.step:hover { background: var(--surface-secondary); }
.step.active { background: var(--blue-wash); }
.step .sdot { width: 24px; height: 24px; border-radius: 999px; border: 2px solid var(--border-strong); flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text-tertiary); background: var(--surface-primary); }
.step.done .sdot { background: var(--green); border-color: var(--green); color: #fff; }
.step.active .sdot { border-color: var(--blue); color: var(--blue); }
.step.warn .sdot { border-color: var(--amber); color: var(--amber); }
.step .stitle { font-weight: 600; font-size: 14px; }
.step .smeta { font-size: 12px; color: var(--text-tertiary); }

/* legend */
.legend-row { display:flex; align-items:center; gap:8px; padding:5px 0; font-size:12px; color: var(--text-secondary); }
.legend-row .sw { width:14px; height:14px; border-radius:4px; flex:none; border:1px solid rgba(0,0,0,.08); }

/* toolbar over map */
.map-toolbar { display:flex; gap:6px; padding:6px; background: var(--surface-elevated); border:1px solid var(--border-default); border-radius:12px; box-shadow: var(--elev-card); }
.layer-item { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:8px; }
.layer-item:hover { background: var(--surface-secondary); }
.layer-item .meta { margin-left:auto; text-align:right; }
