:root {
  --primary: #1a6eb5;
  --primary-dark: #1558a0;
  --danger: #d32f2f;
  --success: #2e7d32;
  --warning: #e65100;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #dde1e9;
  --text: #1a1c23;
  --text-muted: #6b7280;
  --nav-bg: #0f2b4d;
  --nav-text: #e8edf5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
             font-size: 14px; color: var(--text); background: var(--bg); }

/* Login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh;
              background: linear-gradient(135deg, #0f2b4d 0%, #1a6eb5 100%); }
.login-box { background: var(--surface); border-radius: 12px; padding: 40px; width: 360px;
             box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-text { font-size: 28px; font-weight: 700; color: var(--primary); letter-spacing: 1px; }
.logo-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Navbar */
.navbar { display: flex; align-items: center; background: var(--nav-bg); color: var(--nav-text);
          padding: 0 16px; height: 52px; position: sticky; top: 0; z-index: 100;
          box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px;
             margin-right: 24px; white-space: nowrap; }
.nav-logo { width: 28px; height: 28px; background: var(--primary); border-radius: 6px;
            display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.nav-tabs { display: flex; gap: 2px; flex: 1; }
.nav-tab { background: transparent; border: none; color: rgba(232,237,245,0.7); padding: 0 16px;
           height: 52px; cursor: pointer; font-size: 14px; transition: all 0.15s;
           border-bottom: 3px solid transparent; }
.nav-tab:hover { color: var(--nav-text); background: rgba(255,255,255,0.08); }
.nav-tab.active { color: #fff; border-bottom-color: #5b9ef0; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.role-badge { background: rgba(255,255,255,0.15); padding: 2px 8px; border-radius: 12px;
              font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Tabs */
.tab-content { display: none; padding: 16px; }
.tab-content.active { display: block; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.toolbar-left { display: flex; gap: 10px; align-items: center; }
.toolbar-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
                  font-size: 13px; background: #fff; cursor: pointer; }
.search-box { padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px;
              width: 240px; font-size: 14px; outline: none; }
.search-box:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,110,181,0.15); }
.result-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* Audit filters */
.audit-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audit-filters input[type="date"],
.audit-filters input[type="text"],
.audit-filters select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
                        font-size: 13px; background: #fff; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border);
              background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th { background: #f0f2f8; padding: 8px 12px; text-align: left; font-weight: 600; font-size: 12px;
     text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
     border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 7px 12px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9ff; }

/* Pfad-Link in Tabelle */
.path-link { cursor: pointer; font-size: 13px; opacity: 0.6; }
.path-link:hover { opacity: 1; }

/* Objekt-Zeilen (blau hinterlegt wie im Excel) */
tr.row-objekt td { background: #d0e8fb; font-weight: 600; }
tr.row-objekt:hover td { background: #b8d8f5; }
tr.row-sch td { background: #ffffff; }
tr.row-sch:hover td { background: #f0f6ff; }

/* Status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px;
         font-weight: 600; white-space: nowrap; }
.badge-bearb  { background: #e3f0ff; color: #1565c0; }
.badge-fertig { background: #e8f5e9; color: #2e7d32; }
.badge-archiv { background: #f5f5f5; color: #616161; }
.badge-temp   { background: #fff3e0; color: #e65100; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px;
       border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
       transition: all 0.15s; background: #f0f2f8; color: var(--text); }
.btn:hover { filter: brightness(0.93); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm      { padding: 5px 10px; font-size: 12px; }
.btn-full    { width: 100%; justify-content: center; }
.btn-icon    { padding: 4px 7px; background: transparent; color: var(--text-muted); font-size: 14px; }
.btn-icon:hover { background: #eef0f6; color: var(--text); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; font-weight: 600; color: var(--text-muted);
               text-transform: uppercase; letter-spacing: 0.4px; }
.field label small { font-size: 10px; font-weight: normal; text-transform: none; }
.field input, .field select, .field textarea { padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; background: #fff; outline: none; font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,110,181,0.12); }
.error-msg { color: var(--danger); font-size: 13px; padding: 8px; background: #ffeaea;
             border-radius: 6px; margin: 8px 0; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex;
         align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-dialog { position: relative; background: var(--surface); border-radius: 10px;
                display: flex; flex-direction: column; max-height: 92vh; width: 600px;
                box-shadow: 0 16px 48px rgba(0,0,0,0.25); }
.modal-xl { width: min(1100px, 98vw); }
.modal-sm { width: 400px; }
.modal-header { display: flex; align-items: center; justify-content: space-between;
                padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer;
               color: var(--text-muted); line-height: 1; padding: 0 4px; }
.modal-body { overflow-y: auto; padding: 20px; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border);
                display: flex; justify-content: flex-end; gap: 10px; }

/* Form sections */
.form-sections { display: flex; flex-direction: column; gap: 20px; }
.form-section { border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.form-section h4 { font-size: 12px; font-weight: 700; text-transform: uppercase;
                   letter-spacing: 0.5px; color: var(--primary); margin-bottom: 14px;
                   display: flex; align-items: center; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.field-wide { grid-column: span 2; }

/* Secrets section */
.secrets-section { border-color: #f0a000; background: #fffdf0; }
.secrets-section h4 { color: #b06800; }
.reveal-btn { font-size: 11px; padding: 3px 8px; }
.secrets-note { font-size: 11px; color: var(--text-muted); font-weight: normal;
                text-transform: none; letter-spacing: 0; }
.secrets-hint { font-size: 12px; color: var(--text-muted); margin-top: 10px;
                padding: 8px; background: rgba(0,0,0,0.04); border-radius: 4px; }

/* Secrets popup (list view) */
.secrets-popup { position: fixed; background: #1a1c23; color: #e8edf5; border-radius: 8px;
                 padding: 0; z-index: 2000; min-width: 280px;
                 box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
.secrets-popup-header { display: flex; justify-content: space-between; align-items: center;
                        padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.secrets-popup-header span { font-weight: 600; font-size: 13px; }
.secrets-popup-header button { background: none; border: none; color: #aaa; font-size: 18px;
                               cursor: pointer; line-height: 1; }
.secrets-popup-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.secret-row { display: flex; flex-direction: column; gap: 2px; }
.secret-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #888; }
.secret-val { font-family: monospace; font-size: 13px; color: #7dd3fc;
              word-break: break-all; min-height: 18px; }
.secret-empty { color: #555; font-style: italic; }

/* Pagination */
.pagination { display: flex; gap: 6px; padding: 12px 0; align-items: center; flex-wrap: wrap; }
.page-btn { padding: 5px 12px; border: 1px solid var(--border); border-radius: 5px;
            background: #fff; cursor: pointer; font-size: 13px; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: #f0f2f8; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1a1c23; color: #fff;
         padding: 12px 20px; border-radius: 8px; font-size: 14px; z-index: 9999;
         opacity: 0; transition: opacity 0.3s; pointer-events: none;
         box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
.toast.show { opacity: 1; }
.toast.toast-success { background: var(--success); }
.toast.toast-error   { background: var(--danger); }

/* Audit */
.audit-create { color: var(--success); font-weight: 600; }
.audit-update { color: var(--primary); font-weight: 600; }
.audit-delete { color: var(--danger); font-weight: 600; }
.audit-login  { color: #6b7280; font-weight: 600; }
.audit-import { color: #9c27b0; font-weight: 600; }

/* Table helpers */
.cell-anlage { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-muted  { color: var(--text-muted); font-size: 12px; }
.col-actions { width: 120px; }

/* Info box */
.info-box { background: #e8f4ff; border: 1px solid #bee3f8; border-radius: 6px;
            padding: 12px 16px; font-size: 13px; color: #1a5276; }

/* Responsive */
@media (max-width: 768px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: span 1; }
  .modal-dialog { width: 98vw; }
  .nav-brand span:last-child { display: none; }
}

/* ── Zellenfarben ─────────────────────────────────────────────────────────── */
td.cell-hl-red    { background: #fde8e8 !important; }
td.cell-hl-yellow { background: #fef9c3 !important; }
td.cell-hl-green  { background: #dcfce7 !important; }

/* Kontextmenü */
.cell-ctx-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  padding: 4px 0;
  min-width: 160px;
  z-index: 9999;
  font-size: 13px;
}
.cell-ctx-item {
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.cell-ctx-item:hover { background: #f0f4ff; }
.cell-ctx-sep {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}
