:root {
  color-scheme: light;
  --navy: #14244a;
  --navy-2: #203763;
  --coral: #ee5b4e;
  --green: #0a9b72;
  --amber: #d88700;
  --ink: #132143;
  --muted: #74809a;
  --line: #e5e8ee;
  --surface: #ffffff;
  --background: #f1f3f7;
  --shadow: 0 12px 32px rgba(20, 36, 74, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--background); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 80% 10%, #ffe1dc 0, transparent 30%), linear-gradient(145deg, #f7f8fb, #e9edf6); }
.login-card { width: min(540px, 100%); padding: 44px; border-radius: 32px; background: rgba(255,255,255,.94); box-shadow: 0 24px 80px rgba(20,36,74,.14); }
.login-card h1 { font-size: clamp(32px, 7vw, 52px); line-height: 1.05; margin: 14px 0 20px; letter-spacing: -.04em; }
.brand-mark { width: 82px; height: 82px; display: grid; place-items: center; border-radius: 26px; background: var(--navy); color: white; font-weight: 900; font-size: 30px; box-shadow: 0 12px 30px rgba(20,36,74,.2); }
.brand-mark.small { width: 45px; height: 45px; border-radius: 15px; font-size: 16px; box-shadow: none; }
.eyebrow { margin: 0 0 6px; color: var(--coral); letter-spacing: .14em; font-weight: 800; font-size: 12px; }
.muted, .page-intro p, .welcome p, .form-hint { color: var(--muted); line-height: 1.65; }
.notice { margin-top: 20px; border-radius: 16px; padding: 14px 16px; background: #fff6de; color: #835f00; }
.login-benefits { margin: 26px 0 0; padding: 0; list-style: none; display: grid; gap: 13px; }
.login-benefits li::before { content: "✓"; color: var(--green); font-weight: 900; margin-right: 10px; }

.portal { min-height: 100vh; }
.sidebar { width: 250px; position: fixed; inset: 0 auto 0 0; background: white; border-right: 1px solid var(--line); padding: 26px 18px; display: flex; flex-direction: column; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; color: var(--ink); text-decoration: none; }
.brand span:last-child { display: grid; }
.brand small, .sidebar-user small { color: var(--muted); margin-top: 3px; }
.side-nav { display: grid; gap: 7px; }
.side-nav button { border: 0; border-radius: 14px; padding: 13px 15px; background: transparent; color: var(--muted); text-align: left; font-weight: 700; display: flex; gap: 12px; }
.side-nav button:hover, .side-nav button.active { background: var(--navy); color: white; }
.sidebar-user { margin-top: auto; background: #eef2fa; border-radius: 18px; padding: 12px; display: flex; gap: 10px; align-items: center; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--navy-2); color: white; display: grid; place-items: center; font-weight: 800; }
.sidebar-user span:last-child { display: grid; min-width: 0; }

.content { margin-left: 250px; padding: 28px clamp(20px, 4vw, 58px) 80px; max-width: 1500px; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.topbar h1, .page-intro h2 { margin: 0; font-size: clamp(28px, 4vw, 40px); letter-spacing: -.03em; }
.page { display: none; animation: fade .2s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } }

.welcome { background: var(--navy); color: white; border-radius: 26px; padding: clamp(24px, 4vw, 42px); display: flex; align-items: center; justify-content: space-between; gap: 20px; overflow: hidden; position: relative; }
.welcome::after { content: ""; position: absolute; width: 270px; height: 270px; right: -90px; top: -120px; border-radius: 50%; border: 45px solid rgba(255,255,255,.07); }
.welcome h2 { font-size: clamp(27px, 4vw, 42px); margin: 0; }
.welcome p { color: #bfc9dc; }
.button { border: 0; border-radius: 13px; padding: 12px 18px; font-weight: 800; transition: transform .15s ease, opacity .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; }
.button.primary { background: var(--navy); color: white; }
.button.light { background: white; color: var(--navy); position: relative; z-index: 1; }
.button.ghost { color: var(--navy); background: white; border: 1px solid var(--line); }
.button.danger { color: #a72722; background: #fff0ef; }
.text-button { border: 0; background: transparent; color: var(--coral); font-weight: 800; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 22px 0; }
.stat { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); }
.stat p { color: var(--muted); margin: 0 0 12px; font-size: 13px; font-weight: 700; text-transform: uppercase; }
.stat strong { font-size: clamp(23px, 3vw, 34px); letter-spacing: -.03em; }
.stat.green strong { color: var(--green); }
.stat.coral strong { color: var(--coral); }
.stat.amber strong { color: var(--amber); }

.card { background: white; border: 1px solid var(--line); border-radius: 24px; padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 20px; }
.card-heading h2 { margin: 0; font-size: 22px; }
.current-policy { margin: 8px 0 0; color: var(--muted); }
.current-policy strong { color: var(--green); }
.page-intro { margin-bottom: 24px; }
.page-intro p { margin-bottom: 0; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

label { display: grid; gap: 8px; font-weight: 700; color: #536078; margin-bottom: 16px; }
input, select { width: 100%; border: 1px solid #dce0e8; border-radius: 13px; padding: 13px 14px; background: #fbfbfd; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(238,91,78,.12); }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 20px; }
.chip { border: 1px solid var(--line); background: white; color: var(--muted); border-radius: 999px; padding: 9px 14px; font-weight: 700; }
.chip.active { color: white; background: var(--navy); border-color: var(--navy); }

.data-row { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(90px, .6fr)); align-items: center; gap: 14px; padding: 17px 0; border-top: 1px solid var(--line); }
.data-row:first-child { border-top: 0; }
.data-row h3 { margin: 0 0 5px; font-size: 16px; }
.data-row p, .data-row small { color: var(--muted); margin: 0; }
.data-cell { display: grid; gap: 5px; }
.data-cell span { color: var(--muted); font-size: 12px; }
.assignment-controls { display: grid; gap: 8px; }
.policy-history-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.policy-history-row:first-child { border-top: 0; }
.policy-history-row > strong { color: var(--green); font-size: 20px; }
.policy-history-row span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.money { color: var(--green); font-weight: 850; }
.status { justify-self: start; border-radius: 999px; padding: 7px 10px; background: #fff4d5; color: #946100; font-size: 12px; font-weight: 800; }
.status.completed, .status.available, .status.paid { color: #087c5b; background: #ddf8ec; }
.status.cancelled, .status.invalid, .status.refunded, .status.rejected { color: #ad342d; background: #ffe4e1; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }

.link-list { display: grid; gap: 14px; }
.link-item { border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 12px; }
.link-item header { display: flex; justify-content: space-between; gap: 12px; }
.link-item h3 { margin: 0; }
.link-url { color: var(--coral); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-metrics { display: flex; gap: 22px; color: var(--muted); }

.wallet-hero { background: linear-gradient(135deg, var(--navy), #2d4776); color: white; border-radius: 28px; padding: 36px; margin-bottom: 20px; }
.wallet-hero p { color: #c3cde0; margin: 0 0 10px; }
.wallet-hero strong { display: block; font-size: clamp(38px, 8vw, 64px); margin-bottom: 12px; }
.compact-list { margin-top: 15px; }
.compact-item { border-top: 1px solid var(--line); padding: 13px 0; color: var(--muted); }
.profile-form { max-width: 760px; }
.profile-avatar { width: 90px; height: 90px; border-radius: 50%; background: var(--navy); color: white; display: grid; place-items: center; font-size: 28px; font-weight: 900; margin-bottom: 24px; }

.toast { position: fixed; z-index: 100; right: 22px; top: 20px; max-width: min(420px, calc(100vw - 44px)); padding: 14px 18px; border-radius: 13px; background: var(--navy); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(-10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a93630; }
.modal { width: min(680px, calc(100vw - 28px)); max-height: min(760px, calc(100vh - 40px)); overflow: hidden; border: 0; border-radius: 24px; padding: 0; color: var(--ink); box-shadow: 0 24px 80px rgba(20,36,74,.25); }
.modal::backdrop { background: rgba(8, 18, 42, .58); }
.modal-card { display: flex; flex-direction: column; max-height: min(760px, calc(100vh - 40px)); padding: clamp(20px, 4vw, 32px); overflow: hidden; }
.modal-card .card-heading { position: sticky; top: 0; background: white; z-index: 1; }
.policy-history-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 6px; scrollbar-gutter: stable; }
.bottom-nav { display: none; }

@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
  .sidebar { width: 84px; align-items: center; }
  .brand span:last-child, .side-nav span, .sidebar-user span:last-child { display: none; }
  .content { margin-left: 84px; }
  .side-nav button { justify-content: center; font-size: 20px; }
}

@media (max-width: 700px) {
  .login-card { padding: 30px 23px; border-radius: 24px; }
  .sidebar { display: none; }
  .content { margin: 0; padding: 18px 14px 100px; }
  .topbar { margin-bottom: 18px; }
  .topbar .eyebrow { display: none; }
  .welcome { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 16px; }
  .data-row { grid-template-columns: 1fr 1fr; }
  .data-row > :first-child { grid-column: 1 / -1; }
  .policy-history-row { grid-template-columns: 80px 1fr; }
  .policy-history-row .status { grid-column: 2; }
  .input-action { grid-template-columns: 1fr; }
  .bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 10; inset: auto 0 0; background: white; border-top: 1px solid var(--line); padding: 8px 4px max(8px, env(safe-area-inset-bottom)); }
  .bottom-nav button { border: 0; background: transparent; color: #9aa3b5; display: grid; gap: 3px; justify-items: center; font-size: 20px; }
  .bottom-nav button span { font-size: 11px; font-weight: 750; }
  .bottom-nav button.active { color: var(--navy); }
}
