:root {
  --ink: #17212b;
  --muted: #687582;
  --line: #dfe5e8;
  --surface: #ffffff;
  --canvas: #f4f6f6;
  --navy: #142b38;
  --navy-soft: #1d3b4a;
  --teal: #168a84;
  --teal-dark: #0e706b;
  --teal-pale: #e1f3f1;
  --red: #b13a47;
  --red-pale: #fbe8eb;
  --green: #267761;
  --green-pale: #e4f4ee;
  --shadow: 0 18px 45px rgba(21, 43, 56, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(30px, 4vw, 42px); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: 20px; letter-spacing: -.02em; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: 236px;
  padding: 28px 18px 22px;
  flex-direction: column;
  color: #dce8ec;
  background: var(--navy);
}
.brand { display: flex; align-items: center; gap: 11px; margin: 0 10px 46px; color: #fff; font-size: 19px; font-weight: 750; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: var(--navy); background: #7dd8d0; font-size: 17px; font-weight: 850; }
.nav-link { display: flex; width: 100%; align-items: center; gap: 12px; padding: 11px 12px; border: 0; border-radius: 9px; color: #aebfc7; background: transparent; font-weight: 650; text-align: left; text-decoration: none; }
.nav-link:hover, .nav-link.active { color: #fff; background: var(--navy-soft); }
.nav-icon { display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid rgba(255,255,255,.15); border-radius: 7px; font-size: 12px; }
.logout-form { margin-top: auto; }
.nav-button { appearance: none; }

.content { width: min(1280px, calc(100% - 236px)); min-height: 100vh; margin-left: 236px; padding: 58px clamp(28px, 5vw, 72px); }
.narrow-content { max-width: 1120px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.form-header { align-items: flex-start; margin-bottom: 25px; }
.eyebrow { margin-bottom: 10px; text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 800; }
.eyebrow.accent { color: var(--teal); }
.muted { margin-bottom: 0; color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 27px; color: var(--muted); font-weight: 650; text-decoration: none; }
.back-link:hover { color: var(--teal-dark); }

.button { display: inline-flex; min-height: 43px; padding: 10px 17px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; font-weight: 750; text-decoration: none; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--teal); box-shadow: 0 7px 18px rgba(22, 138, 132, .18); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { border-color: var(--line); color: var(--ink); background: #fff; }
.button-danger { color: #fff; background: var(--red); }
.button-danger:hover { background: #922c38; }
.button-full { width: 100%; }

.alert { margin-bottom: 22px; padding: 13px 15px; border: 1px solid; border-radius: 9px; font-weight: 620; }
.alert-error { border-color: #f0c4ca; color: #8e2936; background: var(--red-pale); }
.alert-success { border-color: #b9dfd1; color: #1d6653; background: var(--green-pale); }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { display: flex; min-height: 92px; padding: 19px 21px; flex-direction: column; justify-content: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { margin-top: 3px; font-size: 25px; line-height: 1.2; }
.stat-card small { color: var(--muted); font-size: 14px; font-weight: 650; }
.stat-note strong { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.stat-note i, .status i { display: inline-block; width: 7px; height: 7px; border-radius: 99px; background: #32a47e; box-shadow: 0 0 0 4px #e2f5ee; }

.table-card, .form-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.table-heading { display: flex; padding: 22px 24px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.table-heading h2 { margin: 0; }
.table-heading p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.transaction-list-heading { padding: 0 0 12px; border: 0; }
.transaction-list-surface { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 20px; color: #74818b; background: #f8f9f9; text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
td { padding: 16px 20px; border-top: 1px solid #edf0f1; white-space: nowrap; }
tbody tr:hover { background: #fbfcfc; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell div { display: flex; flex-direction: column; }
.user-cell div > span { color: var(--muted); font-size: 13px; }
.avatar { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border-radius: 11px; color: #176861; background: var(--teal-pale); font-size: 13px; font-weight: 850; }
.role-badge { display: inline-block; padding: 4px 9px; border-radius: 99px; text-transform: capitalize; font-size: 11px; font-weight: 750; }
.role-admin { color: #754b19; background: #f7ecd6; }
.role-user { color: #49606c; background: #edf1f3; }
.approval-badge { display: inline-block; padding: 4px 9px; border-radius: 99px; font-size: 11px; font-weight: 750; }
.approval-approved { color: #267761; background: #e4f4ee; }
.approval-pending { color: #8a5c1e; background: #f8edda; }
.purchase-status { display: inline-block; padding: 4px 9px; border-radius: 99px; text-transform: capitalize; font-size: 11px; font-weight: 750; }
.purchase-status-paid { color: #267761; background: #e4f4ee; }
.purchase-status-pending { color: #8a5c1e; background: #f8edda; }
.purchase-status-failed { color: #8e2936; background: var(--red-pale); }
.purchase-status-applied { color: #267761; background: #e4f4ee; }
.purchase-status-success { color: #267761; background: #e4f4ee; }
.purchase-status-recorded { color: #49606c; background: #edf1f3; }
.currency { color: var(--muted); font-size: 11px; font-weight: 700; }
.activity-type-badge { display: inline-block; padding: 4px 9px; border-radius: 99px; color: #49606c; background: #edf1f3; font-size: 11px; font-weight: 750; }
.table-wrap:has(.reference-tooltip[open]) { overflow: visible; }
.reference-tooltip { position: relative; }
.reference-tooltip summary { display: inline-flex; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--teal-dark); background: #fff; cursor: pointer; font-size: 11px; font-weight: 750; list-style: none; user-select: none; }
.reference-tooltip summary::-webkit-details-marker { display: none; }
.reference-tooltip[open] summary { border-color: #9fc9c5; background: var(--teal-pale); }
.reference-tooltip-content { position: absolute; z-index: 20; top: calc(100% + 7px); right: 0; width: max-content; max-width: min(440px, 70vw); padding: 10px 12px; border: 1px solid #cad2d6; border-radius: 8px; color: #40515b; background: #fff; box-shadow: 0 12px 30px rgba(21, 43, 56, .16); white-space: normal; overflow-wrap: anywhere; }
.reference-tooltip-content code { font-size: 12px; }
.activity-reason { display: block; max-width: 330px; overflow: hidden; text-overflow: ellipsis; }
.activity-author { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.user-activity-details { display: block; max-width: 350px; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 650; }
.status-inactive i { background: #99a2a8; box-shadow: 0 0 0 4px #edf0f1; }
.status-pending i { background: #c18a35; box-shadow: 0 0 0 4px #f8edda; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 13px; }
.actions form { margin: 0; }
.text-link { padding: 0; border: 0; color: var(--teal-dark); background: none; font-weight: 700; text-decoration: none; }
.text-link.danger { color: var(--red); }
.danger-text { color: var(--red); }
.empty-state { display: flex; padding: 45px; flex-direction: column; align-items: center; color: var(--muted); }
.empty-state strong { color: var(--ink); }
.pagination { display: flex; min-height: 64px; padding: 13px 20px; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination div { display: flex; gap: 7px; }
.page-button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-weight: 650; text-decoration: none; }
.page-button.disabled { color: #adb5ba; background: #f6f7f7; }

.form-card { max-width: 850px; }
.user-detail-card, .admin-log-card { width: 100%; max-width: none; }
.form-card + .form-card { margin-top: 22px; }
.form-section { display: grid; grid-template-columns: 190px 1fr; gap: 34px; padding: 30px; border-bottom: 1px solid var(--line); }
.section-copy h2 { margin-bottom: 4px; }
.section-copy p { margin: 0; color: var(--muted); font-size: 13px; }
.fields { display: grid; gap: 18px; }
.two-column { grid-template-columns: 1fr 1fr; }
.span-two { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #34434d; font-size: 13px; font-weight: 700; }
label em { margin-left: 5px; color: var(--muted); font-size: 11px; font-style: normal; font-weight: 550; }
input, select, textarea { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #cad2d6; border-radius: 8px; outline: none; color: var(--ink); background: #fff; }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,138,132,.12); }
label small { color: var(--muted); font-size: 11px; font-weight: 500; }
.form-actions { display: flex; padding: 20px 30px; justify-content: flex-end; gap: 10px; background: #fafbfb; }
.detail-card { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 34px; padding: 30px; }
.detail-content { min-width: 0; }
.note-form { padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.note-fields { display: grid; gap: 16px; }
.note-actions { display: flex; margin-top: 15px; justify-content: flex-end; }
.admin-log { display: grid; gap: 0; }
.note-entry { padding: 20px 0; border-bottom: 1px solid var(--line); }
.note-entry:last-child { border-bottom: 0; }
.note-entry header { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.note-entry time, .note-entry footer { color: var(--muted); font-size: 12px; }
.note-entry p { margin: 13px 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-kind { display: inline-block; padding: 4px 9px; border-radius: 99px; color: #49606c; background: #edf1f3; font-size: 11px; font-weight: 750; }
.transaction-history-section { width: 100%; margin-top: 22px; }
.transaction-heading { display: flex; margin-bottom: 12px; align-items: flex-end; justify-content: space-between; gap: 20px; }
.token-balance { display: flex; align-items: baseline; gap: 5px; color: var(--muted); }
.token-balance span { margin-right: 5px; font-size: 12px; font-weight: 700; }
.token-balance strong { color: var(--ink); font-size: 25px; line-height: 1; }
.token-balance small { font-size: 11px; }
.token-adjustment-form { display: grid; grid-template-columns: minmax(150px, .55fr) minmax(280px, 1.45fr) auto; gap: 13px; margin-bottom: 14px; padding: 16px; align-items: end; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.token-adjustment-form .button { margin-bottom: 22px; }
.embedded-transactions { min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.embedded-transactions table { min-width: 760px; }
.embedded-transactions th { padding-inline: 13px; }
.embedded-transactions td { padding: 13px; }
.embedded-pagination { min-height: 55px; padding: 10px 13px; }
.settings-card { width: 100%; max-width: none; }
.settings-section { width: 100%; margin-top: 28px; }
.settings-heading { margin-bottom: 13px; }
.settings-package-list { display: grid; gap: 14px; }
.package-settings-card { position: relative; width: 100%; max-width: none; padding: 22px; overflow: visible; }
.package-editor { display: grid; gap: 17px; }
.package-fields { grid-template-columns: 1.1fr 1.6fr repeat(4, minmax(110px, 1fr)); align-items: end; }
.package-actions { display: flex; justify-content: flex-end; }
.package-delete-confirmation { position: absolute; left: 22px; bottom: 31px; }
.package-delete-confirmation summary { color: var(--red); cursor: pointer; font-size: 12px; font-weight: 700; }
.package-delete-form { position: absolute; z-index: 5; left: 0; bottom: calc(100% + 8px); display: grid; width: 280px; gap: 12px; padding: 15px; border: 1px solid #ecc5ca; border-radius: 9px; background: #fff; box-shadow: var(--shadow); }
.package-delete-form span { color: var(--muted); font-size: 12px; }
.new-package-card { display: grid; margin-top: 14px; gap: 19px; border-style: dashed; }
.confirm-card { display: grid; max-width: 720px; grid-template-columns: auto 1fr; gap: 18px; padding: 30px; border: 1px solid #ecc5ca; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.confirm-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; color: var(--red); background: var(--red-pale); font-size: 21px; font-weight: 850; }
.confirm-card p { margin: 0; color: var(--muted); }
.confirm-actions { display: flex; grid-column: 1 / -1; justify-content: flex-end; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

.login-body { background: var(--navy); }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(380px, .9fr) minmax(500px, 1.1fr); }
.brand-panel { display: flex; min-height: 100%; padding: 48px clamp(42px, 7vw, 100px); flex-direction: column; color: #fff; background: radial-gradient(circle at 12% 20%, #225365 0, var(--navy) 55%); }
.brand-panel .brand { margin: 0; }
.brand-copy { max-width: 540px; margin: auto 0; }
.brand-copy h1 { max-width: 520px; font-size: clamp(42px, 5vw, 68px); }
.brand-copy > p:last-child { max-width: 470px; color: #b9cad1; font-size: 17px; }
.brand-foot { margin: 0; color: #8099a4; font-size: 12px; }
.login-panel { display: grid; min-height: 100%; padding: 45px; place-items: center; background: #f7f8f8; }
.login-card { display: grid; width: min(420px, 100%); gap: 20px; padding: 42px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.login-card h2 { margin: 0; font-size: 31px; }
.form-note { margin: 0; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 18px; flex-direction: row; align-items: center; }
  .sidebar .brand { margin: 0 auto 0 0; }
  .sidebar nav { margin-right: 8px; }
  .sidebar .nav-link { width: auto; }
  .sidebar .nav-icon { display: none; }
  .logout-form { margin: 0; }
  .content { width: 100%; margin: 0; padding: 35px 20px; }
  .login-shell { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
  .login-panel { min-height: 100vh; padding: 25px; }
  .stat-row { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; }
  .detail-card { grid-template-columns: 1fr; }
  .token-adjustment-form { grid-template-columns: 1fr 1fr; }
  .token-adjustment-form .button { width: max-content; margin-bottom: 0; }
  .package-fields { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-header .button { width: 100%; }
  .two-column { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .form-section { padding: 23px 20px; }
  .detail-card { padding: 23px 20px; }
  .transaction-heading { align-items: flex-start; flex-direction: column; }
  .token-adjustment-form { grid-template-columns: 1fr; }
  .package-fields { grid-template-columns: 1fr; }
  .package-delete-confirmation { position: relative; left: auto; bottom: auto; margin-top: 15px; }
  .form-actions { padding: 18px 20px; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .login-card { padding: 30px 23px; }
}
