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

:root {
  --teal: #1a7a7a;
  --teal-dark: #135e5e;
  --teal-light: #e8f4f4;
  --red: #d9534f;
  --green: #5cb85c;
  --orange: #f0ad4e;
  --gray: #666;
  --light-gray: #f5f5f5;
  --border: #ddd;
  --white: #fff;
  --black: #222;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--light-gray);
  color: var(--black);
  font-size: 14px;
}

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
}
.login-box {
  background: var(--white);
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  width: 360px;
  text-align: center;
}
.login-box img { width: 120px; margin-bottom: 20px; }
.login-box h2 { margin-bottom: 20px; color: var(--teal); }
.login-box input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
}
.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 600;
}
.login-box button:hover { background: var(--teal-dark); }
.login-error { color: var(--red); margin-bottom: 10px; font-size: 13px; }

/* Layout */
.app-container { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--teal-dark);
  color: var(--white);
  padding: 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo { padding: 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo img { width: 80px; }
.sidebar-logo h3 { font-size: 11px; margin-top: 8px; opacity: 0.8; }
.sidebar nav { padding: 10px 0; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}
.sidebar nav a .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 15px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer a { color: rgba(255,255,255,0.6); text-decoration: none; font-size: 12px; }
.sidebar-footer a:hover { color: var(--white); }

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 30px;
  min-height: 100vh;
}

/* Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}
.page-header h1 { font-size: 22px; color: var(--teal-dark); }

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-dark); }
.btn-success { background: var(--green); color: var(--white); }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--orange); color: var(--white); }
.btn-secondary { background: #888; color: var(--white); }
.btn-secondary:hover { background: #666; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--teal);
  color: var(--teal);
}
.btn-outline:hover { background: var(--teal); color: var(--white); }

/* Tabellen */
.table-container {
  background: var(--white);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--teal);
  color: var(--white);
  padding: 12px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 13px;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tbody tr:hover { background: var(--teal-light); }
tbody tr:last-child td { border-bottom: none; }

/* Status-Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-created { background: #e8daef; color: #6c3483; }
.badge-draft { background: #e0e0e0; color: #555; }
.badge-sent { background: #d4edda; color: #155724; }
.badge-paid { background: #cce5ff; color: #004085; }
.badge-overdue { background: #f8d7da; color: #721c24; }

/* Cards / Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 25px;
}
.stat-card {
  background: var(--white);
  padding: 20px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.stat-card .label { font-size: 12px; color: var(--gray); margin-bottom: 6px; }
.stat-card .value { font-size: 22px; font-weight: 700; color: var(--teal-dark); }
.stat-card .value.red { color: var(--red); }
.stat-card .value.green { color: var(--green); }

/* Formulare */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 13px;
  color: var(--gray);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; color: var(--teal-dark); }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray);
  padding: 0 4px;
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Invoice Items Editor */
.items-table { width: 100%; margin: 10px 0; }
.items-table th {
  background: var(--light-gray);
  color: var(--black);
  padding: 8px;
  font-size: 12px;
  text-align: left;
}
.items-table td { padding: 4px; }
.items-table input, .items-table textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
}
.items-table textarea { min-height: 36px; resize: vertical; }
.items-table .col-qty { width: 60px; }
.items-table .col-price { width: 110px; }
.items-table .col-total { width: 100px; }
.items-table .col-action { width: 40px; }

.item-total-row {
  display: flex;
  justify-content: flex-end;
  padding: 8px 0;
  font-weight: 600;
  font-size: 15px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  color: var(--white);
  font-size: 14px;
  z-index: 2000;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Duplicate Selector */
.duplicate-list {
  max-height: 300px;
  overflow-y: auto;
}
.duplicate-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.duplicate-item:hover { background: var(--teal-light); }
.duplicate-item .inv-info { flex: 1; }
.duplicate-item .inv-number { font-weight: 600; color: var(--teal-dark); }
.duplicate-item .inv-date { font-size: 12px; color: var(--gray); }
.duplicate-item .inv-total { font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo h3, .sidebar nav a span { display: none; }
  .sidebar nav a { justify-content: center; padding: 14px; }
  .main-content { margin-left: 60px; padding: 15px; }
  .form-row { flex-direction: column; }
  .modal { width: 95vw; }
}
