:root {
  --pc-bg: #f4f6fb;
  --pc-surface: #ffffff;
  --pc-surface-2: #f8f9fc;
  --pc-text: #161b2e;
  --pc-muted: #667085;
  --pc-border: #e4e7ef;
  --pc-primary: #4361ee;
  --pc-primary-ink: #ffffff;
  --pc-danger: #d92d20;
  --pc-warn: #b54708;
  --pc-warn-bg: #fef0c7;
  --pc-ok: #067647;
  --pc-ok-bg: #dcfae6;
  --pc-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pc-bg: #0d111c;
    --pc-surface: #151b2b;
    --pc-surface-2: #1b2236;
    --pc-text: #eef1f8;
    --pc-muted: #98a2b3;
    --pc-border: #283149;
    --pc-primary: #6b84ff;
    --pc-warn: #fdb022;
    --pc-warn-bg: rgba(253, 176, 34, 0.14);
    --pc-ok: #47cd89;
    --pc-ok-bg: rgba(71, 205, 137, 0.14);
    --pc-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --pc-bg: #0d111c;
  --pc-surface: #151b2b;
  --pc-surface-2: #1b2236;
  --pc-text: #eef1f8;
  --pc-muted: #98a2b3;
  --pc-border: #283149;
  --pc-primary: #6b84ff;
  --pc-warn: #fdb022;
  --pc-warn-bg: rgba(253, 176, 34, 0.14);
  --pc-ok: #47cd89;
  --pc-ok-bg: rgba(71, 205, 137, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--pc-bg);
  color: var(--pc-text);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--pc-primary); }
button, input, select, textarea { font: inherit; color: inherit; }

.pc-loading { display: flex; justify-content: center; padding: 80px 0; font-size: 1.6rem; color: var(--pc-muted); }

/* Auth screens */
.pc-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.pc-auth__card {
  width: 100%; max-width: 400px; background: var(--pc-surface); border: 1px solid var(--pc-border);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--pc-shadow);
}
.pc-auth__card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.pc-auth__card p { margin: 0 0 18px; color: var(--pc-muted); }

/* Layout */
.pc-top {
  position: sticky; top: 0; z-index: 5; background: var(--pc-surface); border-bottom: 1px solid var(--pc-border);
}
.pc-top__inner { max-width: 1200px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pc-brand { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.pc-brand i { color: var(--pc-primary); }
.pc-nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.pc-nav button {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 10px; cursor: pointer; color: var(--pc-muted); font-weight: 600;
}
.pc-nav button.active { background: var(--pc-surface-2); color: var(--pc-text); }
.pc-user { display: flex; align-items: center; gap: 10px; color: var(--pc-muted); font-size: 0.9rem; }
.pc-main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pc-head h2 { margin: 0; font-size: 1.35rem; }

/* Controls */
.pc-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--pc-border); background: var(--pc-surface);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--pc-text);
  white-space: nowrap;
}
.pc-btn:hover { border-color: var(--pc-primary); }
.pc-btn--primary { background: var(--pc-primary); border-color: var(--pc-primary); color: var(--pc-primary-ink); }
.pc-btn--danger { color: var(--pc-danger); border-color: color-mix(in srgb, var(--pc-danger) 40%, var(--pc-border)); }
.pc-btn--sm { padding: 5px 10px; font-size: 0.85rem; }
.pc-btn:disabled { opacity: 0.55; cursor: default; }
.pc-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.pc-field label { font-weight: 600; font-size: 0.9rem; }
.pc-field small { color: var(--pc-muted); }
.pc-input, .pc-field input, .pc-field select, .pc-field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--pc-border); border-radius: 10px; background: var(--pc-surface-2);
}
.pc-field input:focus, .pc-field select:focus, .pc-field textarea:focus { outline: 2px solid color-mix(in srgb, var(--pc-primary) 40%, transparent); border-color: var(--pc-primary); }
.pc-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.pc-check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; margin: 0 14px 8px 0; }
.pc-slug { display: flex; align-items: stretch; }
.pc-slug input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.pc-slug span {
  display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--pc-border); border-left: 0;
  border-radius: 0 10px 10px 0; color: var(--pc-muted); background: var(--pc-surface); white-space: nowrap; font-size: 0.85rem;
}
.pc-error { color: var(--pc-danger); min-height: 1.2em; margin: 6px 0 0; font-size: 0.9rem; }

/* Cards */
.pc-card { background: var(--pc-surface); border: 1px solid var(--pc-border); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.pc-card h3 { margin: 0 0 12px; font-size: 1.05rem; }
.pc-card--danger { border-color: color-mix(in srgb, var(--pc-danger) 35%, var(--pc-border)); }
.pc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.pc-stat { background: var(--pc-surface); border: 1px solid var(--pc-border); border-radius: 14px; padding: 14px 16px; }
.pc-stat span { color: var(--pc-muted); font-size: 0.85rem; }
.pc-stat strong { display: block; font-size: 1.5rem; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Schools */
.pc-schools { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.pc-school { background: var(--pc-surface); border: 1px solid var(--pc-border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pc-school__head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pc-school__name { font-weight: 800; font-size: 1.05rem; }
.pc-school__url { font-size: 0.85rem; word-break: break-all; }
.pc-school__nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pc-school__nums div { background: var(--pc-surface-2); border-radius: 10px; padding: 8px; text-align: center; }
.pc-school__nums strong { display: block; font-variant-numeric: tabular-nums; }
.pc-school__nums span { font-size: 0.72rem; color: var(--pc-muted); }
.pc-school__meta { font-size: 0.82rem; color: var(--pc-muted); }
.pc-school__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.pc-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.pc-badge--ok { background: var(--pc-ok-bg); color: var(--pc-ok); }
.pc-badge--warn { background: var(--pc-warn-bg); color: var(--pc-warn); }
.pc-badge--muted { background: var(--pc-surface-2); color: var(--pc-muted); }

/* Detail */
.pc-back { margin-bottom: 12px; }
.pc-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.pc-limit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }

/* Table */
.pc-table-wrap { overflow-x: auto; background: var(--pc-surface); border: 1px solid var(--pc-border); border-radius: 14px; }
.pc-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.pc-table th, .pc-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--pc-border); vertical-align: top; }
.pc-table th { color: var(--pc-muted); font-weight: 600; background: var(--pc-surface-2); }
.pc-table tr:last-child td { border-bottom: 0; }
.pc-table code { font-size: 0.8rem; color: var(--pc-muted); word-break: break-word; }

/* Modal */
.pc-modal { position: fixed; inset: 0; background: rgba(8, 11, 24, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.pc-modal__card { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: var(--pc-surface); border-radius: 18px; padding: 22px; box-shadow: var(--pc-shadow); }
.pc-modal__card h3 { margin: 0 0 14px; }
.pc-modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.pc-secret { font-family: ui-monospace, monospace; background: var(--pc-surface-2); border-radius: 10px; padding: 10px 12px; word-break: break-all; }

.pc-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--pc-text); color: var(--pc-bg);
  padding: 10px 18px; border-radius: 12px; z-index: 30; box-shadow: var(--pc-shadow); max-width: calc(100vw - 32px);
}
.pc-toast.is-error { background: var(--pc-danger); color: #fff; }

@media (max-width: 640px) {
  .pc-top__inner { gap: 8px; }
  .pc-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .pc-schools { grid-template-columns: 1fr; }
  .pc-school__nums { grid-template-columns: repeat(2, 1fr); }
}
