:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #111827;
  --accent2: #d6b778;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(17,24,39,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.app-header {
  background: linear-gradient(135deg, #111827 0%, #1f2937 70%, #3b3220 100%);
  color: white;
  padding: 22px 18px 26px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
h1 { margin: 4px 0 6px; font-size: 25px; line-height: 1.12; }
h2 { margin: 0; font-size: 18px; }
p { margin: 0; }
.sub { color: #d1d5db; max-width: 520px; font-size: 14px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--accent2); font-weight: 700; }
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 0;
  background: white;
  padding: 14px 6px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tab.active { color: var(--text); border-color: var(--accent2); }
main { padding: 14px; max-width: 1080px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.card, .result-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.card-title { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact { margin-top: 12px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #374151; }
input, select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  background: white;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(214,183,120,.45); border-color: var(--accent2); }
button {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 11px 14px;
  background: white;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.ghost { background: rgba(255,255,255,.08); color: inherit; border-color: rgba(255,255,255,.35); }
.card button.ghost { color: var(--text); border-color: var(--line); }
button.danger { color: var(--danger); border-color: #fecaca; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; }
.actions.inline { justify-content: flex-start; }
.result-card { display: flex; justify-content: space-between; gap: 14px; align-items: center; border-color: #d6b778; }
#grandTotal { font-size: 28px; margin-top: 4px; }
.breakdown { display: grid; gap: 8px; font-size: 14px; }
.line-item { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding: 9px 0; }
.line-item strong { white-space: nowrap; }
.total-line { font-weight: 900; font-size: 17px; border-bottom: 0; }
.helper { color: var(--muted); font-size: 13px; line-height: 1.45; }
.pill { background: #fef3c7; color: #78350f; border-radius: 999px; padding: 7px 10px; font-size: 12px; font-weight: 800; }
.hidden { display: none !important; }
.mode-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.warnings { color: #92400e; margin-top: 8px; font-size: 13px; }
.records-list { display: grid; gap: 10px; }
.record {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.record-top { display: flex; justify-content: space-between; gap: 10px; }
.record h3 { margin: 0 0 4px; font-size: 16px; }
.record p { color: var(--muted); font-size: 13px; }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.setting-group { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.setting-group h3 { margin: 0 0 10px; font-size: 15px; }
.setting-row { display: grid; grid-template-columns: 1.6fr 1fr; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.steps { padding-left: 20px; line-height: 1.55; }
footer { padding: 20px 14px 34px; text-align: center; color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  .app-header { display: block; }
  .app-header button { margin-top: 14px; width: 100%; }
  .grid.two, .grid.three, .settings-grid { grid-template-columns: 1fr; }
  .card-title, .result-card, .record-top { display: grid; }
  .actions { justify-content: stretch; }
  .actions button { flex: 1 1 auto; }
  .tabs { font-size: 12px; }
  main { padding: 10px; }
  .card, .result-card { border-radius: 16px; padding: 14px; }
}
@media print {
  .tabs, .actions, #settings, #records, #help, footer, #installBtn { display: none !important; }
  body { background: white; }
  .card, .result-card { box-shadow: none; border-color: #ddd; }
  #quote { display: block !important; }
}
