:root {
  --abt-red: #c81824;
  --abt-deep: #52050a;
  --abt-wine: #82121d;
  --abt-gold: #f0c56c;
  --abt-ink: #211f20;
  --abt-muted: #6f6966;
  --abt-paper: #f8f3eb;
  --abt-line: #ddd3c8;
  --abt-white: #fff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--abt-ink);
  background: var(--abt-paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--abt-paper); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.portal-header {
  min-height: 86px;
  padding: 18px clamp(20px, 5vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--abt-line);
  background: rgba(255,255,255,.92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.portal-header img { width: 206px; height: auto; display: block; }
.portal-header nav { display: flex; align-items: center; gap: 18px; font-weight: 700; }
.portal-header nav a { text-decoration: none; }

.portal-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 84px;
}

.portal-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr); gap: 28px; align-items: start; }
.portal-card {
  background: var(--abt-white);
  border: 1px solid var(--abt-line);
  border-radius: 18px;
  box-shadow: 0 18px 56px rgba(69, 38, 25, .09);
  overflow: hidden;
}
.portal-card-body { padding: clamp(22px, 4vw, 42px); }
.portal-card + .portal-card { margin-top: 20px; }

.portal-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--abt-wine);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.portal-kicker::before { content: ""; width: 34px; height: 2px; background: var(--abt-red); }
.portal-title { margin: 15px 0 10px; font-size: clamp(32px, 4.7vw, 58px); line-height: 1.02; letter-spacing: -.035em; }
.portal-lead { margin: 0; color: var(--abt-muted); font-size: 18px; line-height: 1.65; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 28px; }
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 14px; font-weight: 800; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid #cfc4ba;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  color: var(--abt-ink);
  outline: none;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--abt-red); box-shadow: 0 0 0 3px rgba(200,24,36,.12); }
.field-help { font-size: 12px; color: var(--abt-muted); }
.check-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; }
.check-row input { margin-top: 3px; accent-color: var(--abt-red); }

.invoice-fields { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px; border: 1px dashed #c9b8aa; border-radius: 12px; background: #fbf8f4; }

.payment-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 20px; }
.payment-choice { position: relative; }
.payment-choice input { position: absolute; opacity: 0; pointer-events: none; }
.payment-choice span {
  min-height: 92px;
  border: 1px solid var(--abt-line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  gap: 4px;
  text-align: center;
  padding: 12px;
  cursor: pointer;
  background: #fff;
}
.payment-choice b { font-size: 19px; }
.payment-choice small { color: var(--abt-muted); }
.payment-choice input:checked + span { border: 2px solid var(--abt-red); background: #fff6f5; box-shadow: 0 0 0 3px rgba(200,24,36,.08); }

.button {
  border: 0;
  border-radius: 10px;
  min-height: 52px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 900;
  cursor: pointer;
}
.button-primary { background: var(--abt-red); color: #fff; box-shadow: 0 13px 30px rgba(200,24,36,.22); }
.button-dark { background: var(--abt-ink); color: #fff; }
.button-ghost { background: transparent; color: var(--abt-ink); border: 1px solid var(--abt-line); }
.button-gold { background: var(--abt-gold); color: #2b1404; }
.button:disabled { opacity: .55; cursor: wait; }
.button-block { width: 100%; margin-top: 22px; }

.order-summary { position: sticky; top: 112px; }
.summary-cover { min-height: 230px; padding: 28px; color: #fff; background: radial-gradient(circle at 86% 16%, rgba(240,197,108,.35), transparent 28%), linear-gradient(135deg, var(--abt-deep), var(--abt-red)); display: flex; align-items: flex-end; }
.summary-cover h2 { margin: 0; font-size: 34px; line-height: 1.05; }
.summary-line { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid #ece5df; }
.summary-line:last-child { border: 0; }
.summary-line span { color: var(--abt-muted); }
.summary-price { font-size: 31px; color: var(--abt-red); font-weight: 900; }
.summary-benefits { padding: 0; margin: 24px 0 0; list-style: none; display: grid; gap: 13px; }
.summary-benefits li { display: flex; gap: 10px; line-height: 1.45; }
.summary-benefits li::before { content: "✓"; color: var(--abt-red); font-weight: 900; }

.payment-panel { margin-top: 24px; padding: clamp(18px, 4vw, 28px); border: 1px solid var(--abt-line); border-radius: 16px; background: #fbf8f4; text-align: center; }
.payment-panel h2 { margin: 0 0 8px; font-size: clamp(24px, 4vw, 34px); line-height: 1.08; }
.payment-panel p { margin: 0 auto 18px; max-width: 520px; color: var(--abt-muted); line-height: 1.5; }
.payment-qr { display: block; width: min(430px, 100%); max-height: 620px; margin: 0 auto; object-fit: contain; border-radius: 14px; background: #fff; }
.payment-details { max-width: 520px; margin: 18px auto 0; text-align: left; }
.transfer-note { margin-top: 20px; padding: 18px; border: 2px solid var(--abt-red); border-radius: 12px; background: #fff6f5; text-align: center; }
.transfer-note span, .transfer-note small { display: block; }
.transfer-note span { color: var(--abt-muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.transfer-note strong { display: block; margin: 7px 0; color: var(--abt-red); font-size: clamp(26px, 6vw, 38px); letter-spacing: .05em; }
.transfer-note small { color: var(--abt-muted); line-height: 1.45; }
.proof-upload { margin-top: 24px; padding: clamp(20px, 4vw, 30px); border-radius: 16px; background: #f4eee8; }
.proof-upload h2 { margin: 0 0 8px; font-size: clamp(24px, 4vw, 34px); line-height: 1.1; }
.proof-upload > p { margin: 0 0 20px; color: var(--abt-muted); line-height: 1.55; }
.proof-upload form { display: grid; gap: 16px; }
.proof-upload .button-block { margin-top: 0; }

.notice { border-radius: 10px; padding: 14px 16px; line-height: 1.5; margin: 18px 0; }
.notice-info { background: #edf4ff; color: #214875; }
.notice-success { background: #eaf8ef; color: #176638; }
.notice-error { background: #fff0f0; color: #9b111a; }

.auth-wrap { min-height: calc(100vh - 87px); display: grid; place-items: center; padding: 42px 20px; }
.auth-card { width: min(520px, 100%); }
.auth-card .portal-card-body { padding: clamp(26px, 6vw, 50px); }
.auth-card h1 { margin: 12px 0; font-size: 42px; line-height: 1.02; }
.auth-card form { display: grid; gap: 16px; margin-top: 28px; }

.library-head { padding: 42px; color: #fff; border-radius: 18px; background: radial-gradient(circle at 80% 20%, rgba(240,197,108,.4), transparent 26%), linear-gradient(130deg, var(--abt-deep), var(--abt-red)); }
.library-head h1 { font-size: clamp(38px, 5vw, 68px); line-height: 1; margin: 12px 0; }
.library-head p { margin: 0; max-width: 720px; line-height: 1.6; color: #f3dddd; }
.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 28px; }
.library-book { background: #fff; border: 1px solid var(--abt-line); border-radius: 16px; overflow: hidden; }
.library-book img { width: 100%; aspect-ratio: 4/3; object-fit: cover; object-position: top; display: block; background: #eee; }
.library-book div { padding: 22px; }
.library-book h2 { margin: 0 0 8px; font-size: 24px; }
.library-book p { color: var(--abt-muted); line-height: 1.5; min-height: 48px; }
.benefit-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(240px,360px); gap: 28px; align-items: center; }
.benefit-grid img { width: 100%; max-height: 430px; object-fit: contain; border-radius: 14px; border: 1px solid var(--abt-line); }

.admin-shell { width: min(1380px, calc(100% - 34px)); margin: 0 auto; padding: 34px 0 74px; }
.admin-top { display: flex; justify-content: space-between; gap: 22px; align-items: flex-end; margin-bottom: 24px; }
.admin-top h1 { margin: 6px 0 0; font-size: 44px; }
.admin-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-tools input, .admin-tools select { min-height: 44px; padding: 0 12px; border: 1px solid var(--abt-line); border-radius: 9px; background: #fff; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 20px; border: 1px solid var(--abt-line); border-radius: 13px; background: #fff; }
.stat-card strong { display: block; font-size: 32px; margin-top: 4px; }
.stat-card span { color: var(--abt-muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.orders-table-wrap { overflow: auto; border: 1px solid var(--abt-line); border-radius: 14px; background: #fff; }
.orders-table { width: 100%; border-collapse: collapse; min-width: 1060px; }
.orders-table th, .orders-table td { padding: 14px 15px; text-align: left; border-bottom: 1px solid #eee8e2; vertical-align: top; }
.orders-table th { position: sticky; top: 0; background: #f4eee8; font-size: 12px; letter-spacing: .07em; text-transform: uppercase; z-index: 2; }
.orders-table td small { display: block; color: var(--abt-muted); margin-top: 4px; line-height: 1.35; }
.status { display: inline-flex; border-radius: 999px; padding: 6px 9px; font-size: 12px; font-weight: 900; }
.status-awaiting_payment { color: #8a5300; background: #fff2cf; }
.status-payment_submitted { color: #805200; background: #ffdf9b; }
.status-access_issued { color: #135f36; background: #e4f7ec; }
.status-paid { color: #135f36; background: #e4f7ec; }
.status-cancelled { color: #777; background: #eee; }
.table-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.mini-button { border: 1px solid var(--abt-line); border-radius: 7px; background: #fff; min-height: 36px; padding: 0 10px; font-weight: 800; cursor: pointer; }
.mini-button.primary { color: #fff; background: var(--abt-red); border-color: var(--abt-red); }

.result-panel { margin-top: 20px; padding: 20px; background: #f6f2ee; border-radius: 12px; }
.result-panel textarea { width: 100%; min-height: 150px; padding: 14px; border: 1px solid var(--abt-line); border-radius: 8px; background: #fff; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.reader-body { background: #221b1b; color: #fff; overflow: hidden; }
.reader-app { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.reader-toolbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; background: #111; border-bottom: 1px solid #3b3434; }
.reader-toolbar h1 { margin: 0; font-size: 18px; }
.reader-toolbar p { margin: 3px 0 0; color: #aaa; font-size: 13px; }
.reader-toolbar-actions { display: flex; align-items: center; gap: 10px; }
.reader-toolbar-actions .button { color: #fff; border-color: #5b5252; }
.reader-canvas { position: relative; overflow: auto; display: grid; place-items: start center; padding: 0; background: #181414; }
.reader-page-wrap { position: relative; width: 100%; min-height: 100%; display: grid; place-items: start center; }
.reader-page { width: 100%; max-width: none; height: auto; display: block; user-select: none; -webkit-user-drag: none; background: #fff; }
.reader-watermark { position: absolute; inset: 0; overflow: hidden; pointer-events: none; opacity: .15; display: grid; grid-template-columns: repeat(3, 1fr); align-content: space-around; transform: rotate(-20deg) scale(1.15); }
.reader-watermark span { color: #8d0c15; font-weight: 900; text-align: center; font-size: clamp(12px, 2vw, 22px); white-space: nowrap; }
.reader-controls { min-height: 70px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px; background: #111; border-top: 1px solid #3b3434; }
.reader-controls input { width: 74px; min-height: 42px; border-radius: 8px; border: 1px solid #504848; background: #211d1d; color: #fff; text-align: center; }
.reader-controls .button { min-height: 42px; padding: 0 17px; }

@media (max-width: 880px) {
  .portal-grid { grid-template-columns: 1fr; }
  .order-summary { position: static; grid-row: 1; }
  .book-grid { grid-template-columns: 1fr; }
  .benefit-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-top { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .portal-header { min-height: 70px; padding: 13px 18px; }
  .portal-header img { width: 160px; }
  .portal-header nav a:not(:last-child) { display: none; }
  .portal-main { width: min(100% - 24px, 1180px); padding: 28px 0 60px; }
  .form-grid, .invoice-fields { grid-template-columns: 1fr; }
  .payment-choices { grid-template-columns: 1fr; }
  .payment-choice span { min-height: 70px; grid-template-columns: auto 1fr; text-align: left; }
  .stats-grid { grid-template-columns: 1fr; }
  .reader-toolbar { padding: 10px 12px; }
  .reader-toolbar .button { padding: 0 12px; }
  .reader-toolbar-actions { gap: 6px; }
  .reader-toolbar-actions .button { font-size: 12px; }
}
