/* === Werkstatt-ERP CSS === */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Geist', system-ui, -apple-system, sans-serif;
  background: #faf7f2;
  color: #1a1814;
  font-size: 14px;
  line-height: 1.5;
}
.serif, h1, h2, h3 { font-family: 'Instrument Serif', Georgia, serif; font-weight: normal; }
.mono { font-family: 'JetBrains Mono', monospace; }
.muted { color: #777; }
.strong { font-weight: 500; }
.small { font-size: .8rem; }
.right { text-align: right; }
.center { text-align: center; }
.inline { display: inline; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.mt-4 { margin-top: 1rem; }

a { color: #1a1814; text-decoration: none; }
a:hover { color: #c44536; }
code { font-family: 'JetBrains Mono', monospace; background: #f0ebe2; padding: 1px 6px; border-radius: 3px; font-size: .85em; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0;
  background: #1a1814; color: #d5cfc4;
  display: flex; flex-direction: column;
}
.sidebar-brand { padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid #2c2823; display: flex; gap: .75rem; align-items: center; }
.brand-mark { font-size: 1.5rem; color: #c44536; }
.brand-title { font-family: 'Instrument Serif', serif; font-size: 1.4rem; line-height: 1; color: #faf7f2; }
.brand-sub { font-size: .7rem; color: #999; margin-top: .25rem; }
nav { flex: 1; padding: .75rem 0; }
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1.25rem; color: #a9a397 !important; font-size: .9rem;
  transition: all .15s;
}
.nav-item:hover { color: #faf7f2 !important; }
.nav-item.active { background: #c44536; color: white !important; }
.nav-icon { opacity: .6; font-size: .75rem; width: 1rem; }
.sidebar-footer { padding: 1rem 1.25rem; font-size: .7rem; color: #555; border-top: 1px solid #2c2823; }

.content { flex: 1; overflow: auto; padding: 2rem 2.5rem; max-width: 1200px; }

/* Headers */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 2rem; padding-bottom: 1.25rem; border-bottom: 1px solid #e8e3da;
}
.page-subtitle { font-size: .7rem; text-transform: uppercase; letter-spacing: .15em; color: #777; margin-bottom: .25rem; }
.page-title { font-family: 'Instrument Serif', serif; font-size: 2.25rem; line-height: 1; margin: 0; font-weight: normal; }

/* Flash messages */
.flash-area { margin-bottom: 1rem; }
.flash { padding: .65rem 1rem; border-radius: 3px; font-size: .85rem; margin-bottom: .5rem; }
.flash-success { background: #e3f0e6; color: #2d5d3a; border-left: 3px solid #4a7c59; }
.flash-error { background: #fae3e1; color: #8a2820; border-left: 3px solid #c44536; }
.flash-info { background: #e3ecf5; color: #1a4471; border-left: 3px solid #3b6dad; }

/* Cards */
.card { background: white; border: 1px solid #e8e3da; border-radius: 3px; overflow: hidden; }
.card.no-shadow { box-shadow: none; }
.welcome { padding: 1.5rem; margin-top: 2rem; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  display: block; background: white; border: 1px solid #e8e3da; padding: 1.25rem; border-radius: 3px;
  transition: border-color .15s;
}
.stat-card:hover { border-color: #1a1814; }
.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .15em; color: #777; }
.stat-value { font-family: 'Instrument Serif', serif; font-size: 2.5rem; line-height: 1; margin-top: .5rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; font-size: .85rem; font-weight: 500;
  border-radius: 3px; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; transition: all .15s; text-decoration: none;
}
.btn-primary { background: #1a1814; color: #faf7f2; border-color: #1a1814; }
.btn-primary:hover { background: #c44536; border-color: #c44536; color: white !important; }
.btn-secondary { background: white; color: #1a1814; border-color: #e8e3da; }
.btn-secondary:hover { border-color: #1a1814; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }
.icon-btn {
  background: none; border: none; padding: .25rem .5rem; cursor: pointer;
  color: #888; font-size: 1rem; font-family: inherit; border-radius: 3px;
}
.icon-btn:hover { color: #1a1814; background: #f0ebe2; }
.icon-btn.danger:hover { color: #c44536; }
.text-btn {
  background: none; border: 1px solid #e8e3da; padding: .25rem .5rem;
  cursor: pointer; font-size: .75rem; font-family: inherit;
  border-radius: 3px; color: #555; margin-right: .25rem;
}
.text-btn:hover { border-color: #1a1814; color: #1a1814; }
.actions { white-space: nowrap; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table thead tr { border-bottom: 1px solid #e8e3da; }
.table th {
  text-align: left; padding: .65rem 1rem; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .1em; color: #777; font-weight: 500;
}
.table th.right { text-align: right; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid #e8e3da; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #faf7f2; }
.table.compact th, .table.compact td { padding: .5rem; }
.table.compact td input, .table.compact td select {
  width: 100%; padding: .35rem .5rem; font-size: .85rem;
  border: 1px solid #e8e3da; border-radius: 3px;
  font-family: inherit; background: white;
}
.table.compact td input.right { text-align: right; }
.table.compact td .small-select { width: 100%; padding: .3rem .35rem; font-size: .75rem; }

/* Forms */
.form-card { padding: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
label { display: block; }
label > span {
  display: block; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .1em; color: #555; margin-bottom: .35rem; font-weight: 500;
}
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input:not([type]), select, textarea {
  width: 100%; padding: .55rem .75rem; font-size: .9rem;
  border: 1px solid #e8e3da; border-radius: 3px;
  font-family: inherit; background: white; color: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: #c44536; box-shadow: 0 0 0 3px rgba(196, 69, 54, .12);
}
.form-actions {
  display: flex; justify-content: flex-end; gap: .5rem;
  margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid #e8e3da;
}

/* Search */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; max-width: 32rem; }
.search-bar input { flex: 1; }

/* Empty state */
.empty-state { text-align: center; padding: 4rem 1rem; }
.empty-title { font-family: 'Instrument Serif', serif; font-size: 1.5rem; color: #555; }
.empty-hint { font-size: .85rem; color: #888; margin-top: .5rem; }
.empty-small { padding: 1.5rem; text-align: center; color: #888; font-size: .85rem; }

/* Status badges */
.badge {
  display: inline-block; padding: .15rem .5rem; font-size: .7rem;
  font-weight: 500; border-radius: 2px; text-transform: uppercase; letter-spacing: .05em;
}
.badge-entwurf { background: #e8e3da; color: #555; }
.badge-versendet, .badge-in-arbeit { background: #dde7f1; color: #1a4471; }
.badge-angenommen, .badge-abgeschlossen, .badge-bezahlt { background: #d8e9dc; color: #2d5d3a; }
.badge-abgelehnt, .badge-ueberfaellig { background: #f8d8d4; color: #8a2820; }
.badge-offen { background: #fae8c4; color: #7c5a18; }
.badge-storniert { background: #e8e3da; color: #555; }
.badge-tag {
  display: inline-block; padding: .15rem .4rem; font-size: .65rem;
  background: #f0ebe2; color: #777; border-radius: 2px;
  text-transform: uppercase; letter-spacing: .05em;
}

/* Positions section */
.positions-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 1.5rem; margin-bottom: .5rem;
}
.section-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .15em; color: #555; font-weight: 500; }
.positions { padding: 0; }

/* Totals box */
.totals { padding: 1rem 1.25rem; align-self: start; }
.totals .row { display: flex; justify-content: space-between; align-items: center; padding: .25rem 0; font-size: .85rem; color: #555; }
.totals .row.total-row {
  border-top: 1px solid #e8e3da; margin-top: .35rem; padding-top: .6rem;
  font-size: 1.1rem; font-weight: 600; color: #1a1814;
}
.discount-input { width: 5rem !important; padding: .25rem .5rem !important; font-size: .85rem !important; }

/* === Login / Ersteinrichtung === */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem 1rem; }
.login-wrap { width: 100%; max-width: 24rem; }
.login-brand { display: flex; gap: .85rem; align-items: center; justify-content: center; margin-bottom: 1.5rem; }
.login-card { padding: 1.75rem; }
.login-card label span {
  display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em;
  color: #777; margin-bottom: .3rem;
}
.login-card input { width: 100%; }

/* === Benutzerleiste in der Seitenleiste === */
.sidebar-user {
  padding: .85rem 1.25rem; border-top: 1px solid #2c2823;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.sidebar-user .who { font-size: .8rem; color: #d5cfc4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who small { display: block; font-size: .65rem; color: #777; text-transform: uppercase; letter-spacing: .1em; }
.logout-btn {
  background: none; border: 1px solid #3c372f; color: #a9a397;
  font-family: inherit; font-size: .75rem; padding: .3rem .6rem; border-radius: 3px; cursor: pointer;
  flex-shrink: 0;
}
.logout-btn:hover { border-color: #c44536; color: #faf7f2; background: #c44536; }

/* === Positionen umsortieren === */
.pos-nr { color: #999; font-family: 'JetBrains Mono', monospace; font-size: .8rem; text-align: right; }
.move-btns { display: flex; flex-direction: column; gap: 1px; }
.move-btn {
  background: none; border: none; color: #aaa; cursor: pointer; line-height: .9;
  font-size: .7rem; padding: 1px 3px;
}
.move-btn:hover:not(:disabled) { color: #c44536; }
.move-btn:disabled { opacity: .25; cursor: default; }

/* === Benutzerverwaltung === */
.user-row {
  display: flex; align-items: flex-end; gap: 1rem;
  padding: .85rem 0; border-bottom: 1px solid #eee8de; flex-wrap: wrap;
}
.user-row:last-of-type { border-bottom: none; }
.user-form { display: flex; align-items: flex-end; gap: .75rem; flex: 1; flex-wrap: wrap; }
.user-form label { display: block; margin: 0; min-width: 11rem; flex: 1; }
.user-form label span, .user-meta span {
  display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em;
  color: #777; margin-bottom: .3rem;
}
.user-form input { width: 100%; }
.user-meta { min-width: 9rem; color: #777; padding-bottom: .45rem; }
