:root {
  --blue: #145f78;
  --blue-dark: #0e4559;
  --brand-red: #9d1111;
  --brand-red-dark: #6f0c0c;
  --gold: #d59b3b;
  --ink: #17323d;
  --muted: #6f858d;
  --line: #dce8eb;
  --canvas: #ffffff;
  --white: #fff;
  --green: #287d58;
  font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { background: #ffffff; }

body {
  margin: 0;
  min-width: 280px;
  background: #ffffff;
  color: var(--ink);
  font-family: inherit;
  line-height: 1.7;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.calculator-page {
  width: 100%;
  padding: 28px 14px;
}

.calculator-card {
  width: min(100%, 780px);
  margin-inline: auto;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(25, 62, 73, .09);
}

.calculator-header {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 28px clamp(20px, 5vw, 42px);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
}

.brand-mark {
  display: grid;
  flex: 0 0 54px;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--blue-dark);
  background: #f2c36b;
  border-radius: 16px;
  font-size: 28px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 2px;
  color: #c8e2e8;
  font-size: 12px;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  color: #fff;
  font-size: clamp(24px, 5vw, 34px);
  line-height: 1.25;
}

.subtitle {
  margin: 3px 0 0;
  color: #e1f0f3;
  font-size: 15px;
}

.calculator-body {
  padding: clamp(18px, 4vw, 32px);
  background: var(--canvas);
}

.intro-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 19px;
}

.intro-row h2 {
  margin-bottom: 3px;
  color: #000000;
  font-size: 23px;
}

.intro-row p {
  margin-bottom: 0;
  color: #808080;
  font-size: 13px;
}

.privacy-chip {
  flex: 0 0 auto;
  padding: 5px 10px;
  color: var(--green);
  background: #e7f4ed;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.refresh-page { flex: 0 0 142px; min-height: 33px; padding: 7px 10px; color: #fff; background: #9d1111; border: 0; border-radius: 7px; font-size: 11px; font-weight: 700; }
.refresh-page:hover { opacity: .88; }

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 15px;
}

.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
#dynamic-fields .field[data-field="university"] { grid-column: 1 / -1; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.field label small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.field input, .field select {
  display: block;
  width: 100%;
  height: 48px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d2e0e4;
  border-radius: 9px;
  outline: 0;
  transition: border-color .2s, box-shadow .2s;
}

.field input:focus, .field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(20, 95, 120, .12);
}

.native-university-select { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.university-custom-select { position: relative; z-index: 5; }
.university-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 48px; padding: 8px 12px; color: var(--ink); background: #fff; border: 1px solid #d2e0e4; border-radius: 9px; outline: 0; text-align: right; }
.university-trigger::after { width: 8px; height: 8px; margin-inline-start: 10px; border-inline-end: 2px solid var(--ink); border-block-end: 2px solid var(--ink); transform: rotate(45deg) translateY(-2px); content: ""; }
.university-trigger[aria-expanded="true"] { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 95, 120, .12); }
.university-options { position: absolute; top: calc(100% + 5px); right: 0; left: 0; max-height: 240px; overflow-y: auto; padding: 5px; background: #fff; border: 1px solid #b7cbd1; border-radius: 9px; box-shadow: 0 10px 24px rgba(25, 62, 73, .16); }
.university-option { display: block; width: 100%; min-height: 46px; padding: 8px 12px; color: var(--ink); background: #fff; border: 0; border-radius: 6px; text-align: right; cursor: pointer; }
.university-option:hover, .university-option:focus { color: #fff; background: var(--blue); outline: 0; }

.field input.invalid, .field select.invalid { border-color: #b93d3d; }

.field-error {
  min-height: 19px;
  margin-top: 3px;
  color: #b93d3d;
  font-size: 11px;
}

.weights-panel { margin-top: 14px; padding: 16px; background: #f8fbfb; border: 1px solid #d2e0e4; border-radius: 12px; }
.weights-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.weights-heading h3 { margin: 0; color: var(--ink); font-size: 17px; }
.weights-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.weights-controls { display: flex; flex: 0 0 auto; flex-direction: column; gap: 8px; width: 142px; }
.reset-weights, .step-toggle { width: 100%; min-height: 33px; padding: 7px 10px; border: 0; border-radius: 7px; font-size: 11px; font-weight: 700; }
.reset-weights { color: #fff; background: #145e76; }
.step-toggle { color: #7b4d00; background: #fff1c9; border: 1px solid #e6b54f; }
.step-toggle.is-on { color: #fff; background: #d59b3b; border-color: #d59b3b; }
.weights-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.weight-field label { display: block; margin-bottom: 5px; color: var(--ink); font-size: 13px; font-weight: 700; }
.weight-field label small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.weight-input-wrap { position: relative; }
.weight-input-wrap input { width: 100%; height: 43px; padding: 8px 30px 8px 10px; color: var(--ink); background: #fff; border: 1px solid #d2e0e4; border-radius: 8px; }
.weight-input-wrap input:disabled, .field-disabled input { color: #8d8d8d; background: #eeeeee; cursor: not-allowed; }
.weight-input-wrap span { position: absolute; right: 10px; top: 9px; color: var(--muted); font-size: 14px; }
.weight-input-wrap input.invalid { border-color: #b93d3d; }
.weight-error { min-height: 17px; color: #b93d3d; font-size: 10px; }
.weights-total { margin-top: 4px; color: var(--green); font-size: 12px; font-weight: 700; }
.weights-total.invalid { color: #b93d3d; }
.score-heading { margin-top: 16px; }
.score-heading h3 { margin: 0; color: var(--ink); font-size: 17px; }
.score-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
#score-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); background: #fffbed; }
#score-fields:empty { display: none; }

.equation {
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--blue-dark);
  background: #eaf6f7;
  border-right: 4px solid var(--gold);
  border-radius: 9px;
  font-size: 13px;
}

.equation strong { display: block; margin-bottom: 2px; }

.calculate-button {
  display: block;
  width: 100%;
  min-height: 49px;
  margin-top: 17px;
  padding: 10px 16px;
  color: #fff;
  background: #222222;
  border: 0;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 700;
  transition: background .2s, transform .2s;
}

.calculate-button:hover { background: #111111; transform: translateY(-1px); }

.result-card {
  margin-top: 18px;
  padding: clamp(18px, 4vw, 25px);
  background: #fff;
  border: 1px solid #b7b7b7;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(25, 62, 73, .06);
}

.result-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-chart { flex: 0 0 min(100%, 285px); }
.chart-layout { display: flex; align-items: center; justify-content: flex-start; gap: 14px; }
.donut-chart { display: grid; flex: 0 0 118px; place-items: center; width: 118px; height: 118px; background: var(--chart-background); border-radius: 50%; }
.donut-chart::before { grid-area: 1 / 1; width: 68px; height: 68px; background: #fff; border-radius: 50%; content: ""; }
.donut-chart span { z-index: 1; grid-area: 1 / 1; color: #555; font-size: 10px; line-height: 1.35; text-align: center; }
.chart-legend { display: grid; gap: 5px; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 11px; white-space: nowrap; }
.legend-item i { display: inline-block; flex: 0 0 10px; width: 10px; height: 10px; background: var(--legend-color); border-radius: 50%; }
.legend-item small { color: var(--muted); font-size: 10px; }
.legend-disabled { color: #999; }
.legend-disabled i { background: #c8c8c8 !important; }

.result-label { margin: 0 0 2px; color: #808080; font-size: 14px; font-weight: 700; }
.score { margin: 0; color: #9d1111; font-size: clamp(44px, 10vw, 62px); font-weight: 800; line-height: 1.15; }
.result-badge { padding: 5px 9px; color: #000000; background: #ffffff; border-radius: 999px; font-size: 11px; font-weight: 700; }

.result-meta { margin-top: 13px; padding-bottom: 14px; border-bottom: 1px solid #b7b7b7; }
.result-meta strong, .result-meta span { display: block; }
.result-meta strong { font-size: 16px; }
.result-meta span { display: none; color: var(--muted); font-size: 13px; }
.result-weights { margin-top: 12px; padding: 10px 12px; color: var(--ink); background: #f8fbfb; border: 1px solid #b7b7b7; border-radius: 8px; font-size: 12px; }
.result-weights strong, .result-weights span, .result-weights em { display: block; }
.result-weights span { margin-top: 2px; color: var(--muted); }
.result-weights em { margin-top: 3px; color: #9d1111; font-size: 11px; font-style: normal; }

.details { margin-top: 12px; }
.detail-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed #b7b7b7; font-size: 13px; }
.detail-name { font-weight: 700; }
.detail-calculation { color: var(--muted); direction: ltr; text-align: left; white-space: nowrap; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.action { min-height: 41px; padding: 8px 12px; border: 0; border-radius: 8px; color: #fff; font-size: 12px; font-weight: 700; transition: opacity .2s, transform .2s; }
.action:hover { opacity: .88; transform: translateY(-1px); }
.action-print { color: #ffffff; background: #9d1111; }
.action-copy { background: #141d78; }

.privacy-note { margin: 17px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.notice { margin: 15px 0 0; padding: 13px 15px; color: #000000; background: #fffbed; border: 1px solid #b7b7b7; border-radius: 9px; font-size: 11px; }
.visit-counter { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px auto 0; color: var(--ink); font-size: 13px; font-weight: 700; text-align: center; }
.visit-counter-value { min-width: 110px; padding: 7px 12px; color: var(--ink); background: #f4f4f4; border: 1px solid #c9c9c9; border-radius: 7px; direction: ltr; font-variant-numeric: tabular-nums; font-weight: 700; text-align: center; box-sizing: border-box; }
.toast { position: fixed; right: 50%; bottom: 20px; z-index: 99; display: none; padding: 9px 15px; color: #fff; background: #263d46; border-radius: 8px; transform: translateX(50%); font-size: 12px; box-shadow: 0 5px 18px rgba(0,0,0,.18); }
.toast.visible { display: block; }

.print-header { display: none; }

@page {
  margin: 1.5cm;
}

@media (max-width: 580px) {
  .calculator-page { padding: 12px 8px; }
  .calculator-header { padding: 22px 18px; }
  .brand-mark { flex-basis: 45px; width: 45px; height: 45px; border-radius: 12px; font-size: 23px; }
  .fields-grid { grid-template-columns: 1fr; padding: 15px; }
  .weights-heading { display: block; }
  .weights-controls { width: 100%; margin-top: 9px; }
  .reset-weights { margin-top: 0; }
  .weights-grid, #score-fields { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .intro-row { display: block; }
  .privacy-chip { display: inline-block; margin-top: 9px; }
  .detail-row { align-items: flex-start; flex-direction: column; gap: 2px; }
  .detail-calculation { text-align: right; }
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .action { padding-inline: 5px; font-size: 11px; }
  .result-topline { display: block; }
  .result-chart { margin-top: 14px; }
}

@media print {
  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .print-header {
    display: block !important;
    visibility: visible !important;
    margin: 0 0 18px;
    color: #000;
    text-align: center;
  }
  .print-site-title {
    display: block;
    color: #000;
    font-size: 12px;
    text-decoration: none;
  }
  .print-datetime {
    margin-top: 6px;
    color: #555;
    font-size: 11px;
  }
  .print-logo-link {
    display: block;
    width: max-content;
    margin: 0 auto 12px;
  }
  .print-logo {
    display: block !important;
    visibility: visible !important;
    width: 230px;
    max-width: 70vw;
    height: auto;
    border: 0;
  }
  .calculator-page { padding: 0; }
  .calculator-card { border: 0; box-shadow: none; }
  .calculator-header { padding: 16px 0; color: #000; background: #fff; border-bottom: 2px solid #000; }
  .calculator-header .brand-mark {
    flex-basis: 60px;
    width: 60px;
    height: 60px;
    color: #000;
    background: #f2c36b;
    border-radius: 16px;
    font-size: 30px;
  }
  .calculator-header h1, .calculator-header p { color: #000; }
  .calculator-body { padding: 14px 0; background: #fff; }
  form, .intro-row, .privacy-note, .actions, .toast, .privacy-chip, .refresh-page, .weights-panel, .visit-counter { display: none !important; }
  .notice { display: block !important; margin-top: 16px; }
  .result-card { display: block !important; margin: 0; box-shadow: none; }
}
