:root {
  --bg: #0B0827;
  --bg-2: #1A1457;
  --bg-3: #2E2694;
  --panel: rgba(14, 10, 44, 0.72);
  --panel-2: rgba(255, 255, 255, 0.05);
  --line: rgba(196, 181, 253, 0.22);
  --line-strong: rgba(196, 181, 253, 0.4);
  --text: #EDE9FE;
  --muted: #B4A9E0;
  --dim: #8B81B8;
  --accent: #7C5CFF;
  --accent-2: #A78BFA;
  --accent-soft: rgba(124, 92, 255, 0.18);
  --net: #C4B5FD;
  --sss: #38BDF8;
  --philhealth: #34D399;
  --pagibig: #FBBF24;
  --tax: #F87171;
  --other: #A1A1AA;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 26px 60px rgba(5, 3, 20, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 120%, rgba(124, 92, 255, 0.35), rgba(11, 8, 39, 0.92) 65%),
    radial-gradient(ellipse 110% 80% at 58% 20%, var(--bg-3) 0%, var(--bg-2) 44%, var(--bg) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--net); text-decoration: none; }
a:hover { color: #fff; }
::selection { background: rgba(124, 92, 255, 0.45); color: #fff; }

.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;
}
.skip {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  padding: 10px 14px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700;
}
.skip:focus { top: 16px; }

/* ---------- header ---------- */
.top {
  max-width: 1120px; margin: 0 auto; padding: 28px 16px 8px;
  animation: rise 0.6s ease both;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim);
}
.brand:hover { color: var(--net); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: 0; color: #fff;
  background: linear-gradient(150deg, #241B63, #100A32);
  box-shadow: 1.5px 0 0 rgba(255, 23, 68, 0.75), -1.5px 0 0 rgba(0, 229, 255, 0.75);
}
.title {
  margin: 18px 0 6px; font-size: clamp(32px, 5vw, 48px); line-height: 1.05; font-weight: 800; letter-spacing: -0.03em;
  background: linear-gradient(100deg, #FFFFFF 6%, #DDD3FF 46%, #A78BFA 96%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { margin: 0; color: var(--muted); max-width: 60ch; }
.subtitle strong { color: var(--text); }

/* ---------- layout ---------- */
.layout {
  max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px;
  animation: rise 0.7s ease both;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }
  .inputs { position: sticky; top: 16px; }
}
.results { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Wide payslips scroll inside their card instead of widening the page. */
.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.card {
  padding: 22px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card-title { margin: 0 0 14px; font-size: 13px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.chip {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--net); background: var(--accent-soft); border: 1px solid var(--line);
}

/* ---------- inputs ---------- */
.label { display: block; margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--dim); }

.money {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 54px;
  border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.money:focus-within { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); }
.money-sign { font-weight: 700; color: var(--dim); }
.money input, .plain, select {
  width: 100%; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; outline: none;
}
.money input::placeholder { color: var(--dim); font-weight: 500; }
.plain, select {
  height: 54px; padding: 0 14px; font-size: 16px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
}
.plain:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
select option { background: #1A1457; color: var(--text); }

.seg { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.seg legend { padding: 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 8px 6px;
  border-radius: 12px; font-size: 13.5px; font-weight: 700; color: var(--muted); cursor: pointer;
  background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; transition: background 0.15s, color 0.15s;
}
.seg span:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.seg input:checked + span { color: #fff; background: var(--accent-soft); border-color: var(--line-strong); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg legend { grid-column: 1 / -1; }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 420px) { .seg-4 { grid-template-columns: 1fr 1fr; } }

.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 0; padding: 0; border: 0; }
.checks legend { padding: 0; width: 100%; }
.checks label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--accent); }

.disclosure { margin: 0 0 18px; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.disclosure summary {
  cursor: pointer; padding: 12px 14px; font-weight: 700; font-size: 13.5px; color: var(--muted); list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: "+"; font-size: 18px; color: var(--dim); }
.disclosure[open] summary::after { content: "–"; }
.disclosure summary:hover { color: var(--text); }
.disclosure-body { padding: 4px 14px 16px; }

.btn {
  height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), #5B3FE0); box-shadow: 0 10px 26px rgba(124, 92, 255, 0.35);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(124, 92, 255, 0.45); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: rgba(255, 255, 255, 0.07); border-color: var(--line); box-shadow: none; color: var(--text); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- results ---------- */
.hero { position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.35), transparent 65%); pointer-events: none;
}
.hero-label { position: relative; margin: 0; font-size: 13px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.hero-value {
  position: relative; margin: 6px 0 4px; font-size: clamp(38px, 7vw, 60px); line-height: 1; font-weight: 800; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(100deg, #FFFFFF 10%, #DDD3FF 60%, #A78BFA 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { position: relative; margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.hero-sub b { color: var(--text); font-weight: 700; }

.bar { position: relative; display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.bar span { display: block; height: 100%; min-width: 0; transition: width 0.35s ease; }
.bar .k-net { background: linear-gradient(90deg, #A78BFA, #7C5CFF); }
.bar .k-sss { background: var(--sss); }
.bar .k-philhealth { background: var(--philhealth); }
.bar .k-pagibig { background: var(--pagibig); }
.bar .k-tax { background: var(--tax); }
.bar .k-other { background: var(--other); }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12.5px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .k-net i { background: #A78BFA; }
.legend .k-sss i { background: var(--sss); }
.legend .k-philhealth i { background: var(--philhealth); }
.legend .k-pagibig i { background: var(--pagibig); }
.legend .k-tax i { background: var(--tax); }
.legend .k-other i { background: var(--other); }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px 0 10px 12px; border-bottom: 1px solid rgba(196, 181, 253, 0.12); text-align: right; vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 0; }
@media (max-width: 420px) {
  .table th, .table td { font-size: 13px; padding-left: 8px; }
  .table .total td { font-size: 14px; }
  .card { padding: 18px 16px; }
}
.table th { font-size: 11.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.table td:first-child, .table th:first-child { text-align: left; }
.table tr:last-child td { border-bottom: 0; }
.table .name { color: var(--text); font-weight: 600; }
.table .sub { display: block; font-size: 12px; font-weight: 500; color: var(--dim); }
.table .neg { color: var(--muted); }
.table .neg::before { content: "− "; color: var(--dim); }
.table .total td { padding-top: 14px; font-weight: 800; font-size: 16px; color: #fff; border-top: 1px solid var(--line-strong); }
.table .total .name { color: #fff; }
.table .accent td:not(:first-child) { color: var(--net); }
.table .muted td { color: var(--dim); font-size: 13px; }
.table.compact td, .table.compact th { padding: 8px 0; font-size: 14px; }
.table td.good { color: var(--philhealth); }
.table td.bad { color: var(--tax); }

.bracket-big { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: #fff; font-variant-numeric: tabular-nums; }
.bracket-line { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.bracket-line b { color: var(--text); }
.bracket-scale { display: flex; gap: 4px; margin-top: 14px; }
.bracket-scale span { flex: 1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); }
.bracket-scale span.on { background: linear-gradient(90deg, #A78BFA, #7C5CFF); }
.bracket-scale span.hot { background: var(--tax); }
.bracket-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--dim); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toast { font-size: 13px; color: var(--philhealth); font-weight: 600; opacity: 0; transition: opacity 0.2s; }
.toast.show { opacity: 1; }

.foot { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; color: var(--dim); font-size: 12.5px; }
.foot p { margin: 0 0 8px; max-width: 80ch; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .top, .layout { animation: none; }
  .bar span, .btn { transition: none; }
}

@media print {
  body { background: #fff; color: #111; }
  .inputs, .actions, .skip, .brand { display: none !important; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  .card { background: #fff; border: 1px solid #ddd; box-shadow: none; color: #111; break-inside: avoid; }
  .title, .hero-value { -webkit-text-fill-color: #111; color: #111; background: none; }
  .table .name, .table .total td, .bracket-big { color: #111; }
  .subtitle, .hint, .table .neg, .legend, .foot, .card-title, .hero-label, .bracket-line { color: #444; }
}
