:root {
  --bg: #e9ecef;
  --card: #ffffff;
  --text: #213547;
  --muted: #6f8191;
  --line: #d7dee4;
  --primary: #1f8cc6;
  --primary-dark: #0f6e9f;
  --danger: #e53935;
  --warning: #f0ad4e;
  --success: #22a55f;
  --gray-badge: #8393a1;
  --shadow: 0 8px 22px rgba(18, 48, 76, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
label { display: block; font-size: 13px; font-weight: 700; color: #4d6070; margin-bottom: 8px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,140,198,.12); }
button { cursor: pointer; border: 0; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.stack { display: flex; flex-direction: column; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }

.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-shell { width: 100%; max-width: 460px; padding: 24px; }
.login-card {
  background: var(--card); border-radius: 24px; padding: 28px; box-shadow: var(--shadow);
}
.login-brand { margin-bottom: 20px; }
.login-brand h1 { margin: 12px 0 8px; font-size: 32px; }
.brand-pill {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px;
  border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
  font-weight: 700; font-size: 18px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 10px 16px; border-radius: 12px; font-weight: 700; transition: .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 7px 12px; font-size: 12px; }
.btn-primary { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-secondary { background: #edf5fb; color: #27698b; }
.btn-danger { background: #ef3e3a; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-blue { background: #2d84c8; color: #fff; }
.text-link { color: var(--primary); font-weight: 700; }

.app-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: #dedede; border-right: 1px solid #c8c8c8; padding: 24px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { font-weight: 800; font-size: 22px; margin-bottom: 22px; padding: 10px 12px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 10px; }
.nav-btn {
  display: block; padding: 14px 18px; background: #2aa4d1; color: #fff; border-radius: 8px; text-align: center; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}
.nav-btn.active { background: #1279a8; }
.nav-btn-danger { width: 100%; background: #1da1cf; }
.sidebar-logout { margin-top: 16px; }
.content { padding: 26px 28px; }
.page-head { margin-bottom: 20px; }
.page-head-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.page-head h1 { margin: 0 0 6px; font-size: 40px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 22px; }
.hero-card { min-height: 330px; }
.big-counter { font-size: 40px; font-weight: 800; color: var(--primary); }
.map-placeholder {
  position: relative; height: 220px; border-radius: 18px; overflow: hidden; background:
  radial-gradient(circle at 20% 30%, rgba(31,140,198,.16), transparent 18%),
  radial-gradient(circle at 55% 50%, rgba(31,140,198,.12), transparent 14%),
  linear-gradient(180deg, #f4f8fb, #edf2f6);
  border: 1px solid #e2e8ee;
}
.map-grid {
  position: absolute; inset: 0; background-image:
    linear-gradient(rgba(31,140,198,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,140,198,.08) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black, transparent 85%);
}
.map-badge {
  position: absolute; top: 18px; right: 18px; background: rgba(255,255,255,.9); padding: 10px 14px;
  border-radius: 999px; font-weight: 700; color: #1d6789; box-shadow: var(--shadow);
}
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 34px; }
.split-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.form-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-source { display: grid; grid-template-columns: 2.4fr .6fr .8fr auto; gap: 12px; align-items: end; }
.source-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: #fafcfd; }
.source-actions { display: flex; justify-content: flex-end; }
.primary-box { min-height: 46px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); padding: 0 12px; border-radius: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions-bar { display: flex; justify-content: flex-end; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; color: #617687; font-size: 12px; padding: 14px 10px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em;
}
.table td { padding: 14px 10px; border-bottom: 1px solid #edf2f5; vertical-align: top; }
.table-title-row { display: flex; align-items: center; gap: 12px; }
.tiny-logo, .tiny-avatar {
  width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: #d4ebf5; display: grid; place-items: center; font-weight: 700;
}
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 4px 12px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 700;
}
.badge-green { background: var(--success); }
.badge-red { background: var(--danger); }
.badge-yellow { background: var(--warning); }
.badge-blue { background: #2d84c8; }
.badge-gray { background: var(--gray-badge); }
.flash { margin-bottom: 20px; padding: 12px 16px; border-radius: 12px; font-weight: 700; }
.flash-success { background: #e7f8ef; color: #167a43; }
.flash-error { background: #ffeaea; color: #bf2421; }
.logo-preview-wrap { padding: 10px; background: #f7fafc; border-radius: 16px; border: 1px dashed var(--line); display: inline-flex; }
.logo-preview { width: 120px; height: 120px; object-fit: contain; background: white; border-radius: 12px; }
.codebox {
  padding: 14px; border-radius: 14px; background: #f5f8fa; border: 1px solid var(--line); word-break: break-all; font-family: ui-monospace, monospace;
}
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 12px; }
.section-head h3 { margin: 0; font-size: 20px; }
.empty { color: var(--muted); text-align: center; padding: 26px !important; }
@media (max-width: 1200px) {
  .stats-grid, .grid-3, .split-grid, .form-grid { grid-template-columns: 1fr 1fr; }
  .grid-source { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .stats-grid, .split-grid, .form-grid, .grid-2, .grid-3, .grid-source { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .page-head h1 { font-size: 30px; }
}
