:root {
  --primary: #ffb320;
  --primary-dark: #e09900;
  --primary-light: #ffd166;
  --primary-text: #1a202c;
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --text: #2d3748;
  --text-muted: #718096;
  --border: #e2e8f0;
  --danger: #e53e3e;
  --success: #38a169;
  --warning: #d69e2e;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }

/* Navbar */
#navbar { background: var(--primary); color: var(--primary-text); display: flex; align-items: center; padding: 0 24px; height: 56px; gap: 24px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.nav-brand { font-weight: 700; font-size: 1.3rem; letter-spacing: 0.5px; line-height: 1; white-space: nowrap; color: var(--primary-text); text-transform: uppercase;}
.nav-brand a { color: var(--primary-text); text-decoration: none; }
.nav-brand img { max-height: 40px; width:auto; }
.nav-links { display: flex; gap: 8px; margin-left: auto; }
.nav-link { color: rgba(26,32,44,0.8); text-decoration: none; padding: 8px 14px; border-radius: 6px; font-size: 0.9rem; transition: background 0.15s; white-space: nowrap; }
.nav-link:hover { background: rgba(0,0,0,0.1); color: var(--primary-text); }
.nav-toggle { display: none; background: none; border: none; color: var(--primary-text); font-size: 1.4rem; cursor: pointer; margin-left: auto; padding: 8px; line-height: 1; }

#navbar-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

@media (max-width: 640px) {
  #navbar { flex-wrap: wrap; height: auto; padding: 0 16px; gap: 0; }
  #navbar-wrapper { flex-wrap: wrap; }
  .nav-brand { padding: 16px 0; }
  .nav-toggle { display: block; padding: 16px 0; margin-left: auto; }
  .nav-links { display: none; flex-direction: column; width: 100%; gap: 2px; padding-bottom: 10px; }
  .nav-links.open { display: flex; }
  .nav-link { padding: 10px 8px; font-size: 0.95rem; color: var(--primary-text); }
}

/* Main layout */
#main-content { max-width: 1100px; margin: 0 auto; padding: 32px 16px; }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; overflow-x: auto; }
.card-title { font-size: 1.2rem; font-weight: 600; color: var(--text); margin-bottom: 16px; border-bottom: 2px solid var(--primary); padding-bottom: 8px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.95rem; transition: border-color 0.15s;
  background: white;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,179,32,0.25); }
.form-row { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 480px) { .form-row { grid-template-columns: 1fr 1fr; } }
@media (min-width: 600px) { .form-row-3 { grid-template-columns: 1fr 1fr 1fr; } }
.password-field { position: relative; }
.password-field input { padding-right: 96px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 6px;
}
.password-toggle:hover { color: var(--text); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 6px; border: none; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }

/* Auth pages */
.auth-container { max-width: 420px; margin: 60px auto; }
.auth-title { font-size: 1.6rem; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 0.9rem; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 0.9rem; }
.auth-footer a { color: var(--primary); text-decoration: none; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #fff5f5; color: var(--danger); border: 1px solid #feb2b2; }
.alert-success { background: #f0fff4; color: var(--success); border: 1px solid #9ae6b4; }
.alert-info { background: #ebf8ff; color: #2b6cb0; border: 1px solid #90cdf4; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:hover td { background: #f7fafc; }

/* Results grid */
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.result-item { background: var(--bg); border-radius: 6px; padding: 12px 16px; }
.result-item .label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.result-item .value { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.result-item .unit { font-size: 0.78rem; color: var(--text-muted); }

/* Wizard steps */
.wizard-steps { display: flex; gap: 0; margin-bottom: 28px; }
.wizard-step { flex: 1; padding: 10px; text-align: center; font-size: 0.85rem; border-bottom: 3px solid var(--border); color: var(--text-muted); }
.wizard-step.active { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.wizard-step.done { border-color: var(--success); color: var(--success); }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-info { background: #ebf8ff; color: #2b6cb0; }
.badge-success { background: #f0fff4; color: var(--success); }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Sections */
.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.section-title { font-size: 1.5rem; font-weight: 700; }

/* Collapsible field groups */
.field-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.field-group-title { padding: 10px 16px; font-weight: 600; font-size: 0.9rem; background: var(--bg); border-radius: var(--radius) var(--radius) 0 0; color: var(--primary); }
.field-group-body { padding: 16px; }

/* Conditional fields */
.field-hidden { display: none !important; }

/* ── Wizard 4-column ──────────────────────────────────────────────────── */
.wz-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.wz-col-hdr { text-align: center; font-weight: 700; font-size: 0.78rem; color: var(--primary); letter-spacing: 0.1em; padding: 6px 0 10px; }
.wz-item { background: white; border: 2px solid var(--border); border-radius: 8px; padding: 10px 8px; margin-bottom: 8px; cursor: pointer; text-align: center; font-size: 0.85rem; line-height: 1.4; transition: border-color 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; align-items: center; }
.wz-img { width: 100%; max-height: 72px; object-fit: contain; margin-bottom: 6px; pointer-events: none; }
.wz-item:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(255,179,32,0.3); }
.wz-sel  { border-color: var(--primary); background: rgba(255,179,32,0.12); color: var(--primary-text); font-weight: 600; }
.wz-dim  { opacity: 0.35; }
@media (max-width: 700px) { .wz-grid { grid-template-columns: repeat(2,1fr); } }

/* ── Calc nav breadcrumb ──────────────────────────────────────────────── */
.calc-nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: white; border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; font-size: 0.85rem; }
.calc-nav span { color: var(--text-muted); }
.calc-nav b { color: var(--text); }

/* ── Calc form blocks ─────────────────────────────────────────────────── */
.cb { background: white; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }
.cb-title { background: var(--bg); padding: 8px 16px; font-weight: 600; font-size: 0.85rem; color: var(--primary); border-bottom: 1px solid var(--border); border-radius: 8px 8px 0 0; }
.cb-body { padding-bottom: 4px; }
.cr { display: grid; grid-template-columns: 1fr; align-items: center; padding: 6px 16px; gap: 6px; }
@media (min-width: 600px) { .cr { grid-template-columns: 1fr 1fr; min-height: 36px; gap: 8px; } }
.cr-label { font-size: 0.83rem; color: var(--text); }
.cr-ctrl { display: flex; }
.cr-input { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.88rem; width: 100%; background: white; }
.cr-input[readonly] { background: var(--bg); color: var(--text-muted); }
.cr-input:focus { outline: none; border-color: var(--primary); }
.cr-select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.88rem; width: 100%; background: white; }
.cr-select:focus { outline: none; border-color: var(--primary); }
.cr-input-select { display: flex; gap: 4px; width: 100%; }
.cr-input-select .cr-input  { flex: 1; min-width: 0; }
.cr-input-select .cr-select { width: auto; min-width: 80px; flex-shrink: 0; }
.div-border { height: 1px; background: var(--border); margin: 0 16px; }

/* ── Results block ────────────────────────────────────────────────────── */
.result-block { background: white; border: 2px solid var(--primary); border-radius: 8px; padding: 20px; margin-top: 12px; }
.result-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.result-label { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.07em; white-space: nowrap; }
.result-dots  { flex: 1; border-bottom: 1px dotted var(--border); min-width: 20px; }
.result-val   { width: 90px !important; }
.rtoggle { font-size: 0.82rem; cursor: pointer; color: var(--text-muted); }
.rtoggle-on   { color: var(--primary); font-weight: 600; text-decoration: underline; }
.rtoggle-sep  { color: var(--text-muted); font-size: 0.82rem; }
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab-btn { background: none; border: none; padding: 8px 16px; cursor: pointer; font-size: 14px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn.tab-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab-btn:hover:not(.tab-active) { color: var(--text); }

/* ── Home page grid ───────────────────────────────────────────────────── */
.home-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 700px) { .home-grid { grid-template-columns: 1fr 1fr; } }
