/* ── CATReport – App Stylesheet ─────────────────────────────────── */
:root {
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --bg:           #f4f6fa;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1a202c;
  --text-muted:   #718096;
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --success:      #16a34a;
  --success-soft: #f0fdf4;
  --warning:      #d97706;
  --warning-soft: #fffbeb;
  --danger:       #dc2626;
  --danger-soft:  #fef2f2;
  --info:         #0891b2;
  --info-soft:    #ecfeff;
  --sidebar-bg:   #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-act:  #2563eb;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:    0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --mono:         'JetBrains Mono', 'Fira Mono', ui-monospace, monospace;
  --transition:   .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ── App Shell ─────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon  { font-size: 1.5rem; color: var(--primary); }
.brand-name  { font-size: 1rem; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.sidebar-nav { flex: 1; padding: .5rem 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1rem;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px .5rem;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.nav-item svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; opacity: .7; }
.nav-item:hover  { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active svg { opacity: 1; }
.nav-item--primary { background: rgba(37,99,235,.25); color: #93c5fd; margin-top: .25rem; }
.nav-item--primary:hover { background: rgba(37,99,235,.4); color: #bfdbfe; }

.nav-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
  padding: .75rem 1.5rem .25rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .8rem;
  color: #94a3b8;
}
.user-name   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout { color: #94a3b8; flex-shrink: 0; display: flex; align-items: center; }
.user-logout:hover { color: var(--danger); }
.user-logout svg { width: 16px; height: 16px; fill: currentColor; }

/* ── Main Wrapper ──────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-title   { font-size: 1rem; font-weight: 600; color: var(--text); flex: 1; }
.topbar-toggle  { display: none; background: none; border: none; cursor: pointer; padding: .25rem; }
.topbar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  margin: 4px 0;
  border-radius: 2px;
}
.main-content { padding: 1.5rem; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.card-title  { font-size: .9375rem; font-weight: 600; color: var(--text); }
.card-body   { padding: 1.25rem; }
.card-footer { padding: .875rem 1.25rem; border-top: 1px solid var(--border); background: #fafafa; }
.mb-3 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* ── Dashboard Stats ───────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card--success { border-left-color: var(--success); }
.stat-card--info    { border-left-color: var(--info); }
.stat-card--accent  { border-left-color: var(--warning); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--text); }
.stat-label { font-size: .8125rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Table ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fafafa;
}
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--primary-soft); }
.table--compact th { padding: .5rem .875rem; }
.table--compact td { padding: .5rem .875rem; }
.td-actions { display: flex; gap: .375rem; justify-content: flex-end; white-space: nowrap; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.table-info { padding: .625rem 1rem; font-size: .8125rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination { display: flex; gap: .375rem; padding: .875rem 1rem; flex-wrap: wrap; }
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  text-decoration: none;
}
.page-btn:hover        { border-color: var(--primary); color: var(--primary); }
.page-btn--active      { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn--active:hover { color: #fff; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2em .6em;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--info    { background: var(--info-soft);    color: var(--info);    }
.badge--default { background: var(--bg);            color: var(--text-muted); }
.badge--lg      { font-size: .875rem; padding: .3em .8em; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn--primary      { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn--ghost        { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover  { background: var(--bg); border-color: #c8d0dc; }
.btn--success      { background: var(--success); color: #fff; }
.btn--success:hover { background: #15803d; }
.btn--danger       { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #b91c1c; }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: #fecaca; }
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--sm   { padding: .3rem .65rem; font-size: .8125rem; }
.btn--full { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.form-group label { font-size: .8125rem; font-weight: 600; color: var(--text); }
.form-group:last-child { margin-bottom: 0; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=url], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], input[type=file],
select, textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; }
.textarea-full { width: 100%; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.form-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* ── Line Items (Leistungen/Materialien im Formular) ─────────────── */
.line-item {
  display: grid;
  grid-template-columns: 1fr 80px 100px 70px 30px;
  gap: .5rem;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.line-item:last-child { border-bottom: 0; }
.input-qty   { max-width: 80px; }
.input-price { max-width: 100px; }
.input-vat   { max-width: 70px; }
.btn-remove-line {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: .1rem .3rem;
  border-radius: 4px;
  line-height: 1;
  transition: color var(--transition);
}
.btn-remove-line:hover { color: var(--danger); }

/* ── Totals ─────────────────────────────────────────────────────── */
.totals-block { display: flex; flex-direction: column; gap: .5rem; }
.totals-row   { display: flex; justify-content: space-between; align-items: center; font-size: .9375rem; }
.totals-row--gross { font-size: 1.125rem; font-weight: 700; padding-top: .5rem; border-top: 2px solid var(--border); }

/* ── Toolbar (Liste oben) ────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-form { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1; }
.filter-form input, .filter-form select { width: auto; }
.input-search { min-width: 200px; }

/* ── Flash Messages ─────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
  font-weight: 500;
}
.flash--success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.flash--error   { background: var(--danger-soft);  color: var(--danger);  border: 1px solid #fecaca; }
.flash--info    { background: var(--info-soft);    color: var(--info);    border: 1px solid #a5f3fc; }
.flash-close    { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; opacity: .6; line-height: 1; padding: 0; }
.flash-close:hover { opacity: 1; }
.flash.mt-2 { margin-top: .5rem; }

/* ── Modals ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: .9375rem; font-weight: 600; }
.modal-header button { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); line-height: 1; padding: .1rem .3rem; }
.modal-header button:hover { color: var(--danger); }
.modal-body   { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Info Table ─────────────────────────────────────────────────── */
.info-table  { display: flex; flex-direction: column; gap: .4rem; }
.info-row    { display: flex; gap: 1rem; font-size: .875rem; }
.info-row > span:first-child { color: var(--text-muted); min-width: 150px; flex-shrink: 0; }
.notes-display { font-size: .875rem; white-space: pre-wrap; line-height: 1.7; }

/* ── Chip ────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: .25rem .75rem;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 500;
  margin: .2rem .2rem 0 0;
}

/* ── Checkbox Group ─────────────────────────────────────────────── */
.checkbox-group { display: flex; flex-direction: column; gap: .5rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; }
.checkbox-label input[type=checkbox] { width: auto; accent-color: var(--primary); }
.checkbox-label small { color: var(--text-muted); }

/* ── Toggle Switch ───────────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}
.slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.switch input:checked + .slider            { background: var(--primary); }
.switch input:checked + .slider::before   { transform: translateX(18px); }

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .9375rem;
}
.empty-state.small { padding: 1.25rem; }

/* ── Report Header ───────────────────────────────────────────────── */
.report-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.report-meta   { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.report-number { font-size: 1rem; font-weight: 700; background: var(--bg); padding: .2em .6em; border-radius: var(--radius); border: 1px solid var(--border); }
.report-title-display { font-size: 1.125rem; font-weight: 600; }
.report-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Contact Display ─────────────────────────────────────────────── */
.contact-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.contact-block-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: .875rem; color: var(--text-muted); margin-bottom: .75rem; }
.contact-display { padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.contact-display:last-child { border-bottom: 0; }
.contact-display a { color: var(--primary); }

/* ── Settings ────────────────────────────────────────────────────── */
.settings-tabs   { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }
.settings-tab {
  padding: .625rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.settings-tab:hover  { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-panel      { display: none; }
.settings-panel.active { display: block; }
.inline-add-form { display: flex; gap: .5rem; align-items: center; }
.inline-add-form input { max-width: 280px; }
.confirm-text-block { padding: 1.25rem; border-bottom: 1px solid var(--border); }
.confirm-text-block:last-child { border-bottom: 0; }
.upload-preview { margin-bottom: .5rem; }
.align-end { align-items: flex-end; }
.form-grid-2 .form-group { margin-bottom: 0; }

/* ── Link Primary ────────────────────────────────────────────────── */
.link-primary { color: var(--primary); font-weight: 500; }
.link-primary:hover { text-decoration: underline; }

/* ── Code ────────────────────────────────────────────────────────── */
code { font-family: var(--mono); font-size: .85em; background: var(--bg); padding: .1em .4em; border-radius: 4px; border: 1px solid var(--border); }

/* ── Danger Text ─────────────────────────────────────────────────── */
.danger-text { color: var(--danger); font-size: .875rem; background: var(--danger-soft); border: 1px solid #fecaca; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }

/* ── Error Page ───────────────────────────────────────────────────── */
.error-page { text-align: center; padding: 5rem 1.5rem; }
.error-code    { font-size: 6rem; font-weight: 800; color: var(--border); line-height: 1; }
.error-message { font-size: 1.5rem; font-weight: 700; margin: .5rem 0 1rem; }
.error-page p  { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Auth ────────────────────────────────────────────────────────── */
.auth-body    { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-wrapper { width: 100%; max-width: 400px; padding: 1rem; }
.auth-card    { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2.5rem 2rem; }
.auth-logo    { display: flex; align-items: center; gap: .75rem; margin-bottom: 2rem; justify-content: center; }
.auth-logo .brand-icon { font-size: 2rem; color: var(--primary); }
.auth-logo .brand-name { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.auth-heading { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--text); }
.auth-form .form-group { margin-bottom: 1rem; }
.auth-form .btn  { margin-top: .5rem; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; flex-direction: column; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid-2 > [style*="grid-column:span 2"] { grid-column: span 1; }
  .line-item { grid-template-columns: 1fr 60px 80px 55px 28px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-form { flex-direction: column; }
  .filter-form input, .filter-form select { width: 100%; }
}
@media (max-width: 480px) {
  .main-content { padding: 1rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .report-header { flex-direction: column; align-items: flex-start; }
}
