:root {
  --primary: #2c5aa8;
  --primary-dark: #22488a;
  --red: #e0263a;
  --green: #1f8a4c;
  --danger: #e0263a;
  --text: #1c2230;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f5f7;
  --card: #fff;
  --side-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "DM Sans", system-ui, sans-serif; color: var(--text); background: var(--bg); font-size: 15px; }
button, input, select, textarea { font: inherit; }
a { color: var(--primary); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; padding: 24px; background: #fff; }
.login-img { border-radius: 12px; background: #1d3b1f url("https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1200&q=70") center/cover; min-height: 400px; }
.login-side { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.login-card { width: 100%; max-width: 380px; border: 1px solid var(--line); border-radius: 12px; padding: 28px 30px; }
.login-card h1 { font-family: Lora, serif; font-weight: 500; text-align: center; margin: 0 0 8px; font-size: 30px; }
.login-card p.sub { text-align: center; margin: 0 0 20px; color: #333; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.foot { color: #444; font-size: 13px; }

/* ---------- brand ---------- */
.brand { font-weight: 700; letter-spacing: 1.5px; font-size: 22px; white-space: nowrap; }
.brand .r { color: var(--red); } .brand .b { color: var(--primary); } .brand .g { color: var(--green); }
.brand-lg { font-size: 24px; text-align: center; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 1000; height: 70px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 20px; gap: 18px; }
.burger { background: none; border: 0; cursor: pointer; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.burger span { display: block; width: 22px; height: 2px; background: #222; }
.topnav { flex: 1; display: flex; justify-content: center; gap: 6px; }
.topnav a { text-decoration: none; color: #222; font-weight: 500; letter-spacing: 1px; padding: 10px 16px; border-radius: 4px; }
.topnav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.user { position: relative; }
.user > button { background: none; border: 0; font-weight: 700; letter-spacing: 1px; cursor: pointer; display: flex; align-items: center; gap: 8px; text-transform: uppercase; }
.user-menu { position: absolute; right: 0; top: 36px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.08); min-width: 190px; padding: 6px; display: none; }
.user-menu.open { display: block; }
.user-menu button { width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.user-menu button:hover { background: var(--bg); }

.shell { display: flex; min-height: calc(100vh - 70px); }
.sidebar { width: var(--side-w); background: #fff; border-right: 1px solid var(--line); padding: 32px 16px 20px 20px; display: flex; flex-direction: column; flex-shrink: 0; transition: width .2s; }
.sidebar a { display: flex; align-items: center; gap: 14px; text-decoration: none; color: #222; font-weight: 500; padding: 10px 10px; border-radius: 4px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; }
.sidebar a svg { flex-shrink: 0; }
.sidebar a.active { background: var(--primary); color: #fff; }
.sidebar .grow { flex: 1; }
.collapse-btn { display: flex; justify-content: space-between; align-items: center; background: none; border: 0; padding: 10px 8px; cursor: pointer; font-weight: 500; }
.shell.collapsed .sidebar { width: 76px; }
.shell.collapsed .sidebar .lbl { display: none; }
.shell.collapsed .collapse-btn svg { transform: rotate(180deg); }
.content { flex: 1; min-width: 0; padding: 30px 32px; }
.shell.no-side .sidebar { display: none; }

/* ---------- page parts ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 26px; letter-spacing: 1.5px; }
.page-head .tools { display: flex; gap: 10px; flex-wrap: wrap; }
.search { position: relative; }
.search input { width: 300px; height: 42px; padding: 0 14px 0 42px; border: 1px solid #cfd3da; border-radius: 4px; }
.search svg { position: absolute; left: 14px; top: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 22px; border-radius: 4px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--primary-dark); }
.btn.outline { background: #fff; color: var(--primary); }
.btn.outline:hover { background: #eef3fb; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .6; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; white-space: nowrap; }
th + th { border-left: 1px solid transparent; }
tbody tr:hover { background: #fafbfc; }
.act { white-space: nowrap; width: 1%; border-right: 1px solid var(--line); }
.act a { font-size: 12px; font-weight: 700; text-transform: uppercase; margin-right: 8px; cursor: pointer; }
.act a.edit { color: var(--primary); }
.act a.del { color: var(--danger); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: var(--muted); font-size: 14px; }
.pager .btns { display: flex; gap: 8px; }
.pager .btn { height: 34px; padding: 0 14px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef0f3; }
.badge.ok { background: #e3f4ea; color: var(--green); }
.badge.err { background: #fde8ea; color: var(--danger); }
.badge.wait { background: #fff4dc; color: #a66a00; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat { padding: 18px 20px; }
.stat .n { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .l { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
#map { height: 560px; border-radius: 8px; }

.form-card { padding: 24px; max-width: 720px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: #333; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid #cfd3da; border-radius: 4px; background: #fff; }
.field input[type=checkbox] { width: auto; margin: 0 6px 0 0; }
.field label:has(input[type=checkbox]) { display: flex; align-items: center; }
.field textarea { min-height: 140px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.pw { position: relative; }
.pw button { position: absolute; right: 8px; top: 8px; background: none; border: 0; cursor: pointer; color: #444; }
.checklist { max-height: 260px; overflow: auto; border: 1px solid #cfd3da; border-radius: 4px; padding: 6px 10px; }
.checklist label { display: flex; gap: 8px; align-items: center; font-weight: 400; padding: 4px 0; margin: 0; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,20,30,.45); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; padding: 24px; }
.modal h3 { margin: 0 0 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
#toasts { position: fixed; top: 16px; right: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #fff; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 14px 18px; min-width: 260px; border-left: 4px solid var(--green); }
.toast.err { border-left-color: var(--danger); }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-img { min-height: 180px; }
  .topbar { padding: 0 12px; gap: 8px; height: auto; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .brand { font-size: 16px; }
  .topnav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
  .topbar .brand { flex: 1; }
  .topnav a { padding: 8px 12px; font-size: 14px; white-space: nowrap; }
  .user > button { font-size: 13px; }
  .shell { flex-direction: column; }
  .sidebar { width: 100% !important; flex-direction: row; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar a { margin: 0 4px 0 0; flex-shrink: 0; font-size: 14px; gap: 8px; }
  .sidebar .grow, .collapse-btn { display: none; }
  .shell.collapsed .sidebar .lbl { display: inline; }
  .content { padding: 18px 16px; }
  .search input { width: 100%; }
  .page-head .tools, .search { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  #map { height: 420px; }
}
