* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
       color: #222; background: #f5f6f8; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { background: #1f2937; color: #f3f4f6; padding: .6rem 1rem;
          display: flex; align-items: center; gap: 1rem; }
.topbar a { color: #f3f4f6; }
.topbar .brand { font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .page-name { font-weight: 600; font-size: 1.05rem; opacity: .95; }
.topbar .topnav { font-size: 13px; opacity: .9; }
.topbar .topnav:hover { opacity: 1; }

main { padding: 1rem; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
        padding: 1rem; margin-bottom: 1rem; }
.card.narrow-wide { max-width: 640px; margin: 1rem auto; }
.card h2, .card h3 { margin-top: 0; }
.bucket-title { font-size: 1.1rem; }
.card.grand { border: 2px solid #1f2937; }
.muted { color: #6b7280; }
.small { font-size: 12px; }
.note { background: #fef3c7; padding: .4rem .6rem; border-radius: 4px; }
.warn { background: #fee2e2; color: #7f1d1d; padding: .4rem .6rem; border-radius: 4px;
        border-left: 4px solid #b91c1c; }
.banner { margin-bottom: 1rem; display: flex; align-items: center; gap: 1rem;
          flex-wrap: wrap; }
.inline-form { margin: 0; display: inline; }

.row { display: flex; align-items: center; gap: 1rem; }
.actions { margin-top: .8rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.actions form { margin: 0; }

.flashes { margin-bottom: 1rem; }
.flash { padding: .5rem .75rem; border-radius: 4px; margin-bottom: .4rem; font-size: .9rem; }
.flash-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

button { background: #2563eb; color: #fff; border: 0; padding: .45rem .9rem;
         border-radius: 4px; cursor: pointer; font: inherit; }
button:hover { background: #1d4ed8; }
button.primary { background: #16a34a; }
button.primary:hover { background: #15803d; }
button.danger { background: #b91c1c; }
button.danger:hover { background: #991b1b; }
button.small { padding: .2rem .55rem; font-size: 12px; background: #6b7280; }
button.small:hover { background: #4b5563; }

input, select, textarea { padding: .35rem .5rem; border: 1px solid #d1d5db;
                border-radius: 4px; font: inherit; width: 100%; background: #fff; }
input.num { text-align: right; }

a.button { background: #e5e7eb; color: #111; padding: .45rem .9rem;
           border-radius: 4px; text-decoration: none; display: inline-block; }
a.button:hover { background: #d1d5db; text-decoration: none; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .35rem .5rem; border-bottom: 1px solid #e5e7eb;
                               text-align: left; vertical-align: middle; }
table.data th.num, table.data td.num { text-align: right; white-space: nowrap; }
table.data tbody tr:hover { background: #f9fafb; }
table.data td.desc { max-width: 22rem; }
table.kv th { width: 14rem; color: #4b5563; font-weight: 500; }
table.lines input { padding: .25rem .4rem; min-width: 4.5rem; }
table.lines input.rate { min-width: 3.5rem; max-width: 5rem; }
table.lines td.center { text-align: center; }
.save-bar { position: sticky; bottom: 0; background: #f5f6f8;
            padding: .6rem 0; margin-top: 0; }

tr.row-error td { background: #fef2f2; }
tr.row-needs_review td { background: #fffbeb; }

.totals-table { margin-top: .6rem; }
.totals-table thead th { background: #f3f4f6; white-space: nowrap; }
.totals-table td.total-cell { font-weight: 700; }

.status { padding: .15rem .45rem; border-radius: 999px; font-size: 12px;
          background: #e5e7eb; color: #374151; white-space: nowrap; }
.status-needs_review { background: #fef3c7; color: #92400e; }
.status-extracted { background: #dcfce7; color: #166534; }
.status-error { background: #fee2e2; color: #991b1b; }
.status-received { background: #e5e7eb; color: #374151; }
.status-bin { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pdf-pane { background: #111; border-radius: 6px; overflow: hidden;
            position: sticky; top: 1rem; height: calc(100vh - 6rem); }
.pdf-pane embed { width: 100%; height: 100%; border: 0; }
.pdf-pane img.photo { width: 100%; height: 100%; object-fit: contain; }
.form-pane { overflow: auto; }
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .pdf-pane { position: static; height: 60vh; }
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem;
        margin: .6rem 0; }
.grid label { display: flex; flex-direction: column; gap: .2rem; font-size: 12px; color: #4b5563; }
.grid label.wide { grid-column: 1 / -1; }

details.bucket-group > summary { cursor: pointer; font-size: 1.1rem;
  font-weight: 600; padding: .1rem 0; }
details.bucket-group > summary:hover { color: #1d4ed8; }
details.bucket-group[open] > summary { margin-bottom: .6rem; }

.tabs { display: flex; gap: .25rem; margin-bottom: .8rem; border-bottom: 1px solid #e5e7eb; }
.tabs .tab { padding: .4rem .9rem; color: #374151; border-bottom: 2px solid transparent; }
.tabs .tab:hover { color: #111; text-decoration: none; }
.tabs .tab.active { color: #1d4ed8; border-bottom-color: #2563eb; font-weight: 500; }

.login-card { max-width: 380px; margin: 3rem auto; }
.rename-form { display: flex; gap: .4rem; }
.rename-form input { min-width: 10rem; }
button:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }
.checkline { flex-direction: row !important; align-items: center; gap: .5rem !important; }
.checkline input { width: auto; }

details.audit { margin-top: .8rem; }
details.audit summary { cursor: pointer; color: #4b5563; }
details.audit ul { margin: .4rem 0 0 0; padding-left: 1.1rem; }
details.audit li { margin-bottom: .25rem; }

/* Foto-Knopf: als große, klar antippbare Fläche hervorheben. */
.grid label.camera input[type="file"] {
  border: 2px dashed #16a34a; background: #f0fdf4; padding: .8rem .6rem;
}

/* Handy-Ansicht */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: .4rem .8rem; padding: .5rem .8rem; }
  .topbar .page-name { display: none; }
  main { padding: .6rem; }
  /* Breite Tabellen scrollen in der Karte, nicht die ganze Seite. */
  .card { overflow-x: auto; }
  .grid { grid-template-columns: 1fr; }
  /* Unter 16px zoomt iOS beim Antippen automatisch in Formularfelder. */
  input, select, textarea { font-size: 16px; }
}
