/* KMU Office – Stylesheet im Bexio-Stil */
:root {
    --sidebar-bg: #123243;        /* dunkles Petrol */
    --sidebar-bg-hover: #1a4157;
    --sidebar-active: #0e2836;
    --sidebar-text: #b7c9d3;
    --primary: #7ab929;           /* Bexio-Grün */
    --primary-dark: #689f21;
    --link: #1a7ba8;
    --bg: #eef1f3;
    --card: #ffffff;
    --text: #333f48;
    --muted: #75808a;
    --border: #dde3e8;
    --green: #7ab929;
    --red: #d94f43;
    --orange: #e8a33d;
    --blue: #3596c7;
    --radius: 4px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Roboto, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 13.5px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 500; }

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar { width: 216px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: 56px; }
.brand-logo { background: var(--primary); color: #fff; font-weight: 700; border-radius: 4px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.brand-name { color: #fff; font-weight: 500; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 10.5px; opacity: .65; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 0 10px; }
.sidebar nav a.nav-item, .sidebar nav .nav-group-head {
    display: flex; align-items: center; gap: 11px; color: var(--sidebar-text);
    padding: 10px 16px; font-size: 13px; border-left: 3px solid transparent; cursor: pointer;
}
.sidebar nav a.nav-item:hover, .sidebar nav .nav-group-head:hover { background: var(--sidebar-bg-hover); text-decoration: none; color: #fff; }
.sidebar nav a.nav-item.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--primary); font-weight: 500; }
.nav-ic { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-group-head .caret { margin-left: auto; font-size: 10px; opacity: .6; transition: transform .15s; }
.nav-group.open .caret { transform: rotate(90deg); }
.nav-sub { display: none; background: rgba(0,0,0,.18); }
.nav-group.open .nav-sub { display: block; }
.nav-sub a { display: block; color: var(--sidebar-text); padding: 8px 16px 8px 48px; font-size: 12.5px; border-left: 3px solid transparent; }
.nav-sub a:hover { background: var(--sidebar-bg-hover); color: #fff; text-decoration: none; }
.nav-sub a.active { color: #fff; border-left-color: var(--primary); background: var(--sidebar-active); font-weight: 500; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.userbox strong { color: #fff; display: block; }
.userbox span { opacity: .65; }
.logout { color: var(--sidebar-text); }

/* ---------- Topbar ---------- */
.main { flex: 1; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 0 24px; display: flex; align-items: center; gap: 18px; position: sticky; top: 0; z-index: 30; height: 56px; }
.topbar h1 { font-size: 17px; font-weight: 500; white-space: nowrap; }
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search form { display: flex; align-items: center; background: #f2f5f7; border: 1px solid var(--border); border-radius: 4px; padding: 0 10px; }
.topbar-search input { border: none; background: transparent; padding: 7px 6px; width: 100%; font-size: 13px; font-family: inherit; outline: none; }
.topbar-search button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-date { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* Dropdowns (+ Neu, Benutzer) */
.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 6px 24px rgba(20,40,60,.16); min-width: 210px; padding: 6px 0; z-index: 100; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 8px 16px; color: var(--text); font-size: 13px; }
.dropdown-menu a:hover { background: #f2f7ec; text-decoration: none; color: var(--text); }
.dropdown-menu .divider { border-top: 1px solid var(--border); margin: 6px 0; }
.dropdown-menu .menu-title { padding: 6px 16px 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.content { padding: 20px 24px 60px; max-width: 1320px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; box-shadow: 0 1px 2px rgba(20,40,60,.04); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; background: #fff; }
.card-head h2 { font-size: 14.5px; font-weight: 500; }
.card-body { padding: 18px; overflow-x: auto; }
.card-body.nopad { padding: 0; }
#items-table { min-width: 980px; }

/* ---------- Flash ---------- */
.flash { padding: 10px 15px; border-radius: 4px; margin-bottom: 12px; font-size: 13px; border: 1px solid; }
.flash-success { background: #f1f8e7; color: #4d7c17; border-color: #cde3a8; }
.flash-error { background: #fdeeec; color: #a8352b; border-color: #f3c3be; }
.flash-warning { background: #fdf4e4; color: #9a6712; border-color: #f0d9ab; }

/* ---------- Buttons ---------- */
.btn { display: inline-block; background: #fff; color: var(--text); border: 1px solid #c5ccd3; border-radius: 4px; padding: 7px 14px; font-size: 13px; cursor: pointer; font-family: inherit; line-height: 1.4; }
.btn:hover { background: #f4f6f8; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--red); border-color: #ecc4c0; }
.btn-danger:hover { background: #fdf3f2; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; text-align: center; padding: 9px; }
.btn-new { font-weight: 500; padding: 7px 16px; }
.inline-form { display: inline; }

/* ---------- Tabellen ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 9px 14px; background: #f7f9fa; border-bottom: 1px solid var(--border); font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
table.data td { padding: 9px 14px; border-bottom: 1px solid #edf0f3; vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #f6fbf0; }
table.data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data tr.total td { font-weight: 700; background: #f7f9fa; }

/* ---------- Badges (Status-Chips wie Bexio) ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 500; }
.badge-gray { background: #eceff1; color: #5c6770; }
.badge-blue { background: #e3f1f8; color: #1a6d94; }
.badge-green { background: #eef7e0; color: #558b13; }
.badge-red { background: #fceceb; color: #b03a30; }
.badge-orange { background: #fdf2df; color: #a86f14; }

/* ---------- Formulare ---------- */
label { display: block; margin-bottom: 12px; font-size: 12.5px; font-weight: 500; color: var(--text); }
label input, label select, label textarea, .field input, .field select, .field textarea {
    display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #c5ccd3;
    border-radius: 4px; font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(122,185,41,.3); border-color: var(--primary); }
textarea { resize: vertical; min-height: 68px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; align-items: center; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 7px 10px; border: 1px solid #c5ccd3; border-radius: 4px; font-size: 13px; font-family: inherit; background: #fff; }
.toolbar .spacer { flex: 1; }

/* ---------- Dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 2px rgba(20,40,60,.04); }
.kpi .kpi-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.kpi .kpi-value { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi.green .kpi-value { color: var(--green); }
.kpi.red .kpi-value { color: var(--red); }
.kpi.orange .kpi-value { color: var(--orange); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Pager ---------- */
.pager { display: flex; gap: 6px; padding: 12px 18px; }
.pager a { padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.pager a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Positionen-Editor ---------- */
#items-table td { padding: 6px 6px; vertical-align: top; }
#items-table input, #items-table textarea, #items-table select { margin-top: 0; padding: 6px 8px; font-size: 13px; }
#items-table textarea { min-height: 38px; }
#items-table .drag { cursor: grab; color: var(--muted); text-align: center; }
.totals-box { margin-left: auto; max-width: 340px; margin-top: 14px; }
.totals-box table { width: 100%; font-size: 13px; }
.totals-box td { padding: 5px 8px; }
.totals-box td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals-box tr.grand td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--text); }

/* ---------- Login ---------- */
.auth-body { background: #123243; min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center; padding: 20px; font-family: Roboto, -apple-system, 'Segoe UI', sans-serif; }
.auth-card { background: #fff; border-radius: 6px; padding: 34px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand h1 { font-size: 18px; font-weight: 500; }
.auth-card h3 { margin: 18px 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.auth-card code { background: #f2f5f7; padding: 2px 6px; border-radius: 3px; }

/* ---------- Detail ---------- */
.def-list { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 13px; }
.def-list dt { color: var(--muted); }
.def-list dd { margin: 0; }
.doc-status-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Suche ---------- */
.search-group h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .content { padding: 0; max-width: none; }
    .card { border: none; }
    body { background: #fff; }
}
@media (max-width: 900px) {
    .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
    .content { padding: 14px; }
    .topbar-search { display: none; }
}
