:root {
  --navy: #0A1B33;
  --blue: #2D6FB7;
  --lightblue: #A9C6E8;
  --silver: #C7CDD6;
  --white: #F2F4F7;
  --ok: #1f7a4d;
  --err: #b02a37;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Montserrat", "Helvetica Neue", Arial, sans-serif;
  color: var(--navy);
  background: var(--white);
  line-height: 1.5;
}

a { color: var(--blue); }

header.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
header.topbar .brand { display: flex; align-items: center; gap: 12px; }
header.topbar img { height: 40px; }
header.topbar .brand strong { font-size: 18px; letter-spacing: .5px; }
header.topbar .brand span { display: block; font-size: 11px; color: var(--lightblue); letter-spacing: 2px; }
header.topbar nav a { color: #fff; margin-left: 18px; text-decoration: none; font-size: 14px; }
header.topbar nav a:hover { color: var(--lightblue); }

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 16px; color: var(--blue); margin: 28px 0 10px; text-transform: uppercase; letter-spacing: 1px; }
.subtitle { color: #4a5b70; margin-top: 0; }

.card {
  background: #fff;
  border: 1px solid var(--silver);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(10,27,51,.06);
}

label { display: block; font-size: 12px; font-weight: 600; color: #4a5b70; margin-bottom: 4px; }
input, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--silver);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--navy);
}
input:focus, select:focus { outline: 2px solid var(--lightblue); border-color: var(--blue); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
.field-wide { grid-column: span 2; }

.btn {
  display: inline-block;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #255a94; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--silver); }
.btn.secondary:hover { background: var(--white); }
.btn.danger { background: transparent; color: var(--err); padding: 4px 8px; font-size: 18px; line-height: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--silver); }
th { background: var(--navy); color: #fff; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:nth-child(even) td { background: #f7f9fc; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--lightblue) !important; color: var(--navy); border-top: 2px solid var(--navy); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.ok { background: #e3f3ea; color: var(--ok); border: 1px solid #bfe3cd; }
.flash.error { background: #fdecee; color: var(--err); border: 1px solid #f3c5cb; }

.toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .field { min-width: 150px; }

.pill { display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; background:var(--lightblue); color:var(--navy); }

/* Login */
.login-wrap { max-width: 360px; margin: 10vh auto; }
.login-wrap .card { text-align: center; }
.login-wrap img { height: 90px; margin-bottom: 8px; }

.muted { color: #6b7a90; font-size: 12px; }

/* Belege-Kacheln */
.beleg-list { display: flex; flex-wrap: wrap; gap: 16px; }
.beleg-item { width: 220px; border: 1px solid #d7dde6; border-radius: 8px; padding: 10px; background: #fff; }
.beleg-item img { width: 100%; height: 150px; object-fit: cover; border-radius: 5px; display: block; }

.beleg-item.klein { width: 130px; padding: 6px; }
.beleg-item.klein img { height: 90px; margin-bottom: 6px; }

/* Ausgaben (Positionen mit Betrag) */
.upload-feld { display: block; border: 2px dashed var(--blue); border-radius: 10px; padding: 16px; text-align: center; color: var(--navy); cursor: pointer; background: #f7fafd; }
.upload-feld input { display: block; width: 100%; margin-top: 12px; }
.ausgabe { border: 1px solid var(--silver); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.ausgabe-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ausgabe-betrag { font-size: 17px; font-weight: 700; white-space: nowrap; }
.ausgabe-aktionen { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ausgabe-aktionen form.upload-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ausgabe-aktionen input[type="file"] { width: auto; max-width: 230px; padding: 5px; font-size: 12px; }
/* Dreipunkt-Menü je Zeile */
details.menu { position: relative; display: inline-block; }
details.menu summary { list-style: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 4px 10px; border-radius: 8px; color: var(--navy); user-select: none; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary:hover, details.menu[open] summary { background: var(--lightblue); }
.menu-liste { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 210px; background: #fff; border: 1px solid var(--silver); border-radius: 10px; box-shadow: 0 6px 18px rgba(10,27,51,.18); padding: 6px; text-align: left; }
.menu-liste a, .menu-liste button { display: block; width: 100%; padding: 9px 12px; border: none; background: none; border-radius: 6px; font: inherit; font-size: 14px; color: var(--navy); text-align: left; text-decoration: none; cursor: pointer; white-space: nowrap; }
.menu-liste a:hover, .menu-liste button:hover { background: var(--white); }
.menu-liste .rot { color: var(--err); }
.menu-liste form { margin: 0; }

.btn.mini { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* --------------------------------------------------------------------- */
/*  Mobil (iPhone Pro Max & kleiner): Tabellen werden zu Karten           */
/* --------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* iOS zoomt bei < 16px Schrift beim Fokus -> auf 16px heben */
  input, select { font-size: 16px; padding: 11px 12px; }

  /* Datum-/Zeitfelder nicht über die volle Breite ziehen (sonst viel Leerraum rechts) */
  input[type="date"], input[type="time"] { width: auto; max-width: 100%; }

  header.topbar { padding: 12px 16px; }
  header.topbar img { height: 32px; }
  header.topbar .brand strong { font-size: 16px; }
  header.topbar nav { width: 100%; }
  header.topbar nav a { margin: 0 16px 0 0; font-size: 15px; }

  main { padding: 18px 16px 56px; }
  h1 { font-size: 20px; }
  .card { padding: 16px 14px; }

  /* Formularraster einspaltig */
  .grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }

  /* Filter-/Aktionsleiste: Buttons volle Breite, gut antippbar */
  .toolbar { gap: 10px; }
  .toolbar .field { min-width: 0; width: 100%; }
  .toolbar .btn { flex: 1 1 auto; text-align: center; padding: 12px 14px; }

  /* Große Datentabellen (Fahrten, Papierkorb) -> je Zeile eine Karte */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr {
    border: 1px solid var(--silver); border-radius: 10px;
    margin-bottom: 12px; padding: 4px 12px; background: #fff;
  }
  table.cards tbody tr:nth-child(even) td { background: transparent; }
  table.cards td {
    border: none; border-bottom: 1px solid #eef1f5;
    padding: 9px 0; text-align: right;
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; white-space: normal; word-break: break-word; min-width: 0;
  }
  table.cards tr td:last-child { border-bottom: none; }
  table.cards td[data-label]::before {
    content: attr(data-label); font-weight: 600; color: #4a5b70;
    font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
    text-align: left; flex: 0 0 auto;
  }
  table.cards tfoot tr { background: var(--lightblue); border-color: var(--navy); }
  table.cards tfoot td { background: transparent !important; font-size: 15px; }
  /* Aktions-Buttons in der Karte mit Fingergröße */
  table.cards td .btn { padding: 8px 14px; font-size: 14px; }
  table.cards td .btn.danger { font-size: 20px; padding: 6px 12px; }

  /* Belege: Kacheln volle Breite */
  .beleg-item { width: 100%; }
  .beleg-item img { height: 220px; }
  .menu-liste a, .menu-liste button { padding: 13px 14px; font-size: 16px; }
  .beleg-item.klein { width: 46%; }
  .beleg-item.klein img { height: 110px; }
  .btn.mini { padding: 9px 12px; font-size: 14px; }
  .ausgabe-aktionen input[type="file"] { max-width: 100%; width: 100%; }

  .hide-mobile { display: none !important; }
}

/* --------------------------------------------------------------------- */
/*  Zeiterfassung                                                         */
/* --------------------------------------------------------------------- */
.laufend-karte { border-color: var(--blue); border-width: 2px; }
.laufend { border: 1px solid var(--silver); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; background: #f7fafd; }
.laufend-kopf { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.laufend-zeit { text-align: right; white-space: nowrap; }
.laufend-zeit .uhr { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--blue); }
.laufend-form { display: flex; gap: 10px; margin-top: 10px; }
.laufend-form input { flex: 1 1 auto; min-width: 0; }
.laufend-fuss { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.btn.stop { background: var(--err); white-space: nowrap; }
.btn.stop:hover { background: #8f222c; }

.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.kachel { width: 100%; height: 100%; text-align: left; background: #fff; border: 1px solid var(--silver); border-left: 5px solid var(--blue); border-radius: 10px; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--navy); display: flex; flex-direction: column; gap: 2px; }
.kachel:hover { background: #f1f6fc; border-color: var(--blue); }
.kachel strong { font-size: 15px; }
.kachel span { font-size: 13px; }

form.zeile { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
form.zeile input[type="text"] { flex: 1 1 240px; width: auto; }
form.zeile label { margin: 0; white-space: nowrap; }
tr.kunde-zeile td { background: #e9f0f9 !important; }

@media (max-width: 640px) {
  .laufend-form { flex-direction: column; }
  .btn.stop { padding: 14px; font-size: 16px; }
  .kacheln { grid-template-columns: 1fr; }
  .kachel { padding: 14px; }
  form.zeile input[type="text"] { flex-basis: 100%; }
}
