/* Baustellen-App – schlankes, mobilfreundliches Layout */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #d9dde3;
  --primary: #d9480f;
  --primary-dark: #b33a0c;
  --topbar: #1f2933;
  --danger: #c0262d;
  --ok: #1f7a3f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary-dark); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
code { background: #eef0f3; padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* Kopfzeile und Menü */
.topbar { background: var(--topbar); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: .5rem 1rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; padding: .35rem 0; }
.menu-toggle {
  display: none; background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 6px; padding: .4rem .8rem; font-size: 1rem;
}
.mainnav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.mainnav a, .nav-button {
  color: #e5e7eb; text-decoration: none; padding: .5rem .75rem; border-radius: 6px;
  font: inherit; background: none; border: 0; cursor: pointer;
}
.mainnav a:hover, .nav-button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.mainnav a.active { background: var(--primary); color: #fff; }
.logout-form { margin: 0; }

@media (max-width: 760px) {
  .js .menu-toggle { display: block; }
  .js .mainnav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: .5rem; }
  .js .mainnav.open { display: flex; }
  .mainnav a, .nav-button { padding: .75rem; text-align: left; width: 100%; }
}

/* Inhalt */
.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; margin-bottom: 1.25rem;
}
.card.highlight { border-left: 4px solid var(--primary); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.breadcrumb { margin: 0 0 .5rem; }
.breadcrumb a { text-decoration: none; }
.grid-main { display: grid; gap: 0 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 860px) { .grid-main { grid-template-columns: 2fr 1fr; } }

/* Anmeldeseiten */
body.guest { display: flex; min-height: 100vh; align-items: center; }
body.guest .container { width: 100%; }
.auth-box { max-width: 420px; margin: 0 auto; }

/* Formulare */
form.narrow { max-width: 560px; }
label { display: block; margin-bottom: 1rem; font-weight: 600; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month],
input[type=search], select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .65rem .75rem;
  font: inherit; font-weight: 400; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 8px; min-height: 46px;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
label.checkbox { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
label.checkbox input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; flex: none; }
.grid-2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters label { margin: 0; flex: 1 1 160px; }
.filters input, .filters select { margin-top: .3rem; }
.filters > input, .filters > select { flex: 1 1 200px; margin-top: 0; }
.filters .btn { flex: none; }
.month-nav { display: flex; gap: .5rem; align-items: center; flex: 1 1 260px; }
.month-nav input { margin: 0; }
.quick-ranges { flex-basis: 100%; display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 46px; padding: .55rem 1.1rem; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f5f6f8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f0c4c6; }
.btn-danger:hover { background: #fdf1f1; }
.btn-small { min-height: 36px; padding: .3rem .7rem; font-size: .875rem; }
.btn-block { width: 100%; }
@media (max-width: 600px) { .btn-block-mobile { width: 100%; } }
.btn[disabled] { opacity: .6; cursor: default; }
form.inline { display: inline; margin: 0; }
.danger-zone { margin: 1rem 0; }

.status-form { display: flex; flex-direction: column; gap: .5rem; }
.status-btn.is-current { border-width: 2px; opacity: 1; }
.status-btn-geplant.is-current { border-color: #2563eb; color: #1e40af; }
.status-btn-in_arbeit.is-current { border-color: var(--primary); color: var(--primary-dark); }
.status-btn-erledigt.is-current { border-color: var(--ok); color: var(--ok); }

/* Hinweise */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-success { background: #edf8f0; border-color: #b9e2c5; color: #14532d; }
.alert-error { background: #fdf1f1; border-color: #f0c4c6; color: #7f1d1d; }
.alert-info { background: #eef4fd; border-color: #c4d7f4; color: #1e3a8a; }

/* Status-Badges */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .8rem; font-weight: 600; vertical-align: middle; white-space: nowrap;
}
.badge-geplant { background: #e0e9fb; color: #1e40af; }
.badge-in_arbeit { background: #fde8dc; color: #9a3412; }
.badge-erledigt { background: #dcf2e3; color: #166534; }
.badge-inactive { background: #e5e7eb; color: #4b5563; }
.status-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.status-pill { text-decoration: none; color: var(--text); padding: .4rem .7rem; border: 1px solid var(--border); border-radius: 999px; }
.overdue { color: var(--danger); font-weight: 600; }

/* Kennzahlen */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.25rem; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; }
.stat-value { display: block; font-size: 1.75rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .875rem; }

/* Listen und Tabellen */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li a {
  display: grid; grid-template-columns: 8.5rem 1fr auto; gap: .5rem; padding: .7rem .25rem;
  border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.entry-list li:last-child a { border-bottom: 0; }
.entry-list li a:hover { background: #f8f9fa; }
.entry-date { color: var(--muted); }
.entry-hours { font-weight: 700; white-space: nowrap; }
@media (max-width: 480px) {
  .entry-list li a { grid-template-columns: 1fr auto; }
  .entry-date { grid-column: 1 / -1; font-size: .85rem; }
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tfoot th { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { margin-left: .25rem; }
.table tr.inactive td { color: var(--muted); }
.total { white-space: nowrap; }

/* Auf dem Handy werden Tabellen zu Karten */
@media (max-width: 700px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td, .table-cards tfoot { display: block; width: 100%; }
  .table-cards tr { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .75rem; }
  .table-cards td { border: 0; padding: .25rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table-cards td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  .table-cards td:empty { display: none; }
  .table-cards td.num { text-align: right; }
  .table-cards td.actions { justify-content: flex-end; padding-top: .5rem; }
  .table-cards tfoot tr { display: flex; justify-content: space-between; border: 0; }
  .table-cards tfoot th { display: inline; padding: 0; }
}

.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.notes { white-space: normal; background: #f8f9fa; padding: .75rem; border-radius: 8px; margin: 0; }

/* Rechnungen */
.badge-type-ausgang { background: #dcf2e3; color: #166534; }
.badge-type-eingang { background: #f1e6fb; color: #6b21a8; }
.badge-inv-offen { background: #fef3c7; color: #92400e; }
.badge-inv-ueberfaellig { background: #fde2e2; color: #991b1b; }
.badge-inv-bezahlt { background: #dcf2e3; color: #166534; }
.overdue-soft { color: #92400e; }
.positive { color: var(--ok); }
.negative { color: var(--danger); }
.details.money dd { margin-bottom: .35rem; }
.gross-preview { margin: -.25rem 0 1rem; font-size: 1.05rem; }

fieldset.segmented { border: 0; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
fieldset.segmented legend { font-weight: 600; font-size: .95rem; margin-bottom: .3rem; padding: 0; }
fieldset.segmented label { margin: 0; position: relative; }
fieldset.segmented input { position: absolute; opacity: 0; }
fieldset.segmented span {
  display: block; padding: .7rem .9rem; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; background: #fff;
}
fieldset.segmented small { display: block; font-weight: 400; color: var(--muted); }
fieldset.segmented input:checked + span { border-color: var(--primary); background: #fff6f1; }
fieldset.segmented input:focus-visible + span { outline: 2px solid var(--primary); }
@media (max-width: 420px) { fieldset.segmented { grid-template-columns: 1fr; } }
input[type=file] { display: block; margin-top: .4rem; font-weight: 400; max-width: 100%; }

.supplier-hint { margin: -.5rem 0 1rem; }
.supplier-hint p { margin: 0; }
.supplier-hint .checkbox { margin: 0; }
[hidden] { display: none !important; }

.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.25rem; }
.tabs a {
  padding: .6rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.lang-switch { text-align: right; font-size: .9rem; margin: 0 0 .5rem; color: var(--muted); }
.inline-form { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.inline-form select { width: auto; min-width: 12rem; margin: 0; }

.copy-row { display: flex; gap: .5rem; }
.copy-row input { margin: 0; }
