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

/* ===== Design tokens ===== */
:root {
  /* Backgrounds */
  --bg: #EEF2F9;
  --bg-primary: #EEF2F9;
  --card: #FFFFFF;
  --bg-card: #FFFFFF;
  --card2: #F5F8FC;
  --bg-hover: #F5F8FC;
  --bg-secondary: #F5F8FC;

  /* Text */
  --text: #0c1f4a;
  --text-primary: #0c1f4a;
  --muted: #7A88A3;
  --text-muted: #7A88A3;
  --faint: #A3AFC4;
  --text-faint: #A3AFC4;

  /* Structure */
  --border: #E6ECF5;
  --card-shadow: 0 1px 2px rgba(12,31,74,.04), 0 10px 28px -16px rgba(12,31,74,.18);
  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-badge: 100px;
  --sidebar-w: 224px;

  /* Accent */
  --accent: #0c1f4a;
  --accent-light: #16305E;
  --navy: #0c1f4a;
  --navy-hover: #16305E;
  --navy-light: #3D6FC4;
  --midnight: #071433;
  --signal: #3D6FC4;
  --ice: #A9C4F5;
  --violet: #7C3AED;
  --cyan: #38BDF8;
  --frame: rgba(148,163,184,.4);
  --glow: linear-gradient(90deg, #3D6FC4, #7C3AED 55%, #38BDF8);

  /* Status colors */
  --green: #16A34A;
  --green-dim: #DCFCE7;
  --blue: #2563EB;
  --blue-dim: #DBEAFE;
  --orange: #D97706;
  --orange-dim: #FEF3C7;
  --red: #DC2626;
  --red-dim: #FEE2E2;
  --gray-dim: #F1F5F9;
  --purple: #7C3AED;
  --purple-dim: #EDE9FE;
}

html, body { height: 100%; }

/* ===== Admin shell (from layouts/admin.blade.php) =====
   The sidebar and top bar sit on the same midnight aurora as the public
   pages; the workspace is a light panel framed inside it. */
body.admin-shell {
  background: var(--midnight);
  color: var(--text-primary);
  font-family: 'Geist', sans-serif;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
body.admin-shell::before {
  content: ""; position: fixed; inset: -20%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(30% 40% at 8% 20%, rgba(61,111,196,.55), transparent 70%),
    radial-gradient(30% 40% at 20% 95%, rgba(124,58,237,.35), transparent 70%),
    radial-gradient(40% 30% at 70% 0%, rgba(56,189,248,.18), transparent 70%),
    linear-gradient(160deg, #0c1f4a 0%, var(--midnight) 60%);
  animation: admin-drift 40s ease-in-out infinite alternate;
}
@keyframes admin-drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(3%, -2%, 0) rotate(3deg); }
}
body.admin-shell > * { position: relative; z-index: 1; }
body.admin-shell > .sidebar-overlay { position: fixed; z-index: 199; }

.shell { display: flex; flex: 1; overflow: hidden; position: relative; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100%;
  transition: transform .25s ease;
  z-index: 200;
}

.sidebar-brand {
  padding: 6px 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; }
.sidebar-brand .brand-name { font-weight: 700; font-size: .8rem; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-sub  { font-size: .7rem; color: rgba(255,255,255,.55); }

.sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; }

.nav-section-label {
  font-size: .72rem; font-weight: 600; color: rgba(255,255,255,.45);
  padding: 8px 14px 4px;
}
/* Faint divider between the menu groups, inset to line up with the menu text */
.nav-section-label:not(:first-child) {
  margin: 10px 14px 0; padding-left: 0; padding-right: 0;
  border-top: 1px solid rgba(255,255,255,.09);
}

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  color: rgba(255,255,255,.65); font-size: .875rem; font-weight: 500;
  transition: all .15s; text-decoration: none;
}
.nav-item:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; }
/* The portal's glow line, standing up, marks where you are */
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, #3D6FC4, #7C3AED 55%, #38BDF8); box-shadow: 0 0 10px rgba(124,58,237,.6);
}
.nav-item:focus-visible { outline: 2px solid var(--ice); outline-offset: 1px; }

.sidebar-footer { padding: 12px; flex-shrink: 0; }
.user-menu { position: relative; }
.user-btn {
  width: 100%; background: rgba(255,255,255,.08); border: none; cursor: pointer;
  border-radius: 8px; padding: 10px 14px; display: flex; align-items: center;
  gap: 10px; text-align: left;
}
.user-avatar {
  width: 30px; height: 30px; background: linear-gradient(135deg,#0c1f4a,#3D6FC4);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: .7rem; color: rgba(255,255,255,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-dropdown {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; z-index: 300; box-shadow: 0 8px 24px rgba(12,31,74,.15);
}
.user-dropdown.open { display: block; }
.user-dropdown a, .user-dropdown button {
  display: flex; align-items: center; gap: 9px; padding: 10px 14px;
  font-size: .82rem; color: var(--text-muted); text-decoration: none;
  background: none; border: none; width: 100%; cursor: pointer;
  font-family: 'Geist', sans-serif; transition: background .12s;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 2px 0; }

.main-area {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0;
  background: var(--bg-primary) padding-box;
  border: 3px solid var(--frame); border-right: 0; border-bottom: 0;
  border-top-left-radius: 22px;
  box-shadow: 0 -10px 60px -20px rgba(3,10,30,.6);
}

.topbar {
  background: transparent;
  padding: 0 24px 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* Logo above the menu column; the page title then lines up with the workspace */
.topbar-brand { width: calc(var(--sidebar-w) - 20px); flex-shrink: 0; display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.topbar-brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; }
.topbar-brand .brand-name { display: block; font-weight: 700; font-size: .84rem; line-height: 1.2; }
.topbar-brand .brand-sub  { display: block; font-size: .72rem; color: rgba(255,255,255,.55); }
.sidebar-brand { display: none; }
.topbar-icon-badge {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center;
}
.topbar-heading { min-width: 0; }
.topbar h1  { font-size: 1.15rem; font-weight: 700; letter-spacing: -.015em; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p   { font-size: .75rem; color: rgba(255,255,255,.65); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Header-action buttons need their own contrast on the now-navy topbar —
   the shared .btn-* classes are tuned for a light-background context. */
.topbar-actions .btn-primary { background: #fff; color: var(--navy); }
.topbar-actions .btn-primary:hover { background: #E8EFFB; box-shadow: 0 8px 22px -10px rgba(0,0,0,.6); transform: translateY(-1px); }
.topbar-actions .btn-secondary { color: rgba(255,255,255,.75); border-color: rgba(255,255,255,.2); }
.topbar-actions .btn-secondary:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar-actions .btn-danger { border-color: rgba(248,113,113,.4); }
.topbar-actions .btn-danger:hover { background: rgba(248,113,113,.15); }
.topbar-actions .btn-success { background: rgba(74,222,128,.18); border-color: rgba(74,222,128,.35); }
.topbar-actions .btn-success:hover { background: rgba(74,222,128,.28); }

.hamburger-btn {
  display: none;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px; padding: 7px 8px; cursor: pointer;
  color: rgba(255,255,255,.7); flex-shrink: 0;
}
.hamburger-btn:hover { color: #fff; }

.main-content { flex: 1; overflow-y: auto; padding: 28px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7,20,51,.55);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

.alert { border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; font-size: .875rem; }
.alert-success { background: var(--green-dim); border: 1px solid rgba(22,163,74,.25); color: var(--green); }
.alert-error   { background: var(--red-dim);   border: 1px solid rgba(220,38,38,.25); color: var(--red); }
.alert-warning  { background: var(--orange-dim);border: 1px solid rgba(217,119,6,.25); color: var(--orange); }

/* ── Component styles ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--card-shadow); }
/* A .portal-stub (portal.css) heading an admin card (after the void/draft watermark, if any) */
.card > .portal-stub { --card-pad: 24px; margin: 0; border-radius: calc(var(--radius-card) - 1px) calc(var(--radius-card) - 1px) 0 0; }
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 100px; font-size: .75rem; font-weight: 600; }
.badge-paid          { background: var(--green-dim);  color: var(--green); }
.badge-open          { background: var(--blue-dim);   color: var(--blue); }
.badge-draft         { background: var(--gray-dim);   color: var(--text-muted); }
.badge-void          { background: var(--red-dim);    color: var(--red); }
.badge-uncollectible,
.badge-overdue       { background: var(--orange-dim); color: var(--orange); }
.badge-refunded      { background: var(--purple-dim); color: var(--purple); }

.btn-primary   { background: var(--accent); color: #fff; padding: 9px 18px; border-radius: var(--radius-btn); font-size: .875rem; font-weight: 600; transition: all .15s; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border: none; text-decoration: none; font-family: 'Geist', sans-serif; }
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(12,31,74,.3); }
.btn-secondary { background: transparent; color: var(--text-muted); padding: 9px 18px; border-radius: var(--radius-btn); font-size: .875rem; font-weight: 500; border: 1px solid var(--border); transition: all .15s; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-family: 'Geist', sans-serif; }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger    { background: transparent; color: var(--red); padding: 9px 18px; border-radius: var(--radius-btn); font-size: .875rem; font-weight: 500; border: 1px solid rgba(220,38,38,.3); transition: all .15s; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-family: 'Geist', sans-serif; }
.btn-danger:hover { background: var(--red-dim); }
.btn-success   { background: rgba(22,163,74,.12); color: var(--green); padding: 9px 18px; border-radius: var(--radius-btn); font-size: .875rem; font-weight: 600; border: 1px solid rgba(22,163,74,.25); transition: all .15s; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-family: 'Geist', sans-serif; }
.btn-success:hover { background: rgba(22,163,74,.2); }
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible, .btn-success:focus-visible { outline: 3px solid var(--ice); outline-offset: 2px; }

.input-field, .form-input {
  background: var(--bg-primary); border: 1.5px solid #DCE3EF; border-radius: var(--radius-btn);
  color: var(--text-primary); padding: 10px 14px; font-size: .875rem;
  font-family: 'Geist', sans-serif; width: 100%; transition: border-color .15s;
  outline: none; box-sizing: border-box; -webkit-appearance: none; appearance: none;
}
.input-field:focus, .form-input:focus { border-color: var(--signal); background: #fff; box-shadow: 0 0 0 4px rgba(61,111,196,.18); }
.input-field::placeholder, .form-input::placeholder { color: var(--text-faint); }
select.input-field option, select.form-input option { background: var(--bg-card); }

.table-row { border-bottom: 1px solid var(--border); transition: background .1s; }
.table-row:hover { background: var(--bg-hover); }
.table-row:last-child { border-bottom: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.divider { border-top: 1px solid var(--border); }
/* Quiet "Copy link" under a link box */
.copy-link { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 2px 0; background: none; border: 0; font: 500 .72rem 'Geist', sans-serif; color: var(--text-faint); cursor: pointer; transition: color .15s; }
.copy-link:hover { color: var(--text-muted); }
.copy-link.is-copied { color: var(--green); }
.copy-link:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
/* Page layouts (admin views) — collapse to one column on small screens */
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.admin-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
.admin-cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.admin-cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.admin-settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
.admin-meta-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1180px) {
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .admin-split, .admin-cols-3, .admin-cols-2, .admin-settings { grid-template-columns: minmax(0, 1fr); }
  .admin-cols-3 > * { grid-column: auto !important; } /* children span 2 columns inline on desktop */
}
@media (max-width: 560px) {
  .admin-meta-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-meta-3 > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
  .admin-stats { grid-template-columns: minmax(0, 1fr); }
}

/* The few utility class names the admin views use (Tailwind isn't loaded) */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gap-4 { gap: 16px; }
.mb-5 { margin-bottom: 20px; }
@media (max-width: 560px) { .grid-cols-2 { grid-template-columns: minmax(0, 1fr); } }
.mono { }

@media (prefers-reduced-motion: reduce) {
  body.admin-shell::before { animation: none; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: rgba(12,31,74,.15); border-radius: 3px; }

@media (max-width: 860px) {
  body.admin-shell { overflow: auto; height: auto; min-height: 100vh; }
  .main-area { border-right: 3px solid var(--frame); border-top-right-radius: 22px; min-height: calc(100vh - 68px); }
  .shell { flex-direction: column; overflow: visible; height: auto; min-height: calc(100vh - 57px); }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    height: 100vh;
    padding-top: 14px;
    background: linear-gradient(170deg, #0c1f4a, var(--midnight) 70%);
    box-shadow: 4px 0 24px rgba(3,10,30,.45);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger-btn { display: flex; align-items: center; justify-content: center; }
  .topbar-brand { display: none; }
  .sidebar-brand { display: flex; }
  .main-area { width: 100%; }
  .main-content { padding: 18px 14px; }
  /* Header buttons get their own scrollable row under the title */
  .topbar { padding: 10px 14px; height: auto; min-height: 60px; flex-wrap: wrap; row-gap: 10px; }
  .topbar-left { flex: 1 1 auto; }
  .topbar-actions { flex: 1 1 100%; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .topbar-actions:empty { display: none; }
  .topbar-actions > * { flex-shrink: 0; }
  .topbar h1 { font-size: .9rem; }
  .topbar p  { display: none; }
}

/* Pagination (resources/views/vendor/pagination/admin.blade.php) */
.pager { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; font-size:13px; color:var(--text-muted); }
.pager-links { display:flex; gap:4px; }
.pager-btn { min-width:32px; height:32px; padding:0 10px; display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--border); border-radius:var(--radius-btn); background:var(--bg-card); color:var(--text-primary); text-decoration:none; font-size:13px; font-weight:500; }
a.pager-btn:hover { background:var(--bg-hover); }
.pager-btn.active { background:var(--accent); border-color:var(--accent); color:#fff; }
.pager-btn.disabled { color:var(--text-faint); }
