:root {
  --bg: #edf2fa;
  --bg-accent: #d9e3f5;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --ink: #080808;
  --muted: #49556d;
  --line: rgba(19, 54, 122, 0.14);
  --accent: #12367a;
  --accent-deep: #0a1e49;
  --accent-soft: #e5ebf8;
  --brand-red: #c8102e;
  --brand-red-deep: #9e0d25;
  --shadow: 0 24px 60px rgba(12, 24, 52, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(200, 16, 46, 0.1), transparent 24%),
    radial-gradient(circle at top right, rgba(18, 54, 122, 0.14), transparent 30%),
    linear-gradient(180deg, #f8faff 0%, #e7eef8 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(23, 34, 32, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 34, 32, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.32), transparent 78%);
  pointer-events: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h3,
strong {
  font-weight: 700;
}

h2 {
  margin-bottom: 16px;
  font-family: "Instrument Serif", serif;
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  font-weight: 400;
  line-height: 0.95;
}

.app-shell {
  width: min(1320px, calc(100% - 28px));
  margin: 18px auto;
  padding-bottom: 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: min(1320px, calc(100% - 28px));
  margin: 0 auto;
  gap: 24px;
}

.hero-card,
.admin-card,
.admin-stat-card,
.payment-summary {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand-block {
  display: grid;
  gap: 14px;
}

.brand-block-horizontal {
  grid-template-columns: minmax(180px, 240px) auto;
  align-items: center;
}

.brand-logo {
  width: 100%;
  max-width: 240px;
  height: auto;
  display: block;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.hero-logo {
  width: min(100%, 480px);
  height: auto;
  display: block;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.top-nav a,
.top-nav-button,
.button {
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.top-nav a,
.top-nav-button {
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(18, 54, 122, 0.12);
}

.top-nav a {
  text-decoration: none;
}

.top-nav-button {
  font: inherit;
  cursor: pointer;
}

.top-nav a:hover,
.top-nav-button:hover,
.button:hover {
  transform: translateY(-1px);
}

.main-panel {
  display: grid;
  gap: 24px;
}

.hero-card,
.admin-card {
  padding: 24px;
  border-radius: 28px;
}

.pill,
.panel-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.pill {
  margin-bottom: 18px;
  color: var(--accent-deep);
  background: rgba(18, 54, 122, 0.08);
}

.statement-line,
.summary-line,
.invoice-meta,
.payment-summary,
.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.stats-grid,
.panel-head,
.action-row,
.summary-top,
.hero-layout {
  display: flex;
}

.hero-layout {
  gap: 24px;
  align-items: stretch;
}

.hero-layout > * {
  flex: 1 1 0;
}

.panel-head,
.action-row,
.summary-top {
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-tag {
  color: var(--accent-deep);
  background: rgba(18, 54, 122, 0.08);
  border: 1px solid var(--line);
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 0.94rem;
  font-weight: 500;
}

input,
textarea,
select,
.button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  font: inherit;
}

input,
textarea,
select {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.72);
}

textarea {
  resize: vertical;
}

.button {
  min-height: 48px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--brand-red), var(--accent));
}

.button-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.button-small {
  max-width: 220px;
}

.full-width {
  grid-column: 1 / -1;
}

.hero-pay-card {
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(18, 54, 122, 0.08), rgba(255, 255, 255, 0.96)),
    linear-gradient(180deg, rgba(200, 16, 46, 0.05), transparent);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

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

.admin-header,
.admin-stats,
.admin-grid {
  display: grid;
  gap: 20px;
}

.admin-header {
  grid-template-columns: 1fr;
  align-items: end;
}

.admin-actions-menu {
  position: relative;
}

.admin-actions-menu summary {
  list-style: none;
}

.top-nav .admin-actions-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
}

.admin-actions-menu summary::-webkit-details-marker {
  display: none;
}

.admin-actions-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(18, 54, 122, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  z-index: 20;
}

.admin-actions-link {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(18, 54, 122, 0.06);
}

.admin-actions-link:hover {
  background: rgba(18, 54, 122, 0.12);
}

.admin-actions-button {
  width: 100%;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-stat-card {
  padding: 20px;
  border-radius: 24px;
}

.admin-stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.admin-stat-card strong {
  font-size: 1.8rem;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-list {
  display: grid;
  gap: 14px;
}

#invoiceList {
  max-height: 430px;
  overflow-y: auto;
  padding-right: 8px;
}

.admin-list-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.admin-list-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.admin-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.admin-list-button {
  width: auto;
  min-height: 38px;
  padding: 0 14px;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-pill.open {
  color: var(--brand-red-deep);
  background: rgba(200, 16, 46, 0.12);
}

.status-pill.partial {
  color: #8a5a00;
  background: rgba(245, 158, 11, 0.18);
}

.status-pill.paid {
  color: var(--accent-deep);
  background: rgba(18, 54, 122, 0.12);
}

.lookup-grid,
.quick-pay-grid {
  grid-template-columns: 1fr;
}
.summary-top {
  margin-bottom: 12px;
}

.payment-summary {
  margin-top: 18px;
  margin-bottom: 28px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(255, 255, 255, 0.94));
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 8, 8, 0.5);
}

.admin-modal {
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(18, 54, 122, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.login-error {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(200, 16, 46, 0.18);
  background: rgba(200, 16, 46, 0.08);
  color: var(--brand-red-deep);
  font-size: 0.92rem;
  font-weight: 500;
}

@media (max-width: 1080px) {
  .topbar {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-layout {
    flex-direction: column;
  }

  .admin-header,
  .admin-stats,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .top-nav {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 1000px);
  }

  .hero-card,
  .admin-card,
  .admin-stat-card {
    padding: 18px;
  }

  .brand-block-horizontal {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
