:root{--bg:#f7f8fa;--card:#fff;--text:#1f2937;--muted:#64748b;--primary:#667eea;--border:#e5e7eb;--radius:12px}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji"}

/* Legacy styles - scoped to avoid conflicts */
.legacy-ui .container{max-width:960px;margin:0 auto;padding:24px}
.legacy-ui .site-header{position:sticky;top:0;background:var(--card);border-bottom:1px solid var(--border);z-index:10}
.legacy-ui .header-inner{display:flex;align-items:center;justify-content:space-between}
.legacy-ui .brand{font-weight:600;font-size:18px}
.legacy-ui .nav{display:flex;gap:16px}
.legacy-ui .nav-link{color:var(--muted);text-decoration:none;padding:12px 8px;border-radius:8px}
.legacy-ui .nav-link:hover{background:#f0f4ff;color:var(--primary)}
.legacy-ui .card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:20px;box-shadow:0 1px 2px rgba(0,0,0,0.03);margin-bottom:16px}
.legacy-ui .btn{display:inline-block;background:var(--primary);color:#fff;border:none;border-radius:10px;padding:10px 16px;text-decoration:none;cursor:pointer}
.legacy-ui .btn.secondary{background:#eef2ff;color:#1e3a8a}
.legacy-ui .btn.danger{background:#ef4444}
.legacy-ui .btn:disabled{opacity:.6;cursor:not-allowed}
.legacy-ui .table{width:100%;border-collapse:separate;border-spacing:0}
.legacy-ui .table th,.legacy-ui .table td{padding:12px 14px;border-bottom:1px solid var(--border)}
.legacy-ui .table thead th{color:var(--muted);font-weight:500;background:#fafafa}
.legacy-ui .table tr:hover td{background:#fafafa}
.legacy-ui .form-group{margin-bottom:12px}
.legacy-ui label{display:block;margin-bottom:6px;color:var(--muted);font-size:14px}
.legacy-ui input[type="text"],.legacy-ui input[type="number"],.legacy-ui input[type="email"],.legacy-ui input[type="password"],.legacy-ui textarea,.legacy-ui select{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:#fff}
.legacy-ui textarea{min-height:120px}
.legacy-ui .actions{margin-top:16px}
.legacy-ui .flash{padding:10px 14px;border-radius:10px;margin-bottom:12px}
.legacy-ui .notice{background:#ecfdf5;color:#065f46}
.legacy-ui .alert{background:#fef3c7;color:#92400e}

/* Admin Form Styles for Tailwind compatibility */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
  padding: 0.625rem 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background-color: #fff;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #1f2937;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* Dark mode form inputs */
.dark input[type="text"],
.dark input[type="number"],
.dark input[type="email"],
.dark input[type="password"],
.dark input[type="tel"],
.dark input[type="url"],
.dark input[type="date"],
.dark input[type="datetime-local"],
.dark textarea,
.dark select {
  background-color: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

.dark input:focus,
.dark textarea:focus,
.dark select:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

/* Fix select dropdown arrow */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.dark select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}

/* Placeholder styling */
input::placeholder,
textarea::placeholder {
  color: #9ca3af;
}

.dark input::placeholder,
.dark textarea::placeholder {
  color: #6b7280;
}

/* Bulk notify modal (avoid relying on Tailwind utilities) */
.bulk-notify-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow-y: auto;
}

.bulk-notify-modal__viewport {
  min-height: 100vh;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bulk-notify-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(107, 114, 128, 0.75);
}

.bulk-notify-modal__card {
  position: relative;
  width: 100%;
  max-width: 28rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.bulk-notify-modal__body {
  padding: 16px;
}

.bulk-notify-modal__footer {
  padding: 12px 16px;
  background: #f9fafb;
  display: grid;
  gap: 8px;
}

.bulk-notify-modal__primary,
.bulk-notify-modal__secondary {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.bulk-notify-modal__primary {
  border: 1px solid transparent;
  background: #4f46e5;
  color: #fff;
}

.bulk-notify-modal__primary:hover {
  background: #4338ca;
}

.bulk-notify-modal__secondary {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
}

.bulk-notify-modal__secondary:hover {
  background: #f9fafb;
}

.dark .bulk-notify-modal__card {
  background: #111827;
}

.dark .bulk-notify-modal__footer {
  background: rgba(17, 24, 39, 0.6);
}

.bulk-notify-form {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.bulk-notify-form__row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: start;
}

.bulk-notify-form__label {
  padding-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-align: right;
  white-space: nowrap;
}

.bulk-notify-form__control input,
.bulk-notify-form__control textarea {
  width: 100%;
}

.dark .bulk-notify-form__label {
  color: #e5e7eb;
}

/* Notes modal */
.notes-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow-y: auto;
}

.notes-modal__viewport {
  min-height: 100vh;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notes-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(107, 114, 128, 0.75);
}

.notes-modal__card {
  position: relative;
  width: 100%;
  max-width: 32rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.notes-modal__body {
  padding: 16px;
}

.notes-modal__footer {
  padding: 12px 16px;
  background: #f9fafb;
  display: grid;
  gap: 8px;
}

.notes-modal__primary,
.notes-modal__secondary {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.notes-modal__primary {
  border: 1px solid transparent;
  background: #4f46e5;
  color: #fff;
}

.notes-modal__primary:hover {
  background: #4338ca;
}

.notes-modal__secondary {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
}

.notes-modal__secondary:hover {
  background: #f9fafb;
}

.dark .notes-modal__card {
  background: #111827;
}

.dark .notes-modal__footer {
  background: rgba(17, 24, 39, 0.6);
}

/* Notification drawer */
.notification-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.notification-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
}

.notification-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(720px, 92vw);
  background: #fff;
  box-shadow: -10px 0 25px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
}

.notification-drawer__header {
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notification-drawer__close {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.notification-drawer__close:hover {
  background: #f9fafb;
}

.notification-drawer__content {
  flex: 1;
  overflow: auto;
}

.dark .notification-drawer__panel {
  background: #111827;
}

.dark .notification-drawer__header {
  border-bottom-color: #374151;
}

/* Modern admin system */
:root {
  --admin-accent: #2457ff;
  --admin-accent-strong: #173ec9;
  --admin-highlight: #0ea5e9;
  --admin-success: #15803d;
  --admin-danger: #e11d48;
  --admin-ink: #162033;
  --admin-muted: #6b7890;
  --admin-line: rgba(148, 163, 184, 0.24);
  --admin-line-strong: rgba(148, 163, 184, 0.38);
  --admin-panel-shadow: 0 22px 60px -42px rgba(15, 23, 42, 0.32), 0 16px 28px -24px rgba(37, 99, 235, 0.12);
}

body.admin-shell {
  color: var(--admin-ink);
  font-family: "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}

body.admin-shell::before,
body.admin-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body.admin-shell::before {
  background-image:
    radial-gradient(circle at top left, rgba(37, 87, 255, 0.12), transparent 34%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.1), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(248, 250, 252, 0));
}

body.admin-shell::after {
  inset: auto 5% 12% auto;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.08), transparent 62%);
  filter: blur(8px);
}

.admin-layout,
.admin-main,
.admin-sidebar,
.admin-topbar,
.admin-content,
.admin-page {
  position: relative;
  z-index: 1;
}

.admin-page {
  display: grid;
  gap: 24px;
  align-content: start;
}

.admin-sidebar {
  box-shadow: 18px 0 44px -36px rgba(15, 23, 42, 0.4);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 252, 0.92));
}

.admin-sidebar__brand {
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(135deg, rgba(36, 87, 255, 0.09), rgba(14, 165, 233, 0.04) 68%, transparent);
}

.admin-sidebar__brand::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(36, 87, 255, 0.3), rgba(148, 163, 184, 0.08), transparent);
}

.admin-sidebar__nav {
  scrollbar-width: thin;
}

.admin-topbar {
  backdrop-filter: blur(18px);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.78));
  box-shadow: 0 18px 50px -42px rgba(15, 23, 42, 0.28);
}

.admin-content::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 180px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(36, 87, 255, 0.08), rgba(14, 165, 233, 0.04) 48%, transparent 78%);
  pointer-events: none;
}

.admin-panel {
  position: relative;
  border-color: var(--admin-line);
  box-shadow: var(--admin-panel-shadow);
}

.admin-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(36, 87, 255, 0.55), rgba(14, 165, 233, 0.18), transparent 70%);
  opacity: 0.8;
}

.admin-panel__header {
  position: relative;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(36, 87, 255, 0.035) 40%, rgba(14, 165, 233, 0.05) 100%);
}

.admin-panel__title {
  font-size: 1.04rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.admin-panel__subtitle {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--admin-muted);
}

.admin-filter-panel {
  box-shadow: var(--admin-panel-shadow);
}

.admin-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.admin-filter-actions,
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.admin-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.88));
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.admin-table thead th {
  position: relative;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.admin-table thead th::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.28), rgba(148, 163, 184, 0.08));
}

.admin-table tbody td {
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover td {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.94), rgba(241, 245, 249, 0.82));
}

.admin-empty-state {
  position: relative;
  padding: 56px 24px;
  background-image: radial-gradient(circle at top center, rgba(36, 87, 255, 0.08), transparent 42%);
}

.admin-empty-state__title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.admin-btn:hover {
  transform: translateY(-1px);
}

.admin-btn--compact {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
}

.admin-btn--primary {
  color: #fff;
  background: linear-gradient(135deg, #2457ff, #3b82f6 56%, #0ea5e9);
  box-shadow: 0 18px 24px -18px rgba(36, 87, 255, 0.62);
}

.admin-btn--secondary {
  color: #334155;
  border-color: rgba(148, 163, 184, 0.34);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
  box-shadow: 0 10px 22px -22px rgba(15, 23, 42, 0.4);
}

.admin-btn--success {
  color: #fff;
  background: linear-gradient(135deg, #16a34a, #15803d);
  box-shadow: 0 16px 24px -18px rgba(21, 128, 61, 0.58);
}

.admin-btn--danger {
  color: #fff;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  box-shadow: 0 16px 24px -18px rgba(225, 29, 72, 0.5);
}

.admin-btn--slate {
  color: #fff;
  background: linear-gradient(135deg, #475569, #334155);
  box-shadow: 0 16px 24px -18px rgba(51, 65, 85, 0.45);
}

.admin-btn[disabled] {
  transform: none;
  opacity: 0.56;
  cursor: not-allowed;
}

.admin-link-action,
button.admin-link-action {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--admin-accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.admin-link-action:hover,
button.admin-link-action:hover {
  color: var(--admin-accent-strong);
}

.admin-link-danger,
button.admin-link-danger {
  color: var(--admin-danger);
}

.admin-link-danger:hover,
button.admin-link-danger:hover {
  color: #be123c;
}

.admin-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.admin-inline-divider {
  color: #cbd5e1;
}

.admin-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #3357d8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.admin-back-link:hover {
  color: #1d37a8;
}

body.admin-shell form.button_to {
  display: inline-block;
  margin: 0;
}

body.admin-shell input[type="text"],
body.admin-shell input[type="number"],
body.admin-shell input[type="email"],
body.admin-shell input[type="password"],
body.admin-shell input[type="tel"],
body.admin-shell input[type="url"],
body.admin-shell input[type="date"],
body.admin-shell input[type="datetime-local"],
body.admin-shell textarea,
body.admin-shell select {
  min-height: 44px;
  padding: 0.72rem 0.95rem;
  border-radius: 14px;
  border-color: rgba(148, 163, 184, 0.4);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 1px 2px rgba(15, 23, 42, 0.03);
}

body.admin-shell textarea {
  min-height: 120px;
}

body.admin-shell input:focus,
body.admin-shell textarea:focus,
body.admin-shell select:focus {
  border-color: rgba(36, 87, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(36, 87, 255, 0.12), 0 14px 24px -22px rgba(36, 87, 255, 0.55);
}

body.admin-shell input[type="checkbox"],
body.admin-shell input[type="radio"] {
  accent-color: var(--admin-accent);
}

body.admin-shell select {
  padding-right: 2.9rem;
}

body.admin-shell .pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

body.admin-shell .pagination a,
body.admin-shell .pagination span,
body.admin-shell .pagination em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.95);
  color: #475569;
  font-size: 13px;
  font-style: normal;
  text-decoration: none;
}

body.admin-shell .pagination .current {
  border-color: rgba(36, 87, 255, 0.3);
  background: linear-gradient(135deg, rgba(36, 87, 255, 0.14), rgba(14, 165, 233, 0.1));
  color: var(--admin-accent-strong);
  font-weight: 700;
}

.dark body.admin-shell,
.dark body.admin-shell input,
.dark body.admin-shell textarea,
.dark body.admin-shell select {
  color: #e5eefb;
}

.dark .admin-sidebar {
  background-image: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.92));
  box-shadow: 18px 0 44px -36px rgba(2, 6, 23, 0.9);
}

.dark .admin-topbar {
  background-image: linear-gradient(180deg, rgba(17, 24, 39, 0.9), rgba(17, 24, 39, 0.8));
}

.dark .admin-panel {
  border-color: rgba(71, 85, 105, 0.45);
  box-shadow: 0 24px 60px -44px rgba(2, 6, 23, 0.88);
}

.dark .admin-panel__header {
  background-image: linear-gradient(135deg, rgba(17, 24, 39, 0.88), rgba(36, 87, 255, 0.08) 42%, rgba(14, 165, 233, 0.08) 100%);
}

.dark .admin-table tbody td {
  border-bottom-color: rgba(51, 65, 85, 0.9);
}

.dark .admin-table tbody tr:hover td {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.9), rgba(30, 41, 59, 0.72));
}

.dark .admin-metric-chip {
  border-color: rgba(71, 85, 105, 0.45);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
  color: #cbd5e1;
}

.dark body.admin-shell input[type="text"],
.dark body.admin-shell input[type="number"],
.dark body.admin-shell input[type="email"],
.dark body.admin-shell input[type="password"],
.dark body.admin-shell input[type="tel"],
.dark body.admin-shell input[type="url"],
.dark body.admin-shell input[type="date"],
.dark body.admin-shell input[type="datetime-local"],
.dark body.admin-shell textarea,
.dark body.admin-shell select {
  border-color: rgba(100, 116, 139, 0.48);
  background-image: linear-gradient(180deg, rgba(51, 65, 85, 0.94), rgba(30, 41, 59, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

@media (max-width: 1200px) {
  .admin-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
