:root {
  --bg-color: #1c1c1e;
  --text-color: #f2f2f7;
  --input-bg: #2c2c2e;
  --button-bg: #0a84ff;
  --button-text: #fff;
  --radius: 12px;
  --padding: 12px 16px;
  --chip-bg: rgba(142,142,147,0.25);
  --chip-color: #aad2ff;
  --result-bg: rgba(142,142,147,0.25);
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  padding: 40px 20px;
  text-align: center;
}


.calculator-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  background: rgba(44, 44, 46, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}


/* --- HEADER --- */
.page-header {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: none;
  
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 32px;
  text-align: center;
}

.page-header .title { font-size: 28px; font-weight: 800; }
.page-header .subtitle { font-size: 16px; font-weight: 600; opacity: 0.65; }

/* --- INPUTS & SELECTS --- */
select, input {
  padding: var(--padding);
  font-size: 16px;
  width: 100%;
  max-width: 400px;
  margin: 0px auto;
  display: block;
  border: none;
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text-color);
}

select {
  appearance: none;
  background-color: var(--input-bg);
  color: var(--text-color);
  border: 1.5px solid transparent;
  background-image: url("data:image/svg+xml,%3Csvg fill='gray' height='20' viewBox='0 0 24 24' width='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.25s;
}
select:focus { border-color: #007aff; outline: none; }

/* --- BUTTONS --- */
button {
  padding: var(--padding);
  font-size: 16px;
  width: 100%;
  max-width: 400px;
  margin: 10px auto;
  border: none;
  border-radius: var(--radius);
  background-color: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
  transition: background-color 0.25s, transform 0.1s;
  display: block;
}
button:hover { 
  background-color: #339aff; 
  transform: translateY(-2px);
}
button:active { background-color: #0066cc; transform: scale(0.98); }

/* --- URGENT BUTTON --- */
.urgent {
  background-color: #ff3b30;
  transition: background-color 0.25s, transform 0.1s;
}
.urgent:hover { background-color: #ff5e57; }
.urgent:active { background-color: #d63031; transform: scale(0.98); }

/* --- FILE LABEL & ICON --- */
.file-label, .file-icon {
  background-color: var(--input-bg);
  color: var(--text-color);
  border-radius: var(--radius);
  cursor: pointer;
}
.file-label {
  display: inline-block;
  padding: var(--padding);
  margin-top: 10px;
}
.file-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  user-select: none;
  font-size: 20px;
  transition: background-color 0.25s;
}
.file-icon:hover { background-color: #007aff; }

.loader {
  width: 16px;
  height: 16px;
  border: 3px solid #e1e1e1;
  border-top: 2px solid #007aff;
  border-radius: 50%;
  border-top: 2px solid #007aff;
  animation: spin 0.9s linear infinite;
  margin: 8px auto 0 auto;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- INPUT WITH ICON --- */
.input-with-icon {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 400px;
  margin: 0px auto;
  gap: 8px;
}
.input-with-icon input[type="number"] {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text-color);
  border: 1.5px solid transparent;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.input-with-icon input[type="number"]:focus { border-color: #007aff; outline: none; }

.input-with-icon select {
  flex: 1;
  height: 48px;
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text-color);
  border: 1.5px solid transparent;
  box-sizing: border-box;
  padding: 0 16px;
}
.input-with-icon select:focus {
  border-color: #007aff;
  outline: none;
}

/* --- RESULT & ETC --- */
#result {
  margin-top: 30px;
  font-size: 18px;
  font-weight: 600;
}
#fileInput { display: none; }
.hidden { display: none; }

/* --- NUMBER INPUTS: No arrows --- */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* --- MANUAL INPUT --- */
#manualInput {
  width: 100% !important;
  max-width: 400px;
  margin: 12px auto;
}

/* --- SPINNER --- */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid #e1e1e1;
  border-radius: 50%;
  border-top: 3px solid #007aff;
  animation: spin 0.9s linear infinite;
  margin: 8px auto 0 auto;
}
@keyframes spin {
  0% { transform: rotate(0deg);}
  100% { transform: rotate(360deg);}
}

/* --- TIP-CHIP --- */
.tip-chip {
  display: inline-block;
  background: var(--chip-bg);
  color: var(--chip-color);
  font-size: 15px;
  padding: 6px 14px;
  border-radius: var(--radius);
  min-height: 24px;
  transition: background 0.2s, color 0.2s;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: none;
}

.tip-text {
  display: inline-block;
}

.result-container {
  background: rgba(44, 44, 46, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-sizing: border-box;
  padding: 12px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: background 0.3s, box-shadow 0.3s;
  text-align: left;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
  flex-wrap: wrap;
  font-size: 16px;
}

.result-row:last-child {
  margin-bottom: 0;
}

.result-row .icon {
  font-size: 20px;
}

.result-row .label {
  font-weight: 600;
}

.result-row .value {
  flex-grow: 1;
  font-weight: 600;
  color: #34c759;
}

/* --- DRAG'N'DROP --- */
.drop-zone {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.drop-zone.active {
  opacity: 1;
  pointer-events: all;
}

.drop-inner {
  text-align: center;
  animation: fadeInUp 0.4s ease forwards;
}

.drop-icon {
  font-size: 64px;
  animation: floatIcon 0.6s ease-in-out infinite alternate,
             pulse 1.2s ease-in-out infinite;
  color: #ffffffcc;
  text-shadow: 0 0 12px #007aff66;
}

.drop-text {
  font-size: 20px;
  margin-top: 16px;
  color: white;
  opacity: 0;
  transform: translateY(12px);
  animation: fadeText 0.5s ease forwards;
  animation-delay: 0.3s;
}

@keyframes floatIcon {
  from { transform: translateY(0px); }
  to   { transform: translateY(-12px); }
}

@keyframes pulse {
  0%   { text-shadow: 0 0 12px #007aff33; }
  50%  { text-shadow: 0 0 20px #007affaa; }
  100% { text-shadow: 0 0 12px #007aff33; }
}

@keyframes fadeText {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip-wrapper {
  position: relative;
}

.tooltip-bubble {
  position: absolute;
  top: 100%;
  margin-top: 8px;
  left: 50%;
  transform: translate(-50%);
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 999;
  max-width: 260px;
  width: max-content;
  word-wrap: break-word;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  border: 1.5px solid #007aff;
}

.tooltip-wrapper:hover .tooltip-bubble {
  opacity: 1;
}

@media (max-width: 480px) {
  .tooltip-bubble {
    max-width: 80vw;
    font-size: 13px;
    padding: 9px 12px;
  }
}

/* Анимация появления результата расчёта */
.result-container {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.result-container.fade-slide-in {
  opacity: 1;
  transform: translateY(0);
}