:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17151f;
  background: #f5f4f9;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 8px; color: #6d4ce8; font-size: 12px; font-weight: 900; letter-spacing: 1.3px; }
.eyebrow.light { color: #cfc8ff; }
.logo { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 22px; background: #fff; color: #6547d7; font-size: 34px; font-weight: 900; box-shadow: 0 14px 34px #24185933; }
.logo.small { width: 42px; height: 42px; border-radius: 14px; background: #6d4ce8; color: #fff; font-size: 21px; box-shadow: none; }
.button { min-height: 44px; padding: 0 17px; border: 0; border-radius: 13px; font-weight: 800; }
.button:disabled { cursor: wait; opacity: .55; }
.primary { width: 100%; color: #fff; background: #6d4ce8; }
.secondary { color: #5536c7; background: #eeeaff; }
.ghost { color: #56515f; background: #f0eef4; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; }
.login-brand { display: flex; flex-direction: column; justify-content: center; padding: 9vw; color: #fff; background: radial-gradient(circle at 15% 20%, #7662c9 0, transparent 30%), #241859; }
.login-brand h1 { max-width: 650px; margin: 26px 0 14px; font-size: clamp(38px, 5vw, 72px); line-height: .98; letter-spacing: -3px; }
.login-brand p:last-child { max-width: 540px; color: #cec8e7; line-height: 1.7; }
.login-card { width: min(430px, calc(100% - 48px)); margin: auto; padding: 34px; border: 1px solid #e4e1eb; border-radius: 26px; background: #fff; box-shadow: 0 22px 60px #31236114; }
.login-card h2 { margin: 0 0 28px; font-size: 29px; }
label { display: block; margin: 15px 0 7px; font-size: 13px; font-weight: 800; }
input, textarea, select { width: 100%; padding: 14px; border: 1px solid #dcd8e4; border-radius: 13px; background: #f8f7fa; outline: none; }
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus { border-color: #6d4ce8; box-shadow: 0 0 0 3px #6d4ce81a; }
.error { min-height: 22px; color: #b3403b; font-size: 13px; }
.security-note { color: #77717f; font-size: 12px; line-height: 1.5; text-align: center; }

.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 4vw; border-bottom: 1px solid #e2dfe8; background: #fff; }
.brand-row, .admin-user { display: flex; align-items: center; gap: 12px; }
.brand-row span { display: block; margin-top: 2px; color: #88828f; font-size: 11px; }
.admin-user span { color: #716b78; font-size: 13px; }
.page { width: min(1220px, calc(100% - 40px)); margin: 42px auto; }
.section-tabs { display: flex; gap: 8px; margin: -18px 0 28px; padding: 6px; max-width: 100%; overflow-x: auto; border: 1px solid #e2dfe8; border-radius: 15px; background: #fff; }
.section-tab { white-space: nowrap; }
.section-tab { min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; color: #716b78; background: transparent; font-weight: 800; }
.section-tab.active { color: #fff; background: #6d4ce8; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-head h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); letter-spacing: -1.8px; }
.page-head p:last-child { color: #746e7b; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 28px 0; }
.overview-stats { grid-template-columns: repeat(3, 1fr); }
.compact { width: auto; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.catalog-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; border: 1px solid #e2dfe8; border-radius: 18px; background: #fff; }
.catalog-card h3, .catalog-card p { margin: 0; }
.catalog-card p, .catalog-card small { color: #77717f; }
.catalog-title { display: flex; align-items: center; gap: 12px; }
.catalog-emoji { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: #f3f0ff; font-size: 24px; }
.catalog-image { width: calc(100% + 40px); aspect-ratio: 4 / 3; margin: -20px -20px 2px; display: block; object-fit: cover; background: #241859; }
.reward-image-upload { border: 2px dashed #d5cce7; border-radius: 16px; padding: 14px; background: #faf8ff; }
.reward-image-upload small { color: #756d83; font-weight: 400; }
.reward-image-upload input[type="file"] { border: 0; padding: 8px 0; background: transparent; }
#reward-image-placeholder { min-height: 120px; border-radius: 12px; background: linear-gradient(135deg,#eee8ff,#f8f5ff); color: #756d83; display: grid; place-items: center; }
#reward-image-preview { width: 100%; max-height: 260px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; }
.catalog-card { overflow: hidden; }
.catalog-card dl { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; padding: 12px 0; border-block: 1px solid #eeeaf2; }
.catalog-card dt { color: #817b88; font-size: 11px; }
.catalog-card dd { margin: 4px 0 0; font-weight: 800; }
.form-box { margin: 24px 0; padding: 20px; border: 1px solid #e2dfe8; border-radius: 18px; background: #fff; }
.form-box h3 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: 1.3fr 1fr auto auto; gap: 10px; align-items: center; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; }
.check input { width: auto; }
.reward-form fieldset { margin: 16px 0; border: 1px solid #e2dfe8; border-radius: 14px; }
.access-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 6px; }
.access-controls .check { min-height: 46px; padding: 10px 13px; border: 1px solid #ded8e8; border-radius: 12px; background: #faf8ff; }
.form-help { margin: 0 0 16px; padding: 11px 13px; border-radius: 11px; background: #fff6d9; color: #6c5507; font-size: 12px; line-height: 1.5; }
.catalog-code { display: inline-block; margin-bottom: 6px; padding: 4px 8px; border-radius: 999px; background: #f0ebff; color: #5433b4; font-size: 10px; font-weight: 800; letter-spacing: .05em; }
.checkbox-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 0; }
.report-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.inventory-toolbar, .report-toolbar { display: grid; grid-template-columns: 1.4fr 1fr 1fr .8fr auto; gap: 10px; align-items: end; margin: 24px 0 8px; padding: 18px; border: 1px solid #e2dfe8; border-radius: 18px; background: #fff; }
.report-toolbar { grid-template-columns: 1.3fr 1fr 1fr 1.2fr; }
.inventory-toolbar label, .report-toolbar label { margin: 0; color: #77717f; }
.inventory-toolbar input, .inventory-toolbar select, .report-toolbar input, .report-toolbar select { margin-top: 7px; padding: 11px; }
.inventory-stats { grid-template-columns: repeat(4,1fr); }
.data-table-wrap { max-width: 100%; overflow-x: auto; border-radius: 18px; }
.data-table { width: 100%; min-width: 820px; border-collapse: collapse; border: 1px solid #e2dfe8; background: #fff; }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid #ebe8ef; text-align: left; vertical-align: middle; }
.data-table th { color: #716b78; background: #f7f5fa; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.data-table td { font-size: 13px; }
.data-table td small, .secret-code { display: block; }
.data-table td small { margin-top: 4px; color: #817b88; font-size: 11px; }
.secret-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.role-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.role-card { display: grid; gap: 7px; padding: 16px; border: 1px solid #e2dfe8; border-radius: 15px; background: #fff; }
.role-card small { color: #817b88; }
.role-badge { width: fit-content; padding: 5px 9px; border-radius: 9px; color: #5536c7; background: #eeeaff; font-size: 11px; font-weight: 900; }
.audit-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.audit-filters { display: grid; grid-template-columns: 180px 240px auto; gap: 8px; }
.audit-filters input, .audit-filters select { padding: 10px; }
.redemption-toolbar { display: grid; grid-template-columns: 1.25fr 1fr 1fr 1fr auto auto; gap: 10px; align-items: end; margin: 24px 0 8px; padding: 18px; border: 1px solid #e2dfe8; border-radius: 18px; background: #fff; }
.redemption-toolbar label { margin: 0; color: #77717f; }
.redemption-toolbar select, .redemption-toolbar input { margin-top: 7px; padding: 11px; }
.redemptions-list { display: grid; gap: 10px; }
.redemption-row { display: grid; grid-template-columns: 90px minmax(220px, 1.3fr) minmax(180px, 1fr) minmax(150px, .7fr); gap: 16px; align-items: center; padding: 16px 18px; border: 1px solid #e2dfe8; border-radius: 16px; background: #fff; }
.redemption-row strong, .redemption-row small { display: block; }
.redemption-row small { margin-top: 4px; color: #817b88; font-size: 11px; }
.redemption-row span:last-child { text-align: right; }
.section-subhead { margin: 34px 0 14px; }
.section-subhead h2 { margin: 0; }
.health-grid, .audit-list { display: grid; gap: 10px; }
.health-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px; border: 1px solid #e2dfe8; border-left-width: 5px; border-radius: 16px; background: #fff; }
.health-card h3, .health-card p { margin: 0; }
.health-card p { margin-top: 5px; color: #77717f; font-size: 12px; }
.health-card > strong { min-width: 55px; font-size: 28px; text-align: right; }
.health-state { display: inline-block; margin-bottom: 8px; padding: 4px 8px; border-radius: 8px; font-size: 10px; font-weight: 900; }
.health-card.pass { border-left-color: #24855c; }
.health-card.pass .health-state { color: #18794e; background: #e7f8ef; }
.health-card.warning { border-left-color: #d29221; }
.health-card.warning .health-state { color: #8a5b00; background: #fff1d7; }
.health-card.critical { border-left-color: #c64b45; }
.health-card.critical .health-state { color: #a13d37; background: #fff0ef; }
.audit-row { display: grid; grid-template-columns: 1fr minmax(220px, .7fr); gap: 16px; padding: 15px 18px; border: 1px solid #e2dfe8; border-radius: 14px; background: #fff; }
.audit-row strong, .audit-row small { display: block; }
.audit-row small { margin-top: 4px; color: #817b88; font-size: 11px; }
.audit-row span:last-child { text-align: right; }
.stats article { padding: 21px; border: 1px solid #e2dfe8; border-radius: 19px; background: #fff; }
.stats span, .stats small { display: block; color: #807a87; font-size: 12px; font-weight: 700; }
.stats strong { display: inline-block; margin: 9px 5px 2px 0; color: #241859; font-size: 32px; }
.filters { display: flex; gap: 8px; margin: 24px 0 15px; overflow-x: auto; }
.filter { padding: 10px 15px; border: 0; border-radius: 12px; color: #716b78; background: #ebe9ef; font-weight: 800; white-space: nowrap; }
.filter.active { color: #fff; background: #6d4ce8; }
.message { min-height: 22px; color: #746e7b; font-size: 13px; }
.orders-list { display: grid; gap: 12px; }
.order-card { display: grid; grid-template-columns: minmax(210px, 1.4fr) repeat(3, minmax(110px, .7fr)) auto; align-items: center; gap: 16px; padding: 18px; border: 1px solid #e2dfe8; border-radius: 18px; background: #fff; }
.customer strong, .customer span { display: block; }
.customer span, .detail span { margin-top: 4px; color: #817b88; font-size: 12px; }
.detail strong { display: block; font-size: 14px; }
.amount { color: #5d3bd4; font-size: 20px !important; }
.status { display: inline-block; width: fit-content; padding: 6px 9px; border-radius: 10px; font-size: 11px; font-weight: 900; }
.status.pending { color: #8a5b00; background: #fff1d7; }
.status.draft { color: #5536c7; background: #eeeaff; }
.status.approved { color: #18794e; background: #e7f8ef; }
.status.ready, .status.used { color: #18794e; background: #e7f8ef; }
.status.rejected { color: #a13d37; background: #fff0ef; }
.status.cancelled, .status.expired { color: #716b78; background: #ebe9ef; }
.actions { display: flex; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.actions button { min-height: 38px; padding: 0 12px; border: 0; border-radius: 11px; font-size: 12px; font-weight: 900; }
.view-slip { color: #5536c7; background: #eeeaff; }
.approve { color: #fff; background: #24855c; }
.reject { color: #a13d37; background: #fff0ef; }
.empty { padding: 60px 20px; border: 1px dashed #d9d5df; border-radius: 20px; color: #7a7480; text-align: center; background: #fff; }
.customer-tools { margin-top: 28px; }
.customer-tools input { max-width: 560px; background: #fff; }
.customer-layout { display: grid; grid-template-columns: minmax(280px, .7fr) minmax(500px, 1.3fr); gap: 16px; align-items: start; }
.customers-list { display: grid; gap: 9px; max-height: 680px; overflow-y: auto; }
.customer-row { display: flex; justify-content: space-between; gap: 16px; padding: 16px; border: 1px solid #e2dfe8; border-radius: 16px; color: inherit; background: #fff; text-align: left; }
.customer-row:hover, .customer-row.active { border-color: #6d4ce8; box-shadow: 0 0 0 2px #6d4ce817; }
.customer-row span:last-child { text-align: right; }
.customer-row strong, .customer-row small { display: block; }
.customer-row small { margin-top: 4px; color: #817b88; }
.customer-detail { min-height: 300px; padding: 24px; border: 1px solid #e2dfe8; border-radius: 20px; background: #fff; }
.empty-detail { display: grid; place-items: center; color: #7a7480; }
.customer-detail-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.customer-detail-head h2 { margin: 0; }
.customer-detail-head p:last-child { color: #77717f; }
.wallet-summary { display: flex; gap: 10px; }
.wallet-summary span { min-width: 130px; padding: 14px; border-radius: 14px; background: #f5f3ff; }
.wallet-summary small, .wallet-summary strong { display: block; }
.wallet-summary small { color: #77717f; }
.wallet-summary strong { margin-top: 5px; color: #3b258d; }
.adjustment { margin: 22px 0; padding: 18px; border-radius: 16px; background: #f7f5ff; }
.adjustment h3, .adjustment p { margin-top: 0; }
.adjustment p { color: #77717f; font-size: 13px; }
.adjustment-grid { display: grid; grid-template-columns: .55fr 1fr auto; gap: 9px; }
.adjustment-grid .primary { width: auto; }
.ledger-title { margin-top: 26px; }
.ledger-list { display: grid; gap: 8px; }
.ledger-row { display: grid; grid-template-columns: 55px 1fr auto; gap: 12px; align-items: center; padding: 13px; border: 1px solid #ebe8ef; border-radius: 13px; }
.ledger-row span:last-child { text-align: right; }
.ledger-row strong, .ledger-row small { display: block; }
.ledger-row small { margin-top: 3px; color: #817b88; font-size: 11px; }
.ledger-direction { display: grid; place-items: center; min-height: 38px; border-radius: 10px; font-weight: 900; }
.ledger-direction.credit, .ledger-direction.unlock { color: #18794e; background: #e7f8ef; }
.ledger-direction.debit, .ledger-direction.lock { color: #a13d37; background: #fff0ef; }

.organization-form-grid { grid-template-columns: .7fr 1.2fr 1.2fr auto auto auto; }
.organization-layout { display: grid; grid-template-columns: minmax(290px,.6fr) minmax(650px,1.4fr); gap: 16px; align-items: start; }
.organizations-list { display: grid; gap: 9px; max-height: 760px; overflow-y: auto; }
.organization-row { display: grid; grid-template-columns: 1fr auto; overflow: hidden; border: 1px solid #e2dfe8; border-radius: 16px; background: #fff; }
.organization-row.active { border-color: #6d4ce8; box-shadow: 0 0 0 2px #6d4ce817; }
.organization-row > button:first-child { display: flex; justify-content: space-between; gap: 14px; padding: 16px; border: 0; color: inherit; background: transparent; text-align: left; }
.organization-row span:last-child { text-align: right; }
.organization-row strong,.organization-row small { display: block; }
.organization-row small { margin-top: 4px; color: #817b88; }
.organization-edit { padding: 0 13px; border: 0; border-left: 1px solid #eeeaf2; color: #5536c7; background: #f7f4ff; font-weight: 800; }
.organization-detail { min-height: 340px; padding: 24px; border: 1px solid #e2dfe8; border-radius: 20px; background: #fff; }
.organization-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.organization-detail-head h2,.organization-detail-head p { margin-top: 0; }
.organization-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #eeeaf2; }
.member-add { display: grid; grid-template-columns: 1fr auto auto; gap: 9px; margin-bottom: 12px; }
.organization-members { display: grid; gap: 8px; }
.organization-members article { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid #ebe8ef; border-radius: 13px; }
.organization-members strong,.organization-members small { display: block; }
.organization-members small { margin-top: 3px; color: #817b88; }
.member-actions { display: grid; grid-template-columns: auto minmax(120px,1fr) auto; gap: 6px; align-items: center; }
.member-actions select { padding: 9px; }
.small-empty { padding: 24px 12px; }
.allocation-list { display: grid; gap: 9px; }
.allocation-row { display: grid; grid-template-columns: 58px minmax(220px,1fr) auto 130px auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid #ebe8ef; border-radius: 14px; }
.allocation-row > img { width: 58px; height: 44px; border-radius: 9px; object-fit: contain; background: #f5f3f8; }
.allocation-row > span strong,.allocation-row > span small,.allocation-row label small { display: block; }
.allocation-row small { margin-top: 3px; color: #817b88; font-size: 11px; }
.allocation-row label { margin: 0; }
.allocation-row input[type="number"] { margin-top: 4px; padding: 9px; }
.allocation-toggle { min-width: 86px; }
.allocation-actions { display: grid; gap: 6px; }
.inventory-status.managed { color: #18794e; font-weight: 800; }
.allocation-row input:disabled { color: #4f4857; background: #efedf2; opacity: 1; }

dialog { width: min(620px, calc(100% - 28px)); padding: 20px; border: 0; border-radius: 22px; box-shadow: 0 28px 90px #18112166; }
dialog::backdrop { background: #17122599; backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-head h2 { margin: 0 0 15px; }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 12px; font-size: 25px; }
#slip-image { width: 100%; max-height: 68vh; object-fit: contain; border-radius: 15px; background: #eee; }
.coupon-import-dialog { width: min(720px, calc(100% - 28px)); }
.coupon-import-dialog label { display: block; margin-top: 15px; color: #665f6d; font-size: 13px; font-weight: 800; }
.coupon-import-dialog textarea { margin-top: 7px; min-height: 230px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55; }
.coupon-import-help { display: grid; gap: 5px; padding: 13px 15px; border-radius: 13px; color: #5c466f; background: #f2edff; }
.coupon-import-help span { font-size: 12px; }
.file-picker input { margin-top: 7px; background: #fff; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.dialog-actions .button { width: auto; }

@media (max-width: 850px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .order-card { grid-template-columns: 1fr 1fr; }
  .customer, .actions { grid-column: 1 / -1; }
  .actions { justify-content: flex-start; }
  .customer-layout { grid-template-columns: 1fr; }
  .catalog-grid, .overview-stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .redemption-toolbar { grid-template-columns: 1fr 1fr 1fr; }
  .inventory-toolbar, .report-toolbar { grid-template-columns: 1fr 1fr; }
  .inventory-stats, .role-grid { grid-template-columns: 1fr 1fr; }
  .audit-heading { align-items: stretch; flex-direction: column; }
  .redemption-row { grid-template-columns: 90px 1fr 1fr; }
  .redemption-row span:last-child { grid-column: 2 / -1; }
  .audit-row { grid-template-columns: 1fr 1fr; }
  .organization-layout { grid-template-columns: 1fr; }
  .organization-form-grid { grid-template-columns: 1fr 1fr; }
  .allocation-row { grid-template-columns: 58px 1fr 110px; }
  .allocation-row .allocation-toggle { grid-column: 2; }
  .allocation-actions { grid-column: 2 / -1; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .admin-user span { display: none; }
  .page { width: min(100% - 24px, 1220px); margin-top: 26px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr; }
  .order-card { grid-template-columns: 1fr; }
  .customer, .actions { grid-column: auto; }
  .customer-detail-head, .wallet-summary { flex-direction: column; }
  .wallet-summary { width: 100%; }
  .wallet-summary span { width: 100%; }
  .adjustment-grid { grid-template-columns: 1fr; }
  .catalog-grid, .overview-stats, .form-grid, .form-grid.two, .checkbox-list { grid-template-columns: 1fr; }
  .redemption-toolbar, .redemption-row { grid-template-columns: 1fr; }
  .redemption-row span:last-child { grid-column: auto; text-align: left; }
  .health-card { align-items: flex-start; }
  .audit-row { grid-template-columns: 1fr; }
  .audit-row span:last-child { text-align: left; }
  .ledger-row { grid-template-columns: 44px 1fr; }
  .ledger-row span:last-child { grid-column: 2; text-align: left; }
  .organization-form-grid,.member-add { grid-template-columns: 1fr; }
  .inventory-toolbar, .report-toolbar, .inventory-stats, .role-grid, .audit-filters { grid-template-columns: 1fr; }
  .organization-row > button:first-child { flex-direction: column; }
  .organization-row span:last-child { text-align: left; }
  .organization-detail { padding: 16px; }
  .organization-members article { grid-template-columns: 1fr auto; }
  .organization-members article .member-toggle { grid-column: 1 / -1; }
  .organization-members article { grid-template-columns: 1fr; }
  .member-actions { grid-template-columns: 1fr; }
  .allocation-row { grid-template-columns: 52px 1fr; }
  .allocation-row > img { width: 52px; height: 40px; }
  .allocation-row .allocation-toggle,.allocation-row > label:not(.allocation-toggle),.allocation-row .save-allocation,.allocation-actions { grid-column: 2; }
  .allocation-actions { grid-template-columns: 1fr; }
}
