:root {
  --navy: #224384;
  --navy-light: #35569C;
  --grey-brand: #A7A5A6;
  --charcoal: #393536;
  --amber: #C98A2A;
  --paper: #F5F5F5;
  --line: #DCDCDC;
  --ink: #26282A;
  --muted: #6B6D6F;
  --danger: #B23A2E;
  --ok: #3A6B4C;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

header.app-header {
  background: #fff;
  color: var(--charcoal);
  padding: 10px 16px calc(10px + env(safe-area-inset-top)) 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

header.app-header .brand {
  display: flex;
  align-items: center;
}

header.app-header img.logo {
  height: 52px;
  width: auto;
  display: block;
}

.stripes {
  height: 6px;
  display: flex;
}
.stripes span { flex: 1; }
.stripes span:nth-child(1) { background: var(--navy); }
.stripes span:nth-child(2) { background: var(--grey-brand); }
.stripes span:nth-child(3) { background: var(--charcoal); }

nav.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

nav.tabs button {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
}

nav.tabs button.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
  font-weight: 600;
}

main {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 14px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  height: 42px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.field textarea { height: auto; min-height: 60px; resize: vertical; }

.field input[type="date"] {
  line-height: 22px;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  text-transform: none;
  margin: 0 0 10px 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

table.positions {
  width: 100%;
  border-collapse: collapse;
}

table.positions th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 4px 8px 4px;
}

table.positions td {
  padding: 4px;
  vertical-align: top;
}

table.positions input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  font-size: 15px;
}

table.positions .qty-col { width: 70px; }
table.positions .del-col { width: 34px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 18px;
  padding: 6px;
  line-height: 1;
}

.add-row-btn {
  margin-top: 8px;
  background: none;
  border: 1px dashed var(--line);
  color: var(--navy);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
}

.sig-wrap {
  position: relative;
}

canvas#sigPad {
  width: 100%;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  touch-action: none;
  display: block;
}

.sig-overlay {
  position: absolute;
  inset: 0;
  background: rgba(245, 245, 245, 0.92);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.sig-overlay.confirmed {
  background: rgba(245, 245, 245, 0.75);
  color: var(--ok);
  font-weight: 600;
}

.sig-overlay.hidden {
  display: none;
}

.sig-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  align-items: center;
  margin-top: 10px;
}

.sig-actions button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}

.sig-actions button#confirmSigBtn {
  color: var(--navy);
  font-weight: 600;
}

.sig-actions button#confirmSigBtn:disabled {
  color: var(--line);
  font-weight: 400;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

button.primary {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
}

button.primary:active { background: var(--navy-light); }

button.secondary {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 6px;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
}

.status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  min-height: 18px;
}

.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child { border-bottom: none; }

.history-item .info .nr {
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
}

.history-item .info .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.history-item .buttons {
  display: flex;
  gap: 6px;
}

.history-item button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--navy);
}

.history-item button.del {
  color: var(--danger);
  border-color: #E7C9C5;
}

.empty-hint {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}

.offline-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--navy-light);
  color: #C9D2DA;
}

.offline-badge.online { background: #2F4A38; color: #B7D8C3; }

/* ---- Passwort-Sperrbildschirm ---- */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lock-box {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.lock-logo {
  width: 100%;
  max-width: 220px;
  height: auto;
  margin-bottom: 24px;
}

.lock-hint {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.lock-box input[type="password"] {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 16px;
  margin-bottom: 12px;
  box-sizing: border-box;
  text-align: center;
}

.lock-box button {
  width: 100%;
}

.lock-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 10px;
}

/* ---- Mailversand (netcup-Version) ---- */
.lock-note { font-size: 12px; color: var(--muted); margin-top: 14px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.banner { background: #FBEAE8; color: var(--danger); padding: 10px 16px; font-size: 14px; border-bottom: 1px solid #F0C9C4; }
.banner button { margin-left: 8px; background: #fff; border: 1px solid var(--danger); color: var(--danger); border-radius: 6px; padding: 4px 10px; font-size: 13px; }
.history-item .mail { font-size: 12px; margin-top: 3px; color: var(--muted); }
.history-item .mail.sent { color: var(--ok); }
.history-item .mail.pending { color: var(--amber); }
.history-item .mail.error { color: var(--danger); }
