:root{
  color-scheme: light;
  --bg:#f4f7fb;
  --bg-strong:#ffffff;
  --surface:rgba(255,255,255,.72);
  --surface-solid:#ffffff;
  --surface-soft:rgba(255,255,255,.56);
  --text:#111827;
  --muted:#667085;
  --muted-strong:#475467;
  --line:rgba(17,24,39,.10);
  --line-strong:rgba(17,24,39,.16);
  --accent:#0a84ff;
  --accent-strong:#0066d6;
  --success:#1f9d64;
  --danger:#d92d20;
  --warning:#b54708;
  --shadow:0 24px 70px rgba(27,39,63,.14);
  --shadow-soft:0 14px 36px rgba(27,39,63,.10);
  --radius:8px;
  --radius-sm:6px;
  --tap:48px;
}

*{
  box-sizing:border-box;
}

html{
  min-width:320px;
  background:var(--bg);
  -webkit-text-size-adjust:100%;
}

body{
  min-height:100vh;
  margin:0;
  font-family:Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color:var(--text);
  background:
    linear-gradient(180deg, #f7faff 0%, #eef3f9 46%, #f7f9fc 100%);
  letter-spacing:0;
}

body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(90deg, rgba(10,132,255,.07), transparent 32%, rgba(31,157,100,.06) 100%);
}

button,
input,
select{
  font:inherit;
}

button{
  cursor:pointer;
}

svg{
  width:18px;
  height:18px;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.app-shell{
  width:min(1180px, 100%);
  margin:0 auto;
  padding:14px 14px 40px;
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:66px;
  margin:0 -2px 18px;
  padding:10px 2px;
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  color:inherit;
  text-decoration:none;
}

.brand-mark{
  display:grid;
  place-items:center;
  width:42px;
  height:42px;
  border:1px solid rgba(255,255,255,.72);
  border-radius:8px;
  background:linear-gradient(145deg, #111827, #263142);
  color:#fff;
  box-shadow:0 12px 30px rgba(17,24,39,.22);
  font-size:20px;
  font-weight:800;
}

.brand strong,
.brand small{
  display:block;
  line-height:1.05;
}

.brand strong{
  font-size:14px;
  letter-spacing:0;
}

.brand small{
  margin-top:4px;
  color:var(--muted);
  font-size:12px;
}

.view-switch,
.compact-tabs,
.segmented-control{
  display:flex;
  align-items:center;
  padding:4px;
  border:1px solid rgba(255,255,255,.68);
  border-radius:8px;
  background:rgba(255,255,255,.58);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.72), 0 8px 22px rgba(27,39,63,.08);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
}

.view-switch__button,
.compact-tab,
.segmented-control span{
  min-height:38px;
  border:0;
  border-radius:6px;
  background:transparent;
  color:var(--muted-strong);
  font-size:13px;
  font-weight:700;
  line-height:1;
  white-space:nowrap;
}

.view-switch__button,
.compact-tab{
  padding:0 14px;
}

.view-switch__button.is-active,
.compact-tab.is-active,
.segmented-control input:checked + span{
  background:#fff;
  color:var(--text);
  box-shadow:0 7px 18px rgba(27,39,63,.12);
}

.calculator-view{
  display:none;
}

.calculator-view.is-active{
  display:block;
}

.hero-grid{
  display:grid;
  gap:14px;
  margin-bottom:14px;
}

.intro{
  padding:4px 2px;
}

.intro h1{
  margin:0;
  font-size:clamp(30px, 8vw, 56px);
  line-height:.96;
  letter-spacing:0;
}

.intro p{
  max-width:620px;
  margin:12px 0 0;
  color:var(--muted-strong);
  font-size:16px;
  line-height:1.55;
}

.quick-stats{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.quick-stats > div,
.metric-tile{
  min-width:0;
  border:1px solid rgba(255,255,255,.72);
  border-radius:var(--radius);
  background:var(--surface-soft);
  box-shadow:var(--shadow-soft);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
}

.quick-stats > div{
  padding:15px;
}

.quick-stats span,
.metric-tile span{
  display:block;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
  line-height:1.25;
}

.quick-stats strong,
.metric-tile strong{
  display:block;
  min-width:0;
  margin-top:7px;
  overflow-wrap:anywhere;
  font-size:20px;
  line-height:1.15;
}

.workspace-grid{
  display:grid;
  gap:14px;
}

.glass-panel{
  border:1px solid rgba(255,255,255,.72);
  border-radius:var(--radius);
  background:var(--surface);
  box-shadow:var(--shadow);
  backdrop-filter:blur(26px);
  -webkit-backdrop-filter:blur(26px);
}

.form-panel,
.results-panel{
  min-width:0;
  padding:14px;
}

.section-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}

.section-head h2{
  margin:0;
  font-size:18px;
  line-height:1.2;
}

.section-head > span,
.status-text{
  color:var(--muted);
  font-size:12px;
  font-weight:700;
  line-height:1.4;
  text-align:right;
}

.field-row,
.salary-pair{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
}

.field{
  display:grid;
  gap:7px;
  min-width:0;
}

.field span,
.details-toggle{
  color:var(--muted-strong);
  font-size:13px;
  font-weight:800;
}

.field input,
.field select{
  width:100%;
  min-height:var(--tap);
  border:1px solid var(--line);
  border-radius:var(--radius-sm);
  background:rgba(255,255,255,.86);
  color:var(--text);
  outline:none;
  padding:0 14px;
  font-size:16px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.82);
  transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.field input:focus,
.field select:focus{
  border-color:rgba(10,132,255,.65);
  background:#fff;
  box-shadow:0 0 0 4px rgba(10,132,255,.12), inset 0 1px 0 rgba(255,255,255,.9);
}

.field input.is-valid,
.field select.is-valid{
  border-color:rgba(31,157,100,.62);
}

.field input.is-invalid,
.field select.is-invalid{
  border-color:rgba(217,45,32,.70);
  box-shadow:0 0 0 4px rgba(217,45,32,.10);
}

.field--full{
  margin-bottom:10px;
}

.field--compact{
  min-width:120px;
}

.segmented-control{
  min-height:var(--tap);
  gap:4px;
  margin:0;
  border-color:var(--line);
}

.segmented-control label{
  flex:1 1 0;
  min-width:0;
}

.segmented-control input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}

.segmented-control span{
  display:grid;
  place-items:center;
  padding:0 10px;
  text-align:center;
}

.choice-strip{
  display:flex;
  gap:8px;
  min-height:0;
  margin:8px 0 12px;
  overflow-x:auto;
  scrollbar-width:none;
}

.choice-strip:empty{
  display:none;
}

.choice-strip::-webkit-scrollbar{
  display:none;
}

.choice-button{
  flex:0 0 auto;
  min-height:38px;
  border:1px solid rgba(10,132,255,.18);
  border-radius:999px;
  background:rgba(10,132,255,.08);
  color:#0757a6;
  padding:0 12px;
  font-size:12px;
  font-weight:800;
}

.choice-button:hover,
.choice-button:focus-visible{
  border-color:rgba(10,132,255,.38);
  background:rgba(10,132,255,.14);
}

.details-toggle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  width:100%;
  min-height:46px;
  margin:2px 0 12px;
  border:1px solid var(--line);
  border-radius:var(--radius-sm);
  background:rgba(255,255,255,.58);
  padding:0 14px;
}

.details-panel{
  display:grid;
  gap:10px;
  margin-bottom:12px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:rgba(255,255,255,.46);
}

.notice{
  min-height:18px;
  margin:0;
  color:var(--warning);
  font-size:12px;
  font-weight:700;
  line-height:1.45;
}

.action-row{
  display:flex;
  gap:10px;
  margin-top:2px;
}

.primary-button,
.ghost-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:var(--tap);
  border-radius:var(--radius-sm);
  padding:0 16px;
  font-size:15px;
  font-weight:800;
}

.primary-button{
  flex:1 1 auto;
  border:0;
  background:linear-gradient(180deg, var(--accent), var(--accent-strong));
  color:#fff;
  box-shadow:0 14px 28px rgba(10,132,255,.25);
}

.ghost-button{
  flex:0 0 auto;
  border:1px solid var(--line);
  background:rgba(255,255,255,.70);
  color:var(--text);
}

.metrics-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  margin-bottom:12px;
}

.metric-tile{
  padding:14px;
}

.metric-tile--flat{
  min-height:var(--tap);
  box-shadow:none;
  background:rgba(255,255,255,.64);
}

.table-card{
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:rgba(255,255,255,.68);
}

.table-card + .table-card{
  margin-top:12px;
}

.table-scroll{
  overflow:auto;
  max-height:62vh;
}

.data-table{
  width:100%;
  min-width:680px;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
}

.data-table caption{
  position:absolute;
  width:1px;
  height:1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
}

.data-table th,
.data-table td{
  padding:11px 12px;
  border-bottom:1px solid var(--line);
  text-align:right;
  white-space:nowrap;
}

.data-table th:first-child,
.data-table td:first-child{
  text-align:left;
}

.data-table thead th{
  position:sticky;
  top:0;
  z-index:1;
  background:rgba(250,252,255,.94);
  color:var(--muted-strong);
  font-size:12px;
  font-weight:900;
}

.data-table tbody tr:nth-child(even) td{
  background:rgba(248,250,252,.72);
}

.data-table tfoot td,
.total-row td{
  background:rgba(10,132,255,.08);
  font-weight:900;
}

.empty-state{
  color:var(--muted);
  text-align:center !important;
  white-space:normal !important;
}

.detail-row th,
.detail-row td{
  background:rgba(255,255,255,.94);
}

.salary-panel{
  display:none;
}

.salary-panel.is-active{
  display:grid;
  gap:10px;
}

.compact-tabs{
  flex:0 0 auto;
  max-width:100%;
  overflow:auto;
}

.compact-tab{
  min-height:34px;
  font-size:12px;
}

.salary-table tbody th{
  text-align:left;
}

.salary-table .subtotal-row th,
.salary-table .subtotal-row td{
  font-weight:900;
}

.salary-table .net-row th,
.salary-table .net-row td{
  color:var(--success);
  font-weight:900;
}

@media (min-width:640px){
  .app-shell{
    padding:18px 20px 52px;
  }

  .hero-grid{
    grid-template-columns:minmax(0, 1fr) minmax(320px, 420px);
    align-items:end;
    margin-bottom:18px;
  }

  .field-row,
  .salary-pair{
    grid-template-columns:minmax(0, 1fr) minmax(150px, .6fr);
  }

  .metrics-grid{
    grid-template-columns:repeat(3, minmax(0, 1fr));
  }
}

@media (min-width:980px){
  .app-shell{
    padding-top:22px;
  }

  .topbar{
    margin-bottom:28px;
  }

  .workspace-grid{
    grid-template-columns:minmax(360px, 430px) minmax(0, 1fr);
    align-items:start;
  }

  .workspace-grid--salary{
    grid-template-columns:minmax(360px, 410px) minmax(0, 1fr);
  }

  .form-panel,
  .results-panel{
    padding:18px;
  }

  .quick-stats strong,
  .metric-tile strong{
    font-size:22px;
  }
}

@media (max-width:479px){
  .topbar{
    align-items:stretch;
    flex-direction:column;
  }

  .brand{
    padding:0 2px;
  }

  .view-switch,
  .view-switch__button{
    width:100%;
  }

  .view-switch__button{
    flex:1 1 0;
  }

  .quick-stats{
    grid-template-columns:1fr;
  }

  .section-head{
    flex-direction:column;
    align-items:stretch;
  }

  .section-head > span,
  .status-text{
    text-align:left;
  }

  .compact-tabs{
    width:100%;
  }

  .compact-tab{
    flex:1 1 0;
  }

  .action-row{
    flex-direction:column;
  }

  .ghost-button{
    flex:1 1 auto;
  }
}

@media (prefers-reduced-motion:no-preference){
  .calculator-view.is-active{
    animation:fadeIn .22s ease both;
  }

  .primary-button,
  .ghost-button,
  .choice-button,
  .view-switch__button,
  .compact-tab{
    transition:transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
  }

  .primary-button:hover,
  .ghost-button:hover,
  .choice-button:hover{
    transform:translateY(-1px);
  }

  @keyframes fadeIn{
    from{ opacity:0; transform:translateY(6px); }
    to{ opacity:1; transform:translateY(0); }
  }
}

@media print{
  body{
    background:#fff;
  }

  body::before,
  .topbar,
  .form-panel,
  .quick-stats,
  .intro p,
  .action-row{
    display:none !important;
  }

  .app-shell{
    width:100%;
    padding:0;
  }

  .calculator-view:not(.is-active){
    display:none !important;
  }

  .glass-panel,
  .table-card{
    border:0;
    box-shadow:none;
    background:#fff;
  }

  .workspace-grid{
    display:block;
  }

  .table-scroll{
    max-height:none;
    overflow:visible;
  }
}
