:root {
  --bg:      #f4f6f9;
  --card:    #ffffff;
  --text:    #111827;
  --muted:   #6b7280;
  --border:  #e5e7eb;
  --hover:   #f9fafb;
  --accent:  #111827;
}
html.dark {
  color-scheme: dark;
  --bg:      #0a0a0a;
  --card:    #111111;
  --text:    #f0f0f0;
  --muted:   #6b7280;
  --border:  #222222;
  --hover:   #1a1a1a;
  --accent:  #ffffff;
}

html { scroll-behavior: smooth; }
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Page layout ─────────────────────────────── */
.pcu-page { padding: 1.5rem; }

.pcu-header { margin-bottom: 1.75rem; }
.pcu-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .2rem;
  letter-spacing: -.3px;
}
.pcu-header p {
  font-size: .83rem;
  color: var(--muted);
  margin: 0;
}

/* ── Mobile responsive ───────────────────────── */
/* Tables always scroll horizontally */
.pcu-card .pcu-table,
.pcu-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Main content padding on small screens */
@media (max-width: 640px) {
  main[style*="padding:1.5rem"],
  main[style*="padding: 1.5rem"] { padding: 1rem !important; }

  .pcu-header h1 { font-size: 1.1rem; }

  /* Stack card grids */
  .pcu-card-body[style*="grid"],
  .stats-grid { grid-template-columns: 1fr !important; }

  /* Full-width buttons in toolbar areas */
  .pcu-tabs { gap: .25rem; }
  .pcu-tab  { font-size: .75rem; padding: .3rem .625rem; }

  /* Search bars go full width */
  .pcu-search { width: 100% !important; }
  .pcu-search input { max-width: none !important; }

  /* Topbar search hide on very small */
  #pcu-topbar .search-wrap { max-width: 180px; }
}

/* Prevent content overflow */
table { min-width: 100%; }
.overflow-x-auto,
.pcu-table-wrap { overflow-x: auto; }

/* Remove bg-white/shadow for dark mode tables */
.relative.overflow-x-auto { background: var(--card) !important; border-radius: 12px !important; border: 1px solid var(--border) !important; box-shadow: none !important; }
html.dark .relative.overflow-x-auto { background: var(--card) !important; }

/* ── Cards ───────────────────────────────────── */
.pcu-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.pcu-card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .625rem;
}
.pcu-card-header h2 {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.pcu-card-header i { color: var(--muted); font-size: .8rem; }
.pcu-card-body { padding: 1.25rem; }

/* ── Tables ──────────────────────────────────── */
.pcu-table { width: 100%; border-collapse: collapse; }
.pcu-table thead th {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  white-space: nowrap;
  text-align: left;
}
.pcu-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.pcu-table tbody tr:last-child { border-bottom: none; }
.pcu-table tbody tr:hover { background: var(--hover); }
.pcu-table tbody td {
  padding: .75rem 1.25rem;
  font-size: .82rem;
  color: var(--text);
  vertical-align: middle;
}
.pcu-table tbody td a { color: var(--muted); text-decoration: none; font-weight: 500; }
.pcu-table tbody td a:hover { color: var(--text); }

/* ── Tabs / Filters ──────────────────────────── */
.pcu-tabs { display: flex; gap: .375rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.pcu-tab {
  padding: .375rem .875rem;
  border-radius: 7px;
  font-size: .8rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s;
  cursor: pointer;
}
.pcu-tab:hover { background: var(--hover); color: var(--text); }
.pcu-tab.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* ── Buttons ─────────────────────────────────── */
.pcu-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.pcu-btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.pcu-btn-primary:hover { opacity: .85; }
.pcu-btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.pcu-btn-ghost:hover { background: var(--hover); color: var(--text); }
.pcu-btn-danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.pcu-btn-danger:hover { background: #fee2e2; }
html.dark .pcu-btn-danger { background: rgba(220,38,38,.1); color: #f87171; border-color: rgba(220,38,38,.2); }
html.dark .pcu-btn-danger:hover { background: rgba(220,38,38,.15); }

/* ── Alerts ──────────────────────────────────── */
.pcu-alert {
  padding: .75rem 1rem;
  border-radius: 9px;
  font-size: .83rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.pcu-alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.pcu-alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
html.dark .pcu-alert-success { background: rgba(21,128,61,.08); color: #4ade80; border-color: rgba(21,128,61,.2); }
html.dark .pcu-alert-error   { background: rgba(220,38,38,.08); color: #f87171; border-color: rgba(220,38,38,.2); }

/* ── Badges ──────────────────────────────────── */
.pcu-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 6px;
  font-size: .73rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--hover);
  color: var(--muted);
}
.pcu-badge-red   { background: rgba(220,38,38,.07); color: #dc2626; border-color: rgba(220,38,38,.15); }
.pcu-badge-green { background: rgba(22,163,74,.07); color: #16a34a; border-color: rgba(22,163,74,.15); }
.pcu-badge-blue  { background: rgba(37,99,235,.07); color: #2563eb; border-color: rgba(37,99,235,.15); }
html.dark .pcu-badge-red   { background: rgba(220,38,38,.12); color: #f87171; border-color: rgba(220,38,38,.2); }
html.dark .pcu-badge-green { background: rgba(34,197,94,.1);  color: #4ade80; border-color: rgba(34,197,94,.2); }
html.dark .pcu-badge-blue  { background: rgba(59,130,246,.1); color: #60a5fa; border-color: rgba(59,130,246,.2); }

/* ── Search input ────────────────────────────── */
.pcu-search {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.pcu-search i {
  position: absolute;
  left: 10px;
  color: var(--muted);
  font-size: .78rem;
  pointer-events: none;
}
.pcu-search input {
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .75rem .5rem 2rem;
  font-size: .82rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.pcu-search input:focus { border-color: var(--accent); }
.pcu-search input::placeholder { color: var(--muted); }

/* ── Forms ───────────────────────────────────── */
.pcu-input, .pcu-select, .pcu-textarea {
  width: 100%;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .75rem;
  font-size: .85rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.pcu-input:focus, .pcu-select:focus, .pcu-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17,24,39,.06);
}
html.dark .pcu-input:focus, html.dark .pcu-select:focus, html.dark .pcu-textarea:focus {
  box-shadow: 0 0 0 3px rgba(255,255,255,.06);
}
.pcu-label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .4rem;
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* ── Tailwind overrides (light) ──────────────── */
.bg-white  { background-color: var(--card) !important; }
.bg-gray-50, .bg-gray-100 { background-color: var(--hover) !important; }
.text-gray-900, .text-gray-800 { color: var(--text) !important; }
.text-gray-700 { color: var(--text) !important; }
.text-gray-600, .text-gray-500 { color: var(--muted) !important; }
.border-gray-200, .border-gray-300 { border-color: var(--border) !important; }
.rounded-lg { border-radius: 10px !important; }

/* Active tab override (Tailwind bg-blue-600 → B&W) */
.bg-blue-600, .bg-blue-500 { background-color: var(--accent) !important; color: var(--bg) !important; }
.bg-gray-200 { background-color: var(--hover) !important; color: var(--muted) !important; }
a.bg-blue-600, a.bg-blue-500 { color: var(--bg) !important; }

/* ── Dark mode overrides ─────────────────────── */
html.dark .bg-white,
html.dark [class*="bg-white"]       { background-color: var(--card) !important; }
html.dark .bg-gray-50,
html.dark .bg-gray-100              { background-color: var(--hover) !important; }
html.dark .bg-gray-200              { background-color: #1a1a1a !important; }
html.dark .bg-gray-700,
html.dark .bg-gray-800,
html.dark .dark\:bg-gray-800,
html.dark .dark\:bg-gray-700       { background-color: #000 !important; }
html.dark .text-gray-900,
html.dark .text-gray-800           { color: var(--text) !important; }
html.dark .text-gray-700           { color: #e5e7eb !important; }
html.dark .text-gray-600,
html.dark .text-gray-500,
html.dark .text-gray-400           { color: var(--muted) !important; }
html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .border-gray-600,
html.dark .border-gray-700         { border-color: var(--border) !important; }
html.dark nav,
html.dark #logo-sidebar,
html.dark .dark\:bg-gray-800       { background-color: #000 !important; border-color: var(--border) !important; }
html.dark table thead tr,
html.dark thead,
html.dark table thead th           { background-color: var(--card) !important; color: var(--text) !important; }
html.dark table tbody tr           { background-color: var(--card) !important; }
html.dark table tbody tr:hover     { background-color: var(--hover) !important; }
html.dark table tbody td           { color: var(--text) !important; }
html.dark .hover\:bg-gray-50:hover,
html.dark .hover\:bg-gray-100:hover { background-color: var(--hover) !important; }
html.dark .hover\:bg-gray-700:hover { background-color: #1a1a1a !important; }
html.dark input:not([type=checkbox]):not([type=radio]),
html.dark select,
html.dark textarea {
  background-color: var(--hover) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder    { color: #374151 !important; }
html.dark .shadow, html.dark .shadow-sm,
html.dark .shadow-md, html.dark .shadow-xl,
html.dark .shadow-xs               { box-shadow: 0 1px 2px rgba(0,0,0,.5) !important; }
html.dark .divide-gray-100 > * + *,
html.dark .divide-gray-200 > * + *,
html.dark .divide-y > * + *        { border-color: var(--border) !important; }
html.dark footer                   { background-color: #0a0a0a !important; }
html.dark footer span,
html.dark footer a                 { color: var(--muted) !important; }
html.dark .swal2-popup             { background-color: #111 !important; }
html.dark .swal2-title,
html.dark .swal2-html-container    { color: var(--text) !important; }
html.dark .swal2-input,
html.dark .swal2-textarea,
html.dark .swal2-select            { background-color: var(--hover) !important; border-color: var(--border) !important; color: var(--text) !important; }
html.dark .bg-blue-600,
html.dark .bg-blue-500             { background-color: var(--accent) !important; color: var(--bg) !important; }
html.dark .bg-gray-200             { background-color: var(--hover) !important; color: var(--muted) !important; }
html.dark .bg-green-100            { background: rgba(34,197,94,.1) !important; }
html.dark .text-green-800          { color: #4ade80 !important; }
html.dark .bg-red-100              { background: rgba(220,38,38,.1) !important; }
html.dark .text-red-800            { color: #f87171 !important; }
html.dark #theme-toggle            { color: var(--accent) !important; }
html.dark #theme-toggle:hover      { background-color: var(--hover) !important; }

/* ── Page load & smooth content ───────────────── */
body.pcu-ready main {
  animation: pcu-fadeIn .2s ease-out;
}
@keyframes pcu-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
body.pcu-ready main.pcu-loading { opacity: .7; pointer-events: none; }

/* ── Page header with icon (unified) ──────────── */
.pcu-page-header {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.pcu-page-header-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  background: var(--hover);
  color: var(--muted);
  border: 1px solid var(--border);
  transition: color .2s, background .2s;
}
html.dark .pcu-page-header-icon { background: var(--card); }
.pcu-page-header-text h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .25rem;
  letter-spacing: -.3px;
  line-height: 1.2;
}
.pcu-page-header-text p {
  font-size: .85rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

/* ── Empty state with icon ────────────────────── */
.pcu-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.pcu-empty i {
  display: block;
  font-size: 2rem;
  margin-bottom: .75rem;
  opacity: .6;
}
.pcu-empty strong { color: var(--text); font-weight: 600; }

/* ── Table link style (consistent) ────────────── */
.pcu-table tbody td a.pcu-link,
.pcu-link { color: var(--accent); text-decoration: none; font-weight: 500; transition: opacity .15s; }
.pcu-table tbody td a.pcu-link:hover,
.pcu-link:hover { opacity: .85; text-decoration: underline; }
html.dark .pcu-link { color: #93c5fd; }

/* ── Subsection titles in cards ───────────────── */
.pcu-card-section-title {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  padding: .75rem 1.25rem .4rem;
  margin: 0;
}
