/* ============================================================
   BBC Calculation — Stylesheet
   Ruhiges, technisches "Instrument"-Design. Keine externen Fonts.
   ============================================================ */

:root {
  --ink:       #122733;
  --ink-soft:  #46606d;
  --muted:     #7b8d97;
  --line:      #d9e3e8;
  --line-soft: #edf2f4;
  --bg:        #f3f6f7;
  --surface:   #ffffff;
  --navy:      #0e2a39;
  --navy-2:    #143849;
  --accent:    #0d8f8f;
  --accent-d:  #0a7474;
  --amber:     #a9690f;
  --amber-bg:  #fbf3e6;
  --danger:    #b3261e;
  --ok:        #1d7a4c;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16,40,52,.05), 0 6px 20px rgba(16,40,52,.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
}

.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.unit { color: var(--muted); font-weight: 400; font-size: .82em; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #eaf2f4;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 18px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; letter-spacing: .2px; }
.brand-mark { display: inline-flex; color: var(--accent); filter: saturate(1.3) brightness(1.25); }
.brand-text { font-size: 15.5px; }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: #c4d6dd; text-decoration: none; padding: 7px 11px; border-radius: 7px;
  font-size: 14px; transition: background .15s, color .15s;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.is-active { color: #fff; background: rgba(13,143,143,.28); }
.nav-user {
  margin-left: 8px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.16);
  color: #9fb4bd; font-size: 13.5px;
}
.logout-form { margin: 0; }
.btn-link {
  background: none; border: none; color: #9fb4bd; cursor: pointer;
  font: inherit; font-size: 13.5px; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px;
}
.btn-link:hover { color: #fff; }

/* ---------- Layout shells ---------- */
.main { max-width: 1120px; margin: 0 auto; padding: 26px 18px 40px; }
.footer {
  max-width: 1120px; margin: 0 auto; padding: 18px; color: var(--muted);
  font-size: 12.5px; text-align: center;
}

.flash-stack { max-width: 1120px; margin: 14px auto 0; padding: 0 18px; display: grid; gap: 8px; }
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px;
  border: 1px solid; background: #fff;
}
.flash-error { color: var(--danger); border-color: #f0c9c6; background: #fdf3f2; }
.flash-ok    { color: var(--ok);     border-color: #bfe3cf; background: #f1faf5; }

.page-head { margin-bottom: 22px; }
.page-title { font-size: 22px; margin: 0 0 4px; letter-spacing: -.2px; }
.page-sub { margin: 0; color: var(--ink-soft); max-width: 64ch; font-size: 14.5px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); display: flex; gap: 6px; align-items: baseline; }
.hint { color: var(--muted); font-weight: 400; }
.input {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,143,143,.15); }
.input.num { font-variant-numeric: tabular-nums; }
select.input { appearance: none; background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%237b8d97' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--accent); }
.check-block { padding: 4px 0; }
.check-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; font: inherit; font-weight: 600; font-size: 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { background: #fff; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-d); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e9c4c1; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Auth (login / setup) ---------- */
.auth-wrap { min-height: 62vh; display: grid; place-items: center; padding: 24px 0; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 26px;
}
.auth-title { margin: 0 0 4px; font-size: 21px; letter-spacing: -.2px; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }
.form .btn { margin-top: 6px; width: 100%; }

/* ---------- Calculator grid ---------- */
.calc-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }

.inputs {
  position: sticky; top: 72px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 18px 20px;
}
.input-block { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.input-block:last-of-type { border-bottom: none; }
.block-title {
  margin: 0 0 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--accent-d); font-weight: 700;
}
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-pair .field { margin-bottom: 0; }
.field-note { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Results ---------- */
.results { display: grid; gap: 18px; }

.derived {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  background: var(--navy); color: #dfeaed; border-radius: var(--radius);
  padding: 14px 18px;
}
.derived-label { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: #8fa8b1; }
.derived-val { font-family: var(--mono); font-size: 19px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.derived-formula { margin-left: auto; font-size: 12px; color: #7e98a2; }

.result-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft); background: #fbfdfd;
}
.card-title { margin: 0; font-size: 16px; letter-spacing: -.1px; }
.hero { text-align: right; line-height: 1.1; }
.hero-num {
  display: block; font-family: var(--mono); font-size: 30px; font-weight: 700;
  color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -1px;
}
.hero-label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }

.result-table { width: 100%; border-collapse: collapse; }
.result-table th, .result-table td { padding: 9px 20px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.result-table thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  font-weight: 600; background: #fff; border-bottom: 1px solid var(--line);
}
.result-table tbody th { font-weight: 500; color: var(--ink-soft); font-size: 13.5px; }
.result-table td { color: var(--ink); font-size: 14px; }
.result-table .ta-r, .result-table td { text-align: right; }
.result-table tbody th { text-align: left; }
.result-table tbody tr:last-child td, .result-table tbody tr:last-child th { border-bottom: none; }

.summary { padding: 12px 20px 4px; border-top: 1px solid var(--line); display: grid; gap: 0; }
.sum-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 14px; color: var(--ink-soft); }
.sum-row .num { color: var(--ink); }
.sum-total {
  margin-top: 4px; padding: 11px 12px; border-radius: var(--radius-sm);
  background: var(--amber-bg); color: var(--ink); font-weight: 700; font-size: 15px;
  border: 1px solid #eedcbf;
}
.sum-total .num { color: var(--amber); font-size: 16px; }

.flow { margin: 6px 20px 16px; font-size: 12px; color: var(--muted); font-family: var(--mono); line-height: 1.7; }

/* ---------- Notes ---------- */
.notes { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 4px; }
.notes > summary {
  cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 13.5px; color: var(--ink-soft);
  list-style: none;
}
.notes > summary::-webkit-details-marker { display: none; }
.notes > summary::before { content: "▸ "; color: var(--accent); }
.notes[open] > summary::before { content: "▾ "; }
.notes-body { padding: 4px 16px 14px; font-size: 13px; color: var(--ink-soft); }
.notes-body p { margin: 0 0 10px; }
.notes-body p:last-child { margin-bottom: 0; }

/* ---------- Panels (user manager) ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.panel-title { margin: 0 0 14px; font-size: 14px; font-weight: 700; }
.row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.row-form .field { margin-bottom: 0; min-width: 150px; }
.field-grow { flex: 1 1 200px; }
.row-form .btn { white-space: nowrap; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 480px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.table tbody tr:last-child td { border-bottom: none; }
.ta-r { text-align: right; }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted); font-size: 13px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-admin { background: rgba(13,143,143,.12); color: var(--accent-d); }
.badge-user  { background: #eef2f4; color: var(--ink-soft); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); font-size: 11px; font-weight: 600; }

/* edit popover via <details> */
.edit { position: relative; display: inline-block; }
.edit > summary { list-style: none; cursor: pointer; }
.edit > summary::-webkit-details-marker { display: none; }
.edit-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
  width: 260px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(16,40,52,.16); padding: 14px;
}
.form-tight .field { margin-bottom: 10px; }
.form-tight .btn { width: 100%; margin-top: 2px; }
.form-inline { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.form-inline .btn { width: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .calc-grid { grid-template-columns: 1fr; }
  .inputs { position: static; }
}
@media (max-width: 560px) {
  .topbar-inner { padding: 0 12px; }
  .nav a { padding: 6px 8px; }
  .nav-user { display: none; }
  .main { padding: 18px 12px 32px; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .hero { text-align: left; }
  .derived-formula { margin-left: 0; width: 100%; }
  .field-pair { grid-template-columns: 1fr; }
  .result-table th, .result-table td { padding: 9px 14px; }
}

/* ---------- A11y ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
