/* App 01 - QAS Premium Calculator */

:root {
  --ink: #111111;
  --paper: #f9f9f9;
  --surface: #ffffff;
  --surface-soft: #f6f4f1;
  --border: rgba(17, 17, 17, .10);
  --border-s: rgba(17, 17, 17, .065);
  --orange: var(--primary-color, #EAB308);
  --gold: #c88728;
  --dim: #6b6b6b;
  --muted: #9ca3af;
  --danger: #b03010;
  --safe: #3a7050;
  --f-ui: var(--font-primary, 'Inter', sans-serif);
  --f-serif: var(--font-heading, 'Playfair Display', serif);
  --f-mono: 'DM Mono', monospace;
  --r: 14px;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, .07);
  --shadow-lg: 0 24px 70px rgba(17, 17, 17, .18);
}

html,
body {
  min-height: 100%;
}

body {
  overflow: hidden;
  background: #050505;
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .65), transparent 62%);
  z-index: 0;
}

.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 700;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0 1.5rem;
  background: rgba(17, 17, 17, .93);
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .16);
  backdrop-filter: blur(14px);
}

.topnav-back,
.topnav-app,
.usage-label {
  color: rgba(255, 255, 255, .72);
  line-height: 1;
}

.topnav-back {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topnav-back:hover,
.topnav-app {
  color: #fff;
}

.topnav-sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, .13);
}

.topnav-app {
  font-family: var(--f-ui);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .01em;
}

.topnav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .85rem;
}

.usage-chips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.chip {
  display: block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .13);
}

.chip.empty {
  background: rgba(255, 255, 255, .20);
  box-shadow: none;
}

.usage-label {
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .06em;
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(320px, 365px) 1fr;
  height: calc(100vh - 68px);
  margin-top: 68px;
  padding: 16px;
  gap: 16px;
}

.sidebar {
  position: relative;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 20px;
  background: rgba(8, 8, 8, .92);
  box-shadow: none;
  backdrop-filter: blur(16px);
}

.sidebar-block {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-block:last-child {
  border-bottom: 0;
}

.blk-label,
.card-title,
.spectrum-title,
.interp-lbl,
.aup-lbl {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.blk-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-bottom: .85rem;
}

.sidebar .blk-label {
  color: rgba(255, 255, 255, .42);
}

.sidebar .field-hint,
.sidebar .parameter-label .field-hint {
  color: rgba(255, 255, 255, .34);
}

.sidebar .parameter-label,
.sidebar .field-label {
  color: rgba(255, 255, 255, .68);
}

.sidebar .parameter-header,
.sidebar .hazard-header {
  border-bottom-color: rgba(255, 255, 255, .08);
}

.sidebar .parameter-header span,
.sidebar .hazard-header span {
  color: rgba(255, 255, 255, .34);
}

.peril-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
}

.peril-tab {
  min-height: 82px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
  color: rgba(255, 255, 255, .62);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .35rem;
  font: 700 .82rem/1 var(--f-ui);
  box-shadow: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, color .2s ease;
}

.peril-tab:hover {
  border-color: rgba(249, 115, 22, .36);
  color: #fff;
  transform: translateY(-1px);
}

.peril-tab.on {
  border-color: transparent;
  background: var(--gradient-1);
  color: #fff;
  box-shadow: 0 12px 28px rgba(249, 115, 22, .28);
}

.peril-tab .ico {
  font-size: 1.45rem;
  line-height: 1;
}

.field {
  margin-bottom: .85rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .38rem;
  color: var(--dim);
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .04em;
}

.field-hint {
  color: var(--muted);
  white-space: nowrap;
}

.inp-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}

.inp {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .82);
  font-family: var(--f-mono);
  font-size: .78rem;
  outline: none;
  padding: .62rem .8rem;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.inp:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, .12);
}

.inp.readonly {
  background: rgba(249, 115, 22, .08);
  color: #A16207;
}

.peril-select {
  color-scheme: dark;
  border-color: rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .82);
}

.parameter-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: .65rem;
  padding: 0 0 .35rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.parameter-header span {
  color: rgba(255, 255, 255, .34);
  font-family: var(--f-mono);
  font-size: .55rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.parameter-header span:last-child {
  text-align: center;
}

.parameter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: center;
  gap: .65rem;
  padding: .34rem 0;
}

.parameter-label {
  min-width: 0;
  color: rgba(255, 255, 255, .68);
  font-family: var(--f-mono);
  font-size: .66rem;
  line-height: 1.35;
}

.parameter-label .field-hint {
  color: rgba(255, 255, 255, .34);
  font-size: .58rem;
  white-space: nowrap;
}

.parameter-row .inp {
  min-height: 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, .82);
  padding: .12rem 0;
  text-align: center;
}

.parameter-row .inp:focus {
  box-shadow: inset 0 -1px 0 rgba(249, 115, 22, .65);
}

.parameter-row .inp.readonly {
  background: transparent;
  color: #FACC15;
}

.sidebar input[type="number"] {
  color-scheme: dark;
}

.sidebar input[type="number"]::-webkit-outer-spin-button,
.sidebar input[type="number"]::-webkit-inner-spin-button {
  opacity: .32;
  filter: invert(1) grayscale(1);
}

.sidebar input[type="number"]:hover::-webkit-outer-spin-button,
.sidebar input[type="number"]:hover::-webkit-inner-spin-button,
.sidebar input[type="number"]:focus::-webkit-outer-spin-button,
.sidebar input[type="number"]:focus::-webkit-inner-spin-button {
  opacity: .52;
}

.sidebar .run-btn {
  box-shadow: none;
}

.sidebar .run-btn:hover {
  box-shadow: 0 10px 24px rgba(249, 115, 22, .25);
}

.sidebar .sidebar-block:last-child div {
  color: rgba(255, 255, 255, .42) !important;
}

.sidebar .sidebar-block:last-child span {
  color: #FACC15 !important;
}

.main {
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.run-btn,
.pro-go {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--f-ui);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: box-shadow .2s ease, transform .2s ease, background .2s ease;
}

.run-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 44px;
  padding: 0 1.1rem;
  background: var(--gradient-1);
  color: #fff;
  box-shadow: 0 10px 24px rgba(249, 115, 22, .28);
}

.run-btn:hover,
.pro-go:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(249, 115, 22, .34);
}

.run-btn:disabled {
  cursor: not-allowed;
  opacity: .62;
  transform: none;
}

.spin-icon {
  display: none;
  animation: spin .7s linear infinite;
}

.run-btn.loading .run-icon {
  display: none;
}

.run-btn.loading .spin-icon {
  display: inline;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.content {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 1rem 0 1rem 1rem;
}

.empty {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  color: var(--dim);
  text-align: center;
}

.usage-chips .chip.empty {
  width: 8px;
  height: 8px;
  min-height: 0;
  display: block;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .20);
  box-shadow: none;
}

.empty-wave {
  color: rgba(249, 115, 22, .45);
  font-family: var(--f-serif);
  font-size: 4rem;
  line-height: 1;
}

.empty-title {
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 800;
}

.empty-sub {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: .72rem;
  line-height: 1.7;
}

#rw {
  display: none;
  flex-direction: column;
  gap: 1.2rem;
}

#rw.show {
  display: flex;
}

.result-context {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1rem;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  background: rgba(8, 8, 8, .92);
}

.result-context span {
  color: rgba(255, 255, 255, .42);
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.result-context strong {
  color: #FACC15;
  font-family: var(--f-ui);
  font-size: .95rem;
  font-weight: 800;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.kpi,
.card,
.spectrum,
.aup-box,
.interp {
  border: 1px solid rgba(17, 17, 17, .08);
  border-radius: 18px;
  background: rgba(255, 255, 255, .93);
  box-shadow: none;
}

.kpi {
  min-height: 138px;
  padding: 1.35rem 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(8, 8, 8, .92);
  border-color: rgba(255, 255, 255, .08);
}

.kpi-meta {
  display: flex;
  align-items: center;
  gap: .42rem;
  margin-bottom: .85rem;
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.kpi-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.kpi-val {
  color: #fff;
  font-family: var(--f-ui);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
}

.kpi-val.accent {
  color: #A16207;
}

.kpi-val.gold {
  color: var(--gold);
}

.kpi-unit {
  margin-top: .65rem;
  color: rgba(255, 255, 255, .42);
  font-family: var(--f-mono);
  font-size: .62rem;
  line-height: 1.35;
}

.spectrum {
  overflow: hidden;
  background: transparent;
  border-color: rgba(255, 255, 255, .06);
}

.spectrum-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: #111;
  color: #fff;
}

.spectrum-title {
  color: #fff;
  font-weight: 800;
}

.spectrum-sub {
  margin-top: .3rem;
  color: rgba(255, 255, 255, .48);
  font-family: var(--f-mono);
  font-size: .62rem;
  line-height: 1.55;
}

.spectrum-body {
  padding: 1rem;
  overflow-x: auto;
  background: rgba(255, 255, 255, .93);
}

.level-row {
  display: grid;
  grid-template-columns: 2.5rem 6rem minmax(150px, 1fr) 5rem 5rem 6rem;
  align-items: center;
  gap: .8rem;
  min-width: 690px;
  margin-top: .55rem;
  padding: .72rem .8rem;
  border: 1px solid var(--border-s);
  border-radius: 14px;
  background: #fff;
  transition: background .15s ease, border-color .15s ease;
}

.level-row:hover {
  background: rgba(249, 115, 22, .035);
}

.level-row.ground {
  border-color: rgba(249, 115, 22, .28);
  background: rgba(249, 115, 22, .06);
}

.level-row.highlight {
  border-color: rgba(200, 135, 40, .30);
  background: rgba(200, 135, 40, .07);
}

.level-n,
.level-energy,
.level-rate,
.level-class,
.level-tag {
  font-family: var(--f-mono);
}

.level-n {
  color: var(--dim);
  font-size: .72rem;
  text-align: center;
}

.level-n strong,
.level-rate {
  color: #A16207;
}

.level-energy,
.level-rate,
.level-class {
  font-size: .74rem;
  text-align: right;
}

.level-energy {
  color: var(--ink);
}

.level-rate {
  font-weight: 700;
}

.level-class {
  color: var(--muted);
}

.level-bar-wrap {
  position: relative;
  height: 6px;
}

.level-bar-bg,
.level-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 999px;
}

.level-bar-bg {
  right: 0;
  background: rgba(17, 17, 17, .10);
}

.level-bar-fill {
  background: var(--orange);
  transition: width .4s ease;
}

.level-bar-fill.dim {
  background: var(--muted);
}

.level-tag {
  padding: .22rem .55rem;
  border-radius: 999px;
  font-size: .56rem;
  letter-spacing: .1em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag-ground {
  background: rgba(249, 115, 22, .13);
  color: #A16207;
}

.tag-solvii {
  background: rgba(200, 135, 40, .16);
  color: var(--gold);
}

.tag-normal {
  background: rgba(17, 17, 17, .06);
  color: var(--dim);
}

.chart-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.card {
  overflow: hidden;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border-s);
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.card-title {
  color: var(--ink);
  font-weight: 800;
}

.card-subtitle {
  color: var(--dim);
  font-family: var(--f-mono);
  font-size: .6rem;
  line-height: 1.4;
}

.chart-area {
  padding: 1rem;
}

.chart-wrap {
  position: relative;
  height: 235px;
}

.aup-box,
.interp {
  padding: 1.1rem 1.2rem;
}

.aup-lbl,
.interp-lbl {
  margin-bottom: .9rem;
  color: #A16207;
}

.aup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
}

.aup-item {
  padding: .9rem;
  border-radius: 14px;
  background: rgba(17, 17, 17, .035);
}

.aup-item-lbl,
.aup-item-unit,
.aup-satisfied,
.aup-violated {
  font-family: var(--f-mono);
}

.aup-item-lbl {
  margin-bottom: .35rem;
  color: var(--dim);
  font-size: .64rem;
}

.aup-item-val {
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 800;
}

.aup-item-val.orange {
  color: #A16207;
}

.aup-item-val.gold {
  color: var(--gold);
}

.aup-item-unit {
  margin-top: .25rem;
  color: var(--muted);
  font-size: .6rem;
  line-height: 1.45;
}

.aup-satisfied,
.aup-violated {
  margin-top: .85rem;
  padding: .68rem .8rem;
  border-radius: 14px;
  font-size: .68rem;
  line-height: 1.5;
}

.aup-satisfied {
  border: 1px solid rgba(58, 112, 80, .22);
  background: rgba(58, 112, 80, .08);
  color: var(--safe);
}

.aup-violated {
  border: 1px solid rgba(176, 48, 16, .22);
  background: rgba(176, 48, 16, .08);
  color: var(--danger);
}

.interp-body {
  color: var(--dim);
  font-size: .92rem;
  line-height: 1.75;
}

.interp-body strong {
  color: var(--ink);
}

.interp {
  background: rgba(8, 8, 8, .92);
  border-color: rgba(255, 255, 255, .08);
}

.interp .interp-lbl {
  color: #FACC15;
}

.interp .interp-body {
  color: rgba(255, 255, 255, .62);
}

.interp .interp-body strong {
  color: #fff;
}

.pro-veil {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(17, 17, 17, .36);
  backdrop-filter: blur(10px);
}

.pro-veil.show {
  display: flex;
}

.pro-card {
  width: min(430px, 100%);
  padding: 2.2rem;
  border-radius: 22px;
  background: #111;
  color: #fff;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .36);
}

.pro-ico {
  margin-bottom: 1rem;
  font-size: 2.2rem;
}

.pro-h {
  margin-bottom: .65rem;
  font-size: 1.8rem;
  font-weight: 800;
}

.pro-p {
  margin-bottom: 1.45rem;
  color: rgba(255, 255, 255, .68);
  font-size: .92rem;
  line-height: 1.7;
}

.pro-go {
  width: 100%;
  min-height: 46px;
  background: var(--gradient-1);
  color: #fff;
}

.pro-skip {
  display: inline-block;
  margin-top: 1rem;
  color: rgba(255, 255, 255, .48);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pro-skip:hover {
  color: rgba(255, 255, 255, .78);
}

@media (max-width: 1180px) {
  .kpi-strip,
  .chart-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .topnav {
    height: auto;
    min-height: 68px;
    flex-wrap: wrap;
    padding: .8rem 1rem;
    gap: .75rem;
  }

  .topnav-right {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 68px);
    margin-top: 92px;
  }

  .main {
    overflow: visible;
  }

  .content {
    height: auto;
    overflow: visible;
  }
}

@media (max-width: 680px) {
  .topnav-sep {
    display: none;
  }

  .topnav-app {
    font-size: 1rem;
  }

  .layout {
    padding: 10px;
    gap: 10px;
    margin-top: 108px;
  }

  .peril-tabs,
  .inp-row,
  .kpi-strip,
  .chart-row,
  .aup-grid {
    grid-template-columns: 1fr;
  }

}
