:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1a2233;
  --muted: #6b7689;
  --line: #e3e8f0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --sidebar: #101828;
  --sidebar-ink: #cbd5e1;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.logo { font-weight: 700; color: #fff; font-size: 15px; padding: 6px 10px 18px;
  line-height: 1.35; }
.logo small { display: block; color: #94a3b8; font-weight: 400; font-size: 11px; }
.nav-btn {
  background: none; border: 0; color: var(--sidebar-ink); text-align: left;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 10px; width: 100%;
}
.nav-btn:hover { background: rgba(255,255,255,.07); }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn .badge { margin-left: auto; background: rgba(255,255,255,.15);
  border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.sidebar .spacer { flex: 1; }
.main { flex: 1; padding: 26px 30px; max-width: 1400px; }

/* ---------- common ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; margin-bottom: 16px; }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #eef2f7; color: var(--ink); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=url], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe;
  border-color: var(--accent); }
label.field { display: block; margin-bottom: 10px; font-size: 12px;
  color: var(--muted); font-weight: 600; }
label.field input, label.field select, label.field textarea { margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- tags & badges ---------- */
.tag { display: inline-block; background: #eef2ff; color: #3730a3;
  border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600;
  margin: 1px 3px 1px 0; }
.tag.uav { background: #ede9fe; color: #5b21b6; }
.tag.robotics { background: #dcfce7; color: #166534; }
.tag.ew_radio { background: #fef3c7; color: #92400e; }
.tag.optics_sensors { background: #fce7f3; color: #9d174d; }
.tag.embedded_hw { background: #e0f2fe; color: #075985; }
.tag.mechanical { background: #f1f5f9; color: #334155; }
.tag.software { background: #ecfeff; color: #155e75; }
.badge { display: inline-block; border-radius: 12px; padding: 2px 9px;
  font-size: 11px; font-weight: 700; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.gray { background: #f1f5f9; color: #475569; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  padding: 8px 16px; border-radius: 8px; cursor: pointer; background: #e9eef6;
  border: 1px solid transparent; font-weight: 600; font-size: 13px;
}
.tab.active { background: #fff; border-color: var(--accent); color: var(--accent); }

/* ---------- table ---------- */
table.grid { width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.grid th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: 10px 12px; background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line);
  vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: #f8faff; }
.cname { font-weight: 700; }
.csite { font-size: 12px; color: var(--muted); word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 40px !important;
  cursor: default !important; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 30px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; max-width: 860px; width: 100%;
  padding: 24px; position: relative;
}
.modal.wide { max-width: 1000px; }
.modal h2 { display: flex; align-items: center; gap: 10px; }
.modal .close {
  position: absolute; top: 14px; right: 16px; background: none; border: 0;
  font-size: 20px; cursor: pointer; color: var(--muted);
}
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px;
  font-size: 13px; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- search progress ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr));
  gap: 12px; margin: 14px 0; }
.stat { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; }
.stat .num { font-size: 22px; font-weight: 800; }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.spin {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin 0.8s linear infinite; vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: #101828; color: #fff;
  padding: 12px 18px; border-radius: 10px; z-index: 100; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 380px;
}
.toast.err { background: var(--red); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: linear-gradient(135deg,#101828,#1e3a8a); }
.login-card { background: #fff; padding: 34px; border-radius: 16px;
  width: 380px; }
.login-card h1 { font-size: 18px; }

.src-row { display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); }
.src-row:last-child { border-bottom: 0; }
.src-status { margin-left: auto; text-align: right; }
.checkline { display: flex; align-items: center; gap: 8px; margin: 4px 0;
  font-size: 13px; }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; margin: 10px 0; }
