:root {
  --side: #0f172a;
  --side-2: #1e293b;
  --accent: #14b8a6;
  --accent-2: #0d9488;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #16a34a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: linear-gradient(180deg, var(--side), #0b1224);
  color: #e2e8f0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand h1 { margin: 0; font-size: 18px; color: #fff; letter-spacing: .4px; }
.brand span { color: var(--accent); font-size: 12px; }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-group { color: #64748b; font-size: 11px; padding: 12px 12px 6px; text-transform: uppercase; letter-spacing: 1px; }
.nav a {
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(20,184,166,.16); color: #5eead4; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar h2 { margin: 0; font-size: 18px; }
.userbox { color: var(--muted); font-size: 14px; display: flex; gap: 14px; align-items: center; }
.userbox a { color: var(--muted); }

.content { padding: 24px; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.flash.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  overflow-x: auto;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }
.stat { font-size: 28px; font-weight: 700; }
.stat small { display: block; color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table tr:hover td { background: #f8fafc; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--accent-2); text-decoration: none; color: #fff; }
.btn.gray { background: #e2e8f0; color: #334155; }
.btn.gray:hover { background: #cbd5e1; color: #0f172a; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #dc2626; }
.btn.sm { padding: 5px 9px; font-size: 12px; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; color: #334155; }
.input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
textarea { min-height: 280px; resize: vertical; line-height: 1.55; }
.input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(20,184,166,.25);
  border-color: var(--accent);
}

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.no { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #e2e8f0; color: #475569; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 16px; color: var(--muted); font-size: 13px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #134e4a, #0f172a 45%);
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; }
.error { background: #fef2f2; color: #991b1b; padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
pre.preview {
  white-space: pre-wrap;
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 10px;
  font-size: 13px;
  max-height: 240px;
  overflow: auto;
}
.nav a.nav-start { font-size: 13px; padding: 8px 12px; color: #94a3b8; }
.phone {
  background: #0e1621;
  border-radius: 18px;
  padding: 14px 10px 16px;
  max-width: 360px;
}
.tg-row { display: flex; gap: 6px; margin-bottom: 6px; }
.tg-btn {
  flex: 1;
  background: #182533;
  color: #e8f4ff;
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
  font-size: 12px;
  text-decoration: none;
  display: block;
  line-height: 1.3;
}
a.tg-btn:hover { background: #243647; text-decoration: none; color: #fff; }
.tg-btn.off { opacity: .32; background: #151e29; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 16px; font-size: 14px; }
.check.tight { margin: 0 0 10px; }
.phone-row-label {
  color: #94a3b8;
  font-size: 11px;
  margin: 10px 2px 4px;
  letter-spacing: .3px;
}
.phone-row-label:first-child { margin-top: 0; }
.pos-fields {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #334155;
  margin: 8px 0 10px;
}
.pos-num {
  width: 68px;
  padding: 8px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pos-badge {
  display: inline-block;
  background: #ecfeff;
  color: #0f766e;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.layout-card { margin-top: 16px; }
.layout-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.layout-row-head h3 { margin: 0; }
.layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.layout-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}
.layout-item.custom { background: #f0fdfa; }
.layout-item.off { opacity: .78; }
.layout-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.layout-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.muted.tight, p.muted.tight { margin: 0 0 8px; }
.form-row.tight { margin-bottom: 10px; }
.textarea-sm { min-height: 88px; }
.layout-save {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
