:root {
  --bg: #f8f8f6;
  --surface: #ffffff;
  --border: #e8e8e3;
  --text: #1a1a18;
  --muted: #6b6b67;
  --accent: #ff6600;
  --accent-dim: #fff3ec;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --sidebar-bg: #141412;
  --sidebar-text: #c8c8c2;
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active: rgba(255,102,0,.15);
  --sidebar-active-text: #ff8533;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ── */
.p-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.p-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.p-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.2px;
}

/* ── Site switcher ── */
.p-site-switcher { padding: 0 10px 8px; position: relative; }

.p-site-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--sidebar-text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  transition: background .15s;
}
.p-site-btn:hover { background: rgba(255,255,255,.1); }
.p-site-btn svg { margin-left: auto; opacity: .5; }

.p-site-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #6b7280;
}
.p-site-dot.online { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.2); }
.p-site-dot.offline { background: #4b5563; }

.p-site-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.p-site-menu {
  display: none;
  position: absolute;
  top: calc(100% - 4px);
  left: 10px; right: 10px;
  background: #1e1e1b;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.p-site-menu.open { display: block; }

.p-site-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--sidebar-text);
  text-decoration: none;
  cursor: pointer;
  transition: background .12s;
}
.p-site-item:hover { background: rgba(255,255,255,.06); }
.p-site-item.active { color: var(--sidebar-active-text); background: var(--sidebar-active); }

/* ── Nav ── */
.p-nav { padding: 8px 10px; flex: 1; display: flex; flex-direction: column; gap: 1px; }

.p-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}
.p-nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.p-nav-item.active { background: var(--sidebar-active); color: var(--sidebar-active-text); }
.p-nav-item svg { flex-shrink: 0; }

.p-sidebar-footer { padding: 8px 10px 16px; border-top: 1px solid rgba(255,255,255,.06); }

/* ── Main ── */
.p-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Page header ── */
.p-page-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 0;
}
.p-page-title { font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -.3px; }
.p-page-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.p-page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Content padding ── */
.p-content { padding: 20px 28px; display: flex; flex-direction: column; gap: 20px; }

/* ── Cards ── */
.p-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.p-card-hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.p-card-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.p-card-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── Stat cards ── */
.p-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .p-stats { grid-template-columns: repeat(2,1fr); } }

.p-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.p-stat-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.p-stat-value { font-size: 26px; font-weight: 600; color: var(--text); letter-spacing: -.5px; font-family: 'DM Mono', monospace; }
.p-stat-change { font-size: 12px; margin-top: 4px; }
.p-stat-change.up { color: var(--green); }
.p-stat-change.down { color: var(--red); }

/* ── Table ── */
.p-table-wrap { overflow-x: auto; }
.p-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.p-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fafafa;
}
.p-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.p-table tr:last-child td { border-bottom: none; }
.p-table tr:hover td { background: #fafaf8; }

/* ── Badges ── */
.p-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.p-badge-green  { background: #d1fae5; color: #065f46; }
.p-badge-amber  { background: #fef3c7; color: #92400e; }
.p-badge-red    { background: #fee2e2; color: #991b1b; }
.p-badge-gray   { background: #f3f4f6; color: #4b5563; }
.p-badge-blue   { background: #dbeafe; color: #1e40af; }

/* ── Buttons ── */
.p-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: background .13s, border-color .13s, color .13s;
  text-decoration: none; white-space: nowrap;
}
.p-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.p-btn-primary:hover { background: #e55a00; border-color: #e55a00; }
.p-btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.p-btn-secondary:hover { background: var(--bg); }
.p-btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.p-btn-danger:hover { background: #fef2f2; }
.p-btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

/* ── Form ── */
.p-form { display: flex; flex-direction: column; gap: 18px; padding: 18px; }
.p-field { display: flex; gap: 16px; align-items: flex-start; }
.p-field-lbl {
  width: 160px; flex-shrink: 0;
  font-size: 13px; font-weight: 500; color: var(--text);
  padding-top: 8px;
}
.p-field-lbl small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.p-field-val { flex: 1; }
.p-inp {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
}
.p-inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,102,0,.1); }
select.p-inp { cursor: pointer; }
textarea.p-inp { resize: vertical; min-height: 80px; }

/* ── Filters ── */
.p-filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.p-filter-btn {
  padding: 5px 12px; border-radius: 6px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  cursor: pointer; transition: all .12s;
  text-decoration: none;
}
.p-filter-btn:hover, .p-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.p-search {
  padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit; font-size: 12px;
  background: var(--surface); color: var(--text);
  outline: none; min-width: 200px;
  transition: border-color .15s;
}
.p-search:focus { border-color: var(--accent); }

/* ── Modal ── */
.p-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 200;
  align-items: center; justify-content: center;
}
.p-modal-overlay.open { display: flex; }
.p-modal {
  background: var(--surface); border-radius: 14px;
  width: 540px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px); overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.p-modal-hd {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.p-modal-title { font-size: 15px; font-weight: 600; }
.p-modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.p-modal-close:hover { background: var(--bg); }
.p-modal-body { padding: 18px 20px; }
.p-modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Notice ── */
.p-notice {
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; margin-bottom: 4px;
}
.p-notice-ok { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.p-notice-err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.p-notice-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Chart container ── */
.p-chart-wrap { padding: 16px 18px; position: relative; height: 240px; }

/* ── Empty state ── */
.p-empty {
  padding: 48px 20px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.p-empty-icon { font-size: 32px; margin-bottom: 10px; opacity: .4; }

/* ── Pagination ── */
.p-pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 18px; border-top: 1px solid var(--border);
}
.p-page-btn {
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 12px; cursor: pointer;
  font-family: inherit; transition: all .12s;
  text-decoration: none;
}
.p-page-btn:hover { background: var(--bg); }
.p-page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.p-page-btn:disabled { opacity: .4; cursor: default; }

/* ── Login page ── */
.p-login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--sidebar-bg);
}
.p-login-card {
  width: 380px; background: #1e1e1b;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px; padding: 32px;
}
.p-login-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 600; color: #fff;
  margin-bottom: 28px;
}
.p-login-title { font-size: 22px; font-weight: 600; color: #fff; margin-bottom: 24px; }
.p-login-field { margin-bottom: 14px; }
.p-login-label { display: block; font-size: 12px; color: var(--sidebar-text); margin-bottom: 6px; font-weight: 500; }
.p-login-inp {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; color: #fff;
  font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .15s;
}
.p-login-inp:focus { border-color: var(--accent); }
.p-login-btn {
  width: 100%; padding: 11px; margin-top: 8px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .13s;
}
.p-login-btn:hover { background: #e55a00; }
.p-login-err { color: #f87171; font-size: 13px; margin-top: 10px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .p-sidebar { width: 64px; }
  .p-logo span, .p-nav-item span, .p-site-name, .p-site-switcher .p-site-btn svg { display: none; }
  .p-nav-item { justify-content: center; }
  .p-page-hd, .p-content { padding-left: 16px; padding-right: 16px; }
}
