/* ─── TOKENS ─── */
:root {
  --bg: #0a0c10;
  --surface: #0f1318;
  --surface-2: #151b22;
  --border: rgba(255,255,255,0.07);
  --border-focus: rgba(210,180,120,0.5);
  --text: #e8e2d6;
  --text-muted: #7a7668;
  --text-dim: #4a4840;
  --gold: #c9a84c;
  --gold-light: #e2c97e;
  --gold-dim: rgba(201,168,76,0.15);
  --teal: #4ec9b0;
  --teal-dim: rgba(78,201,176,0.12);
  --red: #e05c5c;
  --radius: 10px;
  --radius-sm: 6px;
  --font-display: 'DM Serif Display', serif;
  --font-body: 'DM Sans', sans-serif;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── BASE ─── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

/* Grain overlay */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 150px;
}

/* ─── HEADER ─── */
header {
  border-bottom: 1px solid var(--border);
  background: rgba(10,12,16,0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1100px;
  margin: auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  color: var(--gold);
  font-size: 20px;
  animation: spin 12s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.01em;
  color: var(--text);
}
.brand-name em {
  font-style: italic;
  color: var(--gold);
}
.brand-tag {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── LAYOUT ─── */
.container {
  max-width: 1100px;
  margin: auto;
  padding: 40px 32px;
  position: relative;
  z-index: 1;
}
.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .header-inner { padding: 14px 20px; }
  .container { padding: 24px 16px; }
}

/* ─── PANELS ─── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.25;
}

/* ─── LABELS / SECTIONS ─── */
.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gold-dim);
}

/* ─── FIELDS ─── */
.field-group {
  margin-bottom: 16px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 0;
}
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.08);
}
.field-input::placeholder { color: var(--text-dim); }

/* Remove number spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; }

/* ─── FILE UPLOAD ─── */
.file-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--text-muted);
  font-size: 13px;
}
.file-upload:hover {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold-light);
}
.file-icon { font-size: 16px; color: var(--gold); }

/* ─── DIVIDER ─── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

/* ─── COSTS LIST ─── */
.costs-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.cost-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cost-item .field-input {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 8px 8px;
  box-shadow: none !important;
}
.cost-item .field-input:focus { border-color: transparent; }
.cost-item .input-name { flex: 1.6; border-right: 1px solid var(--border) !important; }
.cost-item .input-val  { flex: 1; text-align: right; font-variant-numeric: tabular-nums; }

.btn-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
  flex-shrink: 0;
}
.btn-remove:hover { color: var(--red); background: rgba(224,92,92,0.1); }

/* ─── ADD COST BTN ─── */
.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-add:hover {
  border-color: var(--teal);
  background: var(--teal-dim);
  color: var(--teal);
}
.btn-add-icon { font-size: 17px; line-height: 1; }

/* ─── MARGIN INPUT ─── */
.margin-input-wrap { position: relative; }
.margin-input { padding-right: 42px; }
.pct-badge {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-weight: 600;
  font-size: 13px;
  pointer-events: none;
}

/* ─── CALCULATE BTN ─── */
.btn-calculate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 20px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #c9a84c 0%, #e2c97e 50%, #c9a84c 100%);
  background-size: 200% 200%;
  border: none;
  border-radius: var(--radius-sm);
  color: #1a1400;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-position 0.4s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(201,168,76,0.2);
}
.btn-calculate:hover {
  background-position: right center;
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(201,168,76,0.35);
}
.btn-calculate:active { transform: translateY(0); }
.btn-arrow { font-size: 18px; }

/* ─── PDF BTNS ─── */
.pdf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.btn-pdf {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn-pdf-internal:hover {
  border-color: rgba(78,201,176,0.4);
  color: var(--teal);
  background: var(--teal-dim);
}
.btn-pdf-client:hover {
  border-color: var(--border-focus);
  color: var(--gold-light);
  background: var(--gold-dim);
}

/* ─── RESULT PANEL ─── */
.panel-result {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.panel-result::-webkit-scrollbar { width: 4px; }
.panel-result::-webkit-scrollbar-track { background: transparent; }
.panel-result::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  gap: 14px;
  line-height: 1.7;
}
.result-empty strong { color: var(--text-muted); }
.empty-icon {
  font-size: 32px;
  color: var(--text-dim);
  opacity: 0.4;
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 0.6; }
}

.result-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-price-block {
  text-align: center;
  padding: 20px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.result-price-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.result-price-value {
  font-family: var(--font-display);
  font-size: 44px;
  color: var(--gold-light);
  line-height: 1;
  letter-spacing: -0.01em;
  word-break: break-all;
}
.result-price-currency {
  font-size: 20px;
  vertical-align: super;
  margin-right: 2px;
  color: var(--gold);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}
.result-row:last-child { border-bottom: none; }
.result-row-label { color: var(--text-muted); }
.result-row-value { font-weight: 500; font-variant-numeric: tabular-nums; }
.result-row-value.positive { color: var(--teal); }
.result-row-value.neutral  { color: var(--text); }

/* Breakdown section */
.result-breakdown {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.result-breakdown-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.breakdown-item:last-child { border-bottom: none; }
.breakdown-item span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}