*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #f5a623;
  --danger: #e74c3c;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SF Mono", "Fira Code", monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand a { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.nav-logo { display: block; height: 30px; width: auto; }
.nav-wordmark { display: block; height: 13px; width: auto; }
.nav-links a { color: var(--text-muted); margin-left: 20px; }
.nav-links a:hover { color: var(--text); }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* Flash */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.flash-notice { background: #1a3a1a; border: 1px solid #2d5a2d; color: #7ec87e; }
.flash-alert  { background: #3a1a1a; border: 1px solid #5a2d2d; color: #c87e7e; }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  text-decoration: none;
  transition: background 0.15s;
}
.btn:hover { background: #2e2e2e; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
.btn-primary:hover { background: #e09510; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #3a1a1a; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-secondary { background: var(--surface2); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; align-items: flex-start; }
.search-input {
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  width: 300px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.status-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
}
.pill:hover, .pill.active { color: var(--text); border-color: var(--accent); background: #2a1f00; text-decoration: none; }

/* Import bar */
.import-bar { margin-bottom: 16px; display: flex; gap: 8px; align-items: center; }
.import-bar input[type="file"] { color: var(--text-muted); font-size: 13px; }

/* Table */
.projects-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.projects-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.projects-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.project-row { cursor: pointer; }
.project-row:hover td { background: var(--surface); }
.project-row:hover td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.project-row:hover td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.mono { font-family: var(--mono); font-size: 12px; }
.text-muted { color: var(--text-muted); }
small { color: var(--text-muted); font-size: 12px; }

/* Status pills */
.status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.status-in-arbeit   { background: #2a2200; border-color: #5a4800; color: #f5c842; }
.status-angebot     { background: #002a2a; border-color: #005555; color: #42c5c5; }
.status-abgeschlossen { background: #002a00; border-color: #005500; color: #7ec87e; }
.status-aquise      { background: #001a3a; border-color: #003080; color: #6699ff; }
.status-abrechnen   { background: #2a003a; border-color: #580080; color: #c07ee8; }
.status-nachfrage   { background: #3a1500; border-color: #7a3000; color: #f08040; }
.status-wartestellung { background: #1a1a3a; border-color: #35356a; color: #9090e0; }
.status-auslieferung { background: #002a0a; border-color: #005520; color: #60d080; }
.status-abgebrochen { background: #2a2a2a; border-color: #555; color: #999; }
.status-intern      { background: #222; border-color: #444; color: #888; }
.status-zukunft     { background: #12283a; border-color: #2f6590; color: #8fd0f5; }
.status-zahlungseingang-erwartet { background: #3a1616; border-color: #7a3434; color: #f08a8a; }

/* Detail */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.detail-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 16px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
dt { color: var(--text-muted); font-size: 12px; white-space: nowrap; padding-top: 1px; }
dd { font-size: 13px; }

/* Form */
.project-form { max-width: 1100px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; margin-bottom: 24px; }
.form-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field select option { background: var(--surface2); }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }
.checkbox-field label { margin-bottom: 0; color: var(--text); }

/* Searchable select (Stimulus combobox) */
.searchable-select { position: relative; }
.searchable-select-list {
  list-style: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.searchable-select-list li {
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
.searchable-select-list li:hover,
.searchable-select-list li:not(.searchable-select-empty):focus {
  background: var(--surface);
}
.searchable-select-list li.searchable-select-empty { color: var(--text-muted); cursor: default; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }

select.status-select {
  width: auto;
  field-sizing: content;
  min-width: 60px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font-family: inherit;
  padding-right: 8px;
}
select.status-select:disabled { opacity: 0.5; cursor: wait; }
select.status-select option { background: #1a1a1a; color: #eee; }

/* Login + logout */
.login-card { max-width: 360px; margin: 80px auto 0; }
.login-card h1 { margin-bottom: 16px; }
.nav-links { display: flex; align-items: center; }
.nav-logout-form { display: inline; margin: 0 0 0 20px; }
.nav-logout {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--text-muted);
}
.nav-logout:hover { color: var(--text); }
