*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --text: #1e293b;
  --text-muted: #64748b;
  --green: #059669;
  --red: #dc2626;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

body.center-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 8px;
}

.logo { font-size: 18px; font-weight: 700; color: var(--primary); }
.subtitle { color: var(--text-muted); text-align: center; margin-bottom: 24px; font-size: 14px; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  word-break: break-all;
  font-size: 14px;
}
.alert.error { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.alert.success { border-color: #6ee7b7; background: #f0fdf4; color: #065f46; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: #eef2ff; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.btn-warning { border-color: #fde68a; color: var(--warning); background: #fffbeb; }
.btn-warning:hover { background: #fef3c7; border-color: var(--warning); }
.btn-danger { border-color: #fca5a5; color: var(--red); background: #fff5f5; }
.btn-danger:hover { background: #fee2e2; border-color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.full-width { width: 100%; justify-content: center; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.field input, .field select {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.fields-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.section-header h2 { font-size: 18px; font-weight: 600; }

/* Table wrapper — горизонтальный скролл на мобильных */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Table */
.table { width: 100%; border-collapse: collapse; min-width: 600px; }
.table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tr.inactive td { opacity: 0.45; }
.table tr:hover td { background: #fafbff; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }

code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--primary);
  border: 1px solid var(--border);
}
.invite-link {
  display: block;
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  word-break: break-all;
  border: 1px solid var(--border);
}

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: #d1fae5; color: var(--green); }
.badge-red { background: #fee2e2; color: var(--red); }

/* Empty */
.empty { color: var(--text-muted); text-align: center; padding: 32px; font-size: 14px; }

/* Steps (invite page) */
.steps { display: flex; flex-direction: column; gap: 20px; margin: 20px 0; }
.step { display: flex; gap: 16px; align-items: flex-start; }
.step-num {
  width: 30px; height: 30px; flex-shrink: 0;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}

/* Login card */
.login-card {
  max-width: 400px;
  width: 100%;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Hidden */
.hidden { display: none; }

/* Routing page */
.routing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.routing-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.routing-info { flex: 1; min-width: 0; }
.routing-name { font-weight: 600; font-size: 14px; }
.routing-cidrs { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Responsive */
@media (max-width: 640px) {
  .navbar { padding: 12px 16px; }
  .container { padding: 16px 12px; }
  .card { padding: 16px; }
  .fields-row { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .table th, .table td { padding: 8px 10px; }
}
