/* ---------- Reset / Basis ---------- */
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f4f5f7;
    color: #1a2033;
    line-height: 1.45;
}
a { color: #d75500; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
code { background: #eef; padding: 1px 4px; border-radius: 3px; font-size: .85em; }

/* ---------- Top-Bar / Navigation ---------- */
.topbar {
    display: flex; align-items: center; gap: 1rem;
    background: #fff; border-bottom: 1px solid #e2e5eb;
    padding: .5rem 1rem;
    position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .5rem; color: #1a2033; font-weight: 600; }
.brand img { height: 32px; width: auto; }
.mainnav { display: flex; gap: 0; flex: 1; margin-left: 1rem; flex-wrap: wrap; }
.mainnav a {
    color: #4a5468; padding: .45rem .8rem; border-radius: 6px; font-weight: 500;
}
.mainnav a:hover { background: #f0f2f5; text-decoration: none; }
.mainnav a.active { background: #fff2e6; color: #d75500; }
.userbox { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: #4a5468; }
.userbox small { color: #8892a6; }

/* ---------- Layout ---------- */
.content { max-width: 1200px; margin: 1.4rem auto; padding: 0 1rem 3rem; }
.footer {
    text-align: center; color: #6a7690; font-size: .8rem; padding: 1rem;
    border-top: 1px solid #e2e5eb; background: #fff;
}
.pageheader { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }

/* ---------- Login-Karte ---------- */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1rem;
}
.auth-card {
    background: #fff; padding: 2rem; max-width: 420px; width: 100%;
    border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.auth-logo { max-width: 220px; display: block; margin: 0 auto 1rem; }
.auth-card h1 { text-align: center; margin: 0 0 1rem; }

/* ---------- Cards & Formulare ---------- */
.card {
    background: #fff; border: 1px solid #e2e5eb;
    border-radius: 8px; padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.cardhead {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: .5rem;
}
.cardhead h2 { margin: 0; }
.stack > * + * { margin-top: .8rem; }
.layout-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; }
@media (max-width: 720px) {
    .layout-2col, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
label { display: block; font-size: .85rem; color: #4a5468; font-weight: 500; }
label.checkbox { display: flex; align-items: center; gap: .4rem; margin-top: 1.6rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
    display: block; width: 100%;
    padding: .5rem .7rem; margin-top: .2rem;
    border: 1px solid #d6dae2; border-radius: 5px;
    font: inherit; color: #1a2033; background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid #f9c68a; outline-offset: 0; border-color: #d75500;
}
fieldset { border: 1px solid #d6dae2; border-radius: 6px; padding: .8rem 1rem; margin: 0 0 .8rem; }
legend { padding: 0 .4rem; font-weight: 600; color: #4a5468; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: .5rem .95rem; margin: 0;
    background: #fff; color: #1a2033;
    border: 1px solid #d6dae2; border-radius: 6px;
    font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn-primary { background: #d75500; color: #fff; border-color: #d75500; }
.btn-primary:hover { background: #b84900; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: #4a5468; }
.btn-ghost:hover { background: #f0f2f5; }
.btn-danger { background: #c93636; color: #fff; border-color: #c93636; }
.btn-danger:hover { background: #a72929; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }

/* ---------- Meldungen ---------- */
.flash {
    padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-weight: 500;
}
.flash-success { background: #e8f5eb; color: #256d3a; border: 1px solid #bfe3c9; }
.flash-error   { background: #fbeaea; color: #a11f1f; border: 1px solid #efc0c0; }

/* ---------- Tabellen ---------- */
.table {
    width: 100%; border-collapse: collapse; background: #fff;
    border: 1px solid #e2e5eb; border-radius: 6px; overflow: hidden; margin: .8rem 0;
}
.table th, .table td {
    padding: .55rem .7rem; text-align: left; border-bottom: 1px solid #eef0f4;
    vertical-align: top;
}
.table th { background: #fafbfc; font-weight: 600; font-size: .85rem; color: #4a5468; }
.table tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.right { text-align: right; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: .15rem .5rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; background: #eef; color: #465;
}
.badge-draft        { background: #eef0f4; color: #4a5468; }
.badge-final        { background: #e0f2e5; color: #256d3a; }
.badge-cancelled    { background: #fce8e8; color: #a11f1f; }
.badge-cancellation { background: #fff0dc; color: #a15b0f; }

/* ---------- Dashboard ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.tile { background: #fff; border: 1px solid #e2e5eb; border-radius: 8px; padding: 1rem 1.2rem; }
.tile-label { color: #6a7690; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }
.tile-value { font-size: 1.8rem; font-weight: 600; margin-top: .3rem; }
.quick-actions { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* ---------- Rechnung: Positionen-Editor ---------- */
.positions td { vertical-align: top; }
.positions input, .positions select { padding: .35rem .5rem; font-size: .88rem; margin: 0; }
.positions .mt-2 { margin-top: .3rem; }
.pos-nr { text-align: center; font-weight: 600; color: #6a7690; padding-top: .8rem; }
.pos-del { color: #c93636; }

.totals-panel {
    margin-top: .8rem; padding: .8rem 1rem;
    background: #fafbfc; border-radius: 6px;
    display: flex; flex-direction: column; gap: .25rem;
    max-width: 400px; margin-left: auto;
}
.totals-panel > div { display: flex; justify-content: space-between; gap: 1rem; }
.totals-panel .grand { border-top: 1px solid #d6dae2; padding-top: .35rem; font-size: 1.15rem; }

/* ---------- Speisekarten-Auswahl ---------- */
.menu-tabs { display: flex; gap: .3rem; flex-wrap: wrap; border-bottom: 1px solid #e2e5eb; padding-bottom: .4rem; margin-bottom: .8rem; }
.tab {
    background: #f4f5f7; border: 1px solid transparent;
    padding: .4rem .8rem; border-radius: 6px 6px 0 0; cursor: pointer;
    font: inherit; color: #4a5468;
}
.tab.active { background: #fff; border-color: #e2e5eb; border-bottom-color: #fff; color: #d75500; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; }
.menu-item {
    background: #fff; border: 1px solid #e2e5eb; border-radius: 6px;
    padding: .5rem .7rem; text-align: left; cursor: pointer;
    display: flex; flex-direction: column; gap: .1rem;
    font: inherit; color: inherit;
}
.menu-item:hover { border-color: #d75500; background: #fff8f0; }
.menu-nr { font-size: .75rem; color: #8892a6; }
.menu-name { font-weight: 600; }
.menu-price { font-size: .8rem; color: #4a5468; }

/* ---------- Actions ---------- */
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.sticky-actions {
    position: sticky; bottom: 0; background: rgba(244, 245, 247, .95);
    padding: .6rem; border-top: 1px solid #e2e5eb;
    backdrop-filter: blur(6px);
}
.filterbar { display: flex; gap: .8rem; align-items: end; margin-bottom: 1rem; background: #fff; padding: .8rem; border-radius: 6px; border: 1px solid #e2e5eb; flex-wrap: wrap; }
.filterbar label { flex: 1; min-width: 140px; }
.inline-form { display: flex; gap: .4rem; align-items: end; margin-bottom: 1rem; }
.inline-form input[type=text] { max-width: 250px; }

.empty { color: #6a7690; padding: 1rem; background: #fff; border: 1px dashed #d6dae2; border-radius: 6px; }
.hint  { color: #6a7690; font-size: .85rem; margin: .4rem 0; }
.muted { color: #8892a6; }
.small { font-size: .82rem; }
.pagination { margin-top: 1rem; display: flex; gap: .5rem; align-items: center; }

/* ---------- Rechnungs-Vorschau ---------- */
.invoice-toolbar {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
    margin-bottom: 1.4rem; flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.invoice-preview {
    background: #fff; border: 1px solid #e2e5eb; border-radius: 8px;
    padding: 2rem; max-width: 800px; margin: 0 auto;
}
.preview-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; gap: 2rem; }
.preview-logo { max-height: 70px; width: auto; }
.preview-meta { text-align: right; font-size: .95rem; }
.preview-meta div { margin-bottom: .2rem; }
.preview-sender { font-size: .8rem; color: #6a7690; border-bottom: 1px solid #d6dae2; padding-bottom: .3rem; margin-bottom: .8rem; }
.preview-customer { margin-bottom: 2rem; }
.preview-subtitle { font-weight: 600; margin-bottom: 1rem; }
.preview-items { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.preview-items th { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid #d6dae2; font-weight: 600; }
.preview-items td { padding: .35rem .5rem; vertical-align: top; }
.preview-items tbody tr { border-bottom: 1px dotted #eef0f4; }
.preview-totals { max-width: 340px; margin: 1rem 0 1rem auto; display: flex; flex-direction: column; gap: .2rem; }
.preview-totals > div { display: flex; justify-content: space-between; padding: .15rem 0; }
.preview-totals .grand { border-top: 1px solid #1a2033; padding-top: .3rem; font-weight: 700; font-size: 1.05rem; }
.preview-terms { margin-top: 2rem; font-weight: 600; }
.preview-bank { margin-top: .5rem; line-height: 1.6; }
.preview-footer { margin-top: 2.5rem; text-align: center; font-size: .8rem; color: #6a7690; border-top: 1px solid #d6dae2; padding-top: .6rem; }

/* ---------- Druck ---------- */
@media print {
    .topbar, .footer, .no-print, .invoice-toolbar { display: none !important; }
    body { background: #fff; }
    .content { padding: 0; margin: 0; max-width: none; }
    .invoice-preview { border: none; box-shadow: none; padding: 0; }
}
