:root {
    --bg: #f1f1f1;
    --card: #fff;
    --text: #303030;
    --muted: #616161;
    --border: #dedede;
    --blue: #1d49c3;
    --blue-dark: #143ba8;
    --blue-soft: #e8efff;
    --navy: #0f144e;
    --green: #16794a;
    --green-soft: #e7f5ed;
    --amber: #8a5b00;
    --amber-soft: #fff3d6;
    --red: #a02c1d;
    --red-soft: #fceae7;
    --shadow: 0 1px 2px rgba(20, 25, 45, .06), 0 8px 30px rgba(20, 25, 45, .05);
    --radius: 12px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand img { display: block; width: 142px; height: auto; }
.brand span { padding-left: 11px; border-left: 1px solid var(--border); color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 8px; padding: 8px 15px; border: 1px solid transparent; border-radius: 8px; font-size: 14px; font-weight: 700; transition: background .15s, border .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .6; }
.button--primary { background: var(--blue); color: white; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.button--primary:hover:not(:disabled) { background: var(--blue-dark); }
.button--secondary { border-color: #c9c9c9; background: white; color: var(--text); }
.button--secondary:hover { background: #f8f8f8; }
.button--large { width: 100%; min-height: 49px; padding: 12px 18px; font-size: 15px; }
.icon-button { display: inline-grid; width: 36px; height: 36px; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: white; color: var(--text); font-size: 19px; }
.icon-button:hover { background: #f7f7f7; }

/* Customer checkout */
.checkout-body { display: flex; flex-direction: column; background: radial-gradient(circle at 50% -20%, #fff 0, #f4f6fb 38%, var(--bg) 72%); }
.checkout-header { display: flex; width: min(1100px, calc(100% - 40px)); min-height: 82px; align-items: center; justify-content: space-between; margin: 0 auto; border-bottom: 1px solid rgba(222, 222, 222, .8); }
.secure-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.secure-label span { color: var(--green); font-size: 8px; }
.checkout-header-status { display: flex; align-items: center; gap: 13px; }
.sandbox-badge { display: inline-flex; min-height: 25px; align-items: center; padding: 4px 9px; border: 1px solid #e7b652; border-radius: 999px; background: #fff5d8; color: #815600; font-size: 9px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.sandbox-notice { display: grid; gap: 3px; margin-bottom: 23px; padding: 12px 13px; border: 1px solid #edca80; border-radius: 8px; background: #fff8e8; color: #76500b; }
.sandbox-notice strong { font-size: 11px; }
.sandbox-notice span { font-size: 10px; line-height: 1.5; }
.checkout-main { display: grid; width: min(1040px, calc(100% - 40px)); flex: 1; place-items: center; margin: 48px auto; }
.checkout-grid { display: grid; width: 100%; overflow: hidden; grid-template-columns: 1.05fr .95fr; border: 1px solid var(--border); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.checkout-summary, .checkout-action { min-width: 0; padding: clamp(32px, 5vw, 58px); }
.checkout-summary { background: linear-gradient(155deg, #fff 0%, #f7f9ff 100%); border-right: 1px solid var(--border); }
.checkout-summary h1 { max-width: 480px; margin: 0; color: var(--navy); font-size: clamp(25px, 3vw, 36px); line-height: 1.18; letter-spacing: -.03em; }
.summary-reference { margin: 12px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.amount-block { margin: 46px 0 38px; }
.amount-block span, .amount-block small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.amount-block strong { display: inline-block; margin: 7px 7px 4px 0; color: var(--navy); font-size: clamp(36px, 5vw, 51px); line-height: 1; letter-spacing: -.04em; }
.amount-block small { display: inline; }
.summary-list { display: grid; margin: 0; gap: 12px; }
.summary-list div { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; font-weight: 700; overflow-wrap: anywhere; }
.checkout-action { display: flex; align-items: center; }
.payment-state { width: 100%; }
.payment-state h2, .state-card h1 { margin: 0; color: var(--navy); font-size: 24px; line-height: 1.28; letter-spacing: -.02em; }
.payment-state > p:not(.eyebrow), .state-card > p:not(.eyebrow) { margin: 12px 0 26px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.provider-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 23px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.shield { display: grid; width: 19px; height: 19px; flex: 0 0 19px; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 900; }
.state-icon { display: grid; width: 58px; height: 58px; place-items: center; margin-bottom: 25px; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 28px; font-weight: 800; }
.state-icon--success { background: var(--green-soft); color: var(--green); }
.state-icon--neutral { background: var(--blue-soft); color: var(--blue); }
.state-card { width: min(560px, 100%); padding: 48px; border: 1px solid var(--border); border-radius: 18px; background: white; box-shadow: var(--shadow); }
.checkout-footer { display: flex; width: min(1100px, calc(100% - 40px)); min-height: 70px; align-items: center; justify-content: space-between; margin: 0 auto; border-top: 1px solid rgba(222, 222, 222, .8); color: #777; font-size: 11px; }
.inline-loader { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Admin login */
.login-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(360px, .82fr) 1.18fr; }
.login-brand-panel { display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; padding: clamp(35px, 6vw, 78px); background: linear-gradient(155deg, #10164e, #182b78 70%, #1d49c3); color: white; }
.login-brand-panel .brand { align-self: flex-start; padding: 11px 14px; border-radius: 9px; background: white; }
.login-brand-panel h1 { max-width: 600px; margin: 0; font-size: clamp(35px, 4.5vw, 59px); line-height: 1.08; letter-spacing: -.045em; }
.login-brand-panel p:not(.eyebrow) { max-width: 560px; margin: 22px 0 0; color: rgba(255,255,255,.72); font-size: 16px; line-height: 1.7; }
.login-brand-panel .eyebrow { color: #9eb7ff; }
.login-brand-panel small { color: rgba(255,255,255,.55); }
.login-form-panel { display: grid; min-height: 100vh; place-items: center; padding: 30px; background: #f7f7f7; }
.login-card { display: grid; width: min(410px, 100%); gap: 22px; padding: 35px; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.login-card h2 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.login-card p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.field { display: grid; gap: 7px; }
.field span { font-size: 12px; font-weight: 700; }
.field input { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #bdbdbd; border-radius: 8px; background: white; color: var(--text); outline: none; }
.field input:focus, .search-field:focus-within, .select-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,73,195,.12); }
.form-error { padding: 10px 12px; border: 1px solid #f1beb7; border-radius: 7px; background: var(--red-soft); color: var(--red); font-size: 12px; }

/* Admin shell */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 242px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 20; display: flex; height: 100vh; flex-direction: column; gap: 28px; padding: 18px 13px 13px; border-right: 1px solid var(--border); background: #f7f7f7; }
.sidebar-brand { padding: 2px 5px 8px; }
.sidebar-brand img { width: 150px; }
.sidebar-nav { display: grid; gap: 7px; }
.sidebar-nav > p { margin: 0 8px 3px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.nav-link { display: flex; width: 100%; min-height: 40px; align-items: center; gap: 11px; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px; font-weight: 700; text-align: left; }
.nav-link:hover { background: #ededed; }
.nav-link.is-active { border-color: var(--border); background: white; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.nav-link span { display: grid; width: 20px; height: 20px; place-items: center; color: var(--blue); }
.sidebar-account { display: grid; grid-template-columns: 36px minmax(0, 1fr) 34px; align-items: center; gap: 9px; margin-top: auto; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: white; }
.sidebar-account .avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 7px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 800; }
.sidebar-account strong, .sidebar-account small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { font-size: 11px; }
.sidebar-account small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.sidebar-account .icon-button { width: 31px; height: 31px; border: 0; font-size: 16px; }
.admin-main { min-width: 0; padding: 30px clamp(22px, 3.2vw, 48px) 48px; }
.admin-sandbox-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 10px 13px; border: 1px solid #e7c36f; border-radius: 9px; background: #fff7df; color: #77530c; font-size: 10px; }
.admin-sandbox-banner strong { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; background: #f7df9e; font-size: 9px; text-transform: uppercase; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 25px; margin-bottom: 24px; }
.page-header h1 { margin: 0; font-size: 30px; letter-spacing: -.035em; }
.page-header p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.metric-card { display: grid; min-width: 0; grid-template-columns: 42px minmax(0, 1fr); gap: 13px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: 0 1px 1px rgba(0,0,0,.02); }
.metric-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 9px; font-size: 18px; font-weight: 800; }
.metric-icon--blue { background: var(--blue-soft); color: var(--blue); }
.metric-icon--green { background: var(--green-soft); color: var(--green); }
.metric-icon--amber { background: var(--amber-soft); color: var(--amber); }
.metric-icon--red { background: var(--red-soft); color: var(--red); }
.metric-card p { margin: 0 0 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-card strong { display: block; overflow: hidden; font-size: 22px; letter-spacing: -.03em; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { display: block; margin-top: 5px; color: #777; font-size: 9px; }
.table-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 13px; border-bottom: 1px solid var(--border); }
.search-field { display: flex; width: min(360px, 100%); min-height: 38px; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid #c9c9c9; border-radius: 8px; background: white; color: #777; }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--text); font-size: 12px; }
.select-field { display: flex; min-height: 38px; margin-left: auto; border: 1px solid #c9c9c9; border-radius: 8px; }
.select-field select { min-width: 145px; padding: 0 31px 0 11px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th { padding: 11px 13px; border-bottom: 1px solid var(--border); background: #fafafa; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .05em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 13px; border-bottom: 1px solid #ececec; vertical-align: middle; }
.data-table tbody tr:hover { background: #fbfbfb; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.cell-primary { display: block; max-width: 220px; overflow: hidden; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.cell-secondary { display: block; max-width: 220px; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; min-height: 23px; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; background: #efefef; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: capitalize; white-space: nowrap; }
.status-badge::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.status-badge--paid, .status-badge--delivered { background: var(--green-soft); color: var(--green); }
.status-badge--pending, .status-badge--authorized { background: var(--amber-soft); color: var(--amber); }
.status-badge--failed { background: var(--red-soft); color: var(--red); }
.status-badge--refunded, .status-badge--partially_refunded { background: var(--blue-soft); color: var(--blue); }
.table-message { height: 180px; color: var(--muted); text-align: center; }
.row-action { min-width: 29px; width: 29px; height: 29px; font-size: 16px; }
.pagination { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 13px; border-top: 1px solid var(--border); }
.pagination p, .pagination span { margin: 0; color: var(--muted); font-size: 10px; }
.pagination > div { display: flex; align-items: center; gap: 10px; }
.pagination .icon-button { width: 30px; height: 30px; }
.mobile-header { display: none; }
.sidebar-backdrop { display: none; }

/* Dialog and feedback */
.detail-dialog { width: min(650px, calc(100% - 28px)); max-height: min(85vh, 800px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: white; box-shadow: 0 24px 90px rgba(15,20,78,.25); color: var(--text); }
.detail-dialog::backdrop { background: rgba(15,20,40,.46); backdrop-filter: blur(2px); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); background: white; }
.dialog-header h2 { margin: 0; font-size: 20px; }
.detail-content { padding: 22px; overflow-y: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--border); }
.detail-item { min-width: 0; padding: 13px; background: white; }
.detail-item dt { margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.detail-item dd { margin: 0; overflow-wrap: anywhere; font-size: 11px; font-weight: 650; }
.detail-section { margin-top: 20px; }
.detail-section h3 { margin: 0 0 9px; font-size: 13px; }
.code-block { max-height: 180px; overflow: auto; margin: 0; padding: 13px; border-radius: 8px; background: #101526; color: #dce5ff; font: 10px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.webhook-panel { padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: #fafafa; }
.webhook-panel-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.webhook-panel p { margin: 8px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; overflow-wrap: anywhere; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(380px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid #b8dfc9; border-radius: 9px; background: #f0faf4; box-shadow: var(--shadow); color: var(--green); font-size: 12px; font-weight: 700; }
.toast.is-error { border-color: #efc0b9; background: #fff2f0; color: var(--red); }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .checkout-grid { grid-template-columns: 1fr; }
    .checkout-summary { border-right: 0; border-bottom: 1px solid var(--border); }
    .login-layout { grid-template-columns: 1fr; }
    .login-brand-panel { min-height: 340px; padding: 35px; }
    .login-brand-panel small { display: none; }
    .login-form-panel { min-height: auto; padding: 45px 20px; }
    .admin-shell { display: block; padding-top: 64px; }
    .mobile-header { position: fixed; inset: 0 0 auto; z-index: 25; display: flex; height: 64px; align-items: center; justify-content: space-between; padding: 10px 15px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.96); }
    .mobile-header img { width: 135px; }
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 88vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 12px 0 40px rgba(0,0,0,.12); }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; display: block; width: 100%; height: 100%; border: 0; background: rgba(0,0,0,.35); }
    .admin-main { padding: 24px 15px 35px; }
}
@media (max-width: 590px) {
    .checkout-header, .checkout-footer, .checkout-main { width: min(100% - 28px, 1040px); }
    .checkout-header { min-height: 70px; }
    .checkout-header .brand span { display: none; }
    .checkout-header .brand img { width: 125px; }
    .checkout-header-status { gap: 7px; }
    .sandbox-badge { padding-inline: 7px; font-size: 8px; }
    .secure-label { display: none; }
    .checkout-main { margin: 25px auto; align-items: start; }
    .checkout-summary, .checkout-action { padding: 28px 24px; }
    .amount-block { margin: 33px 0 28px; }
    .summary-list div { grid-template-columns: 85px minmax(0, 1fr); }
    .checkout-footer { flex-direction: column; justify-content: center; gap: 6px; }
    .login-brand-panel { min-height: 290px; }
    .login-brand-panel h1 { font-size: 32px; }
    .login-card { padding: 26px 22px; }
    .page-header { align-items: center; }
    .page-header p:not(.eyebrow) { display: none; }
    .metric-grid { grid-template-columns: 1fr; }
    .table-toolbar { align-items: stretch; flex-direction: column; }
    .search-field { width: 100%; }
    .select-field { margin-left: 0; }
    .select-field select { width: 100%; }
    .detail-grid { grid-template-columns: 1fr; }
}
