:root {
  /* Exact Palette from Screenshot */
  --bg-app: #111827;
  --bg-card: #1f2937;
  --bg-input: #374151;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --accent-green: #10b981;
  --accent-blue: #3b82f6;
  --accent-gold: #facc15;
  --border: #374151;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === HEADER === */
.app-header {
  background: var(--bg-card);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1f2937;
  height: 60px;
  flex-shrink: 0;
}

.header-title {
  font-weight: 700;
  font-size: 16px;
}

.version-tag {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  font-weight: 500;
  vertical-align: middle;
}

.header-total {
  text-align: right;
}
.header-total .label {
  display: block;
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.header-total .value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-green);
}

/* === SIDEBAR (Default Hidden - Mobile) === */
.desktop-sidebar {
  display: none;
}

/* === MAIN CONTENT === */
.main-layout {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  padding-bottom: 80px; /* Space for nav */
}

.page {
  display: none;
}
.page.active {
  display: block;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* === CARDS === */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.card-title {
  margin: 0 0 15px 0;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* === INPUTS === */
.input-group {
  margin-bottom: 15px;
}
label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

input,
select {
  width: 100%;
  background: var(--bg-input);
  border: none;
  color: white;
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 15px;
  font-family: "Inter", sans-serif;
  outline: none;
}

input:focus,
select:focus {
  box-shadow: 0 0 0 2px var(--accent-blue);
}

/* Select Arrow Fix */
.select-wrapper {
  position: relative;
}
.select-wrapper::after {
  content: "▼";
  font-size: 10px;
  color: var(--text-muted);
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
select {
  appearance: none;
}

/* === TIME INPUTS === */
.time-row {
  display: flex;
  gap: 12px;
}
/* === DIMENSIONS ROW === */
.dimensions-row {
  display: flex;
  gap: 10px;
}
/* Reuses .input-wrapper and .suffix styles which already exist */
.input-wrapper {
  position: relative;
  flex: 1;
}
.input-wrapper input {
  padding-right: 40px;
}
.input-wrapper .suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

/* === TOGGLE === */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-input);
  transition: 0.4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
}
input:checked + .slider {
  background-color: var(--accent-blue);
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}

/* === DIVIDER === */
.divider {
  height: 1px;
  background: #374151;
  margin: 20px 0;
}

/* === BREAKDOWN === */
.breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text-muted);
}
.breakdown-row span:last-child {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}
.breakdown-row.profit span:last-child {
  color: var(--accent-gold);
}

.final-section {
  text-align: center;
  margin-top: 10px;
}
.final-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.final-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-green);
  display: block;
}

/* === TABLE === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text-muted);
}
th {
  text-align: left;
  padding: 10px 5px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
td {
  padding: 10px 5px;
  border-bottom: 1px solid #37415155;
}
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.card-header-row button {
  background: var(--bg-input);
  border: none;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
}

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-app);
  border-top: 1px solid #1f2937;
  height: 60px;
  display: flex;
}
.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
}
.nav-item.active {
  color: var(--accent-blue);
}

.nav-icon {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 4px;
}
.calc-icon {
  position: relative;
}
.calc-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}
.settings-icon {
  border-radius: 50%;
  border: 2px dashed currentColor;
}

.hidden {
  display: none;
}

/* ========================================= */
/* === DESKTOP LAYOUT (Min Width 1024px) === */
/* ========================================= */
@media (min-width: 1024px) {
  /* Hide Mobile Elements */
  .app-header,
  .bottom-nav {
    display: none;
  }

  /* Layout Structure */
  .main-layout {
    display: flex;
    padding: 0;
    height: 100vh;
    overflow: hidden;
  }

  /* Sidebar Styles */
  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 30px;
  }

  .sidebar-header {
    margin-bottom: 40px;
  }
  .sidebar-header h2 {
    margin: 0;
    font-size: 22px;
    color: white;
  }
  .sidebar-header .version {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .side-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 15px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: 0.2s;
  }
  .side-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
  }
  .side-btn.active {
    background: var(--accent-blue);
    color: white;
  }

  /* Content Area */
  .content-area {
    flex: 1;
    padding: 50px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
  }

  /* Grid Layout for Calculator */
  #calculator.active {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr; /* Inputs slightly wider */
    gap: 30px;
    align-items: start;
  }

  /* Settings Grid */
  .settings-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    align-items: start;
  }

  .materials-card {
    margin-top: 0 !important;
  }

  /* Input Card Tweaks for Desktop */
  .card {
    padding: 30px;
  }

  /* Make Result Card Sticky */
  .result-card {
    position: sticky;
    top: 20px;
    border: 1px solid var(--border);
  }
}

/* === DETAILS TAB STYLES === */
textarea {
  width: 100%;
  background: var(--bg-input);
  border: none;
  color: white;
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 15px;
  font-family: "Inter", sans-serif;
  outline: none;
  resize: vertical;
}

textarea:focus {
  box-shadow: 0 0 0 2px var(--accent-blue);
}

#copyBtn {
  width: 100%;
  background: var(--accent-blue);
  color: white;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  padding: 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

#copyBtn:active {
  background: #2563eb;
  transform: scale(0.98);
}

/* Dynamic Color Inputs */
.color-input {
  margin-bottom: 8px;
}
.color-input:last-child {
  margin-bottom: 0;
}

/* Details Icon for Mobile Nav */
.details-icon {
  border: 2px solid currentColor;
  border-radius: 2px;
  position: relative;
}
.details-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  height: 2px;
  background: currentColor;
  box-shadow:
    0 4px 0 currentColor,
    0 8px 0 currentColor;
}
