/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #2563eb;
  --blue-dark:  #1d4ed8;
  --blue-light: #eff6ff;
  --blue-mid:   #dbeafe;
  --dark:       #1e293b;
  --dark2:      #334155;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --bg:         #f8fafc;
  --white:      #ffffff;
  --red:        #dc2626;
  --red-light:  #fef2f2;
  --green:      #16a34a;
  --green-light:#f0fdf4;
  --orange:     #ea580c;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --sidebar-w:  220px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--dark); background: var(--bg); }
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ── Login ────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e293b 0%, #1e40af 100%); }

.login-card { background: var(--white); border-radius: 16px; padding: 40px; width: 100%; max-width: 380px; box-shadow: 0 20px 40px rgba(0,0,0,.3); }
.login-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.login-card h1 { text-align: center; font-size: 20px; font-weight: 700; color: var(--dark); margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 28px; }

/* ── App Layout ───────────────────────────────────────────── */
.app-body { display: flex; height: 100vh; overflow: hidden; background: var(--bg); }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--dark); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-title { color: white; font-weight: 700; font-size: 15px; }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: rgba(255,255,255,.65); cursor: pointer; transition: all .15s; font-size: 13.5px; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: var(--blue); color: white; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; }
.sidebar-footer span { color: rgba(255,255,255,.5); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.4); padding: 4px; border-radius: 4px; display: flex; }
.btn-logout:hover { color: white; background: rgba(255,255,255,.1); }

/* Main Content */
.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }

.section { display: none; padding: 28px 32px; flex: 1; }
.section.active { display: block; }

/* Page Header */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--dark); }
.page-header p { color: var(--muted); margin-top: 4px; font-size: 13px; }

/* ── Job Bar ──────────────────────────────────────────────── */
.job-bar { background: white; border-bottom: 1px solid var(--border); padding: 10px 32px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.job-bar-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.job-bar-items { display: flex; gap: 12px; flex-wrap: wrap; flex: 1; }

.job-chip { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px 4px 8px; cursor: pointer; min-width: 200px; transition: box-shadow .15s; }
.job-chip:hover { box-shadow: var(--shadow-md); }
.job-chip.running { border-color: var(--blue); }
.job-chip.completed { border-color: var(--green); }
.job-chip.error { border-color: var(--red); }

.job-chip-info { flex: 1; min-width: 0; }
.job-chip-label { font-size: 12px; font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-chip-text { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.job-progress-wrap { display: flex; align-items: center; gap: 6px; }
.job-progress-bar-outer { width: 60px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.job-progress-bar-inner { height: 100%; background: var(--blue); border-radius: 2px; transition: width .3s; }
.job-chip.completed .job-progress-bar-inner { background: var(--green); }
.job-chip.error .job-progress-bar-inner { background: var(--red); }
.job-pct { font-size: 11px; font-weight: 600; color: var(--muted); width: 30px; text-align: right; }

.job-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.job-dot.running { background: var(--blue); animation: pulse 1.5s infinite; }
.job-dot.completed { background: var(--green); }
.job-dot.error { background: var(--red); }
.job-dot.pending { background: var(--muted); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Cards & Panels ───────────────────────────────────────── */
.card { background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--dark); }
.card-body { padding: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Stats */
.stat-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 700; color: var(--dark); margin: 4px 0 2px; }
.stat-unit { font-size: 12px; color: var(--muted); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--dark2); margin-bottom: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

input[type=text], input[type=password], input[type=date], input[type=datetime-local],
input[type=number], input[type=email], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: white; color: var(--dark); transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 80px; }

/* Checkboxen */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: all .15s; user-select: none; }
.checkbox-item:hover { border-color: var(--blue); background: var(--blue-light); }
.checkbox-item input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.checkbox-item.checked { border-color: var(--blue); background: var(--blue-light); }
.checkbox-item span { font-size: 13px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; transition: all .15s; font-size: 13.5px; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: white; color: var(--dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.btn-success:hover { background: #bbf7d0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 10px; }
.btn-icon { padding: 6px; background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; color: var(--muted); display: inline-flex; }
.btn-icon:hover { color: var(--dark); background: var(--bg); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.alert-info { background: var(--blue-light); color: var(--blue); border: 1px solid var(--blue-mid); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; background: var(--bg); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-blue { background: var(--blue-mid); color: var(--blue); }
.badge-green { background: #dcfce7; color: var(--green); }
.badge-red { background: #fee2e2; color: var(--red); }
.badge-orange { background: #ffedd5; color: var(--orange); }
.badge-grey { background: #f1f5f9; color: var(--muted); }

/* ── Tree ─────────────────────────────────────────────────── */
.tree { font-size: 13px; }
.tree-node { user-select: none; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.tree-row:hover { background: var(--bg); }
.tree-toggle { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; font-size: 10px; }
.tree-icon { width: 16px; height: 16px; flex-shrink: 0; }
.tree-label { flex: 1; }
.tree-children { margin-left: 20px; }
.tree-children.collapsed { display: none; }

/* ── Charts ───────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap canvas { max-height: 280px; }

/* ── Progress (Job Detail) ────────────────────────────────── */
.progress-block { margin: 12px 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.progress-label strong { color: var(--dark); }
.progress-outer { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.progress-inner { height: 100%; background: var(--blue); border-radius: 5px; transition: width .4s ease; }
.progress-inner.done { background: var(--green); }
.progress-inner.error { background: var(--red); }

/* ── Result Sections ──────────────────────────────────────── */
.result-section { margin-top: 24px; }
.result-section h3 { font-size: 14px; font-weight: 600; color: var(--dark); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.result-section h3::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* COP Result */
.cop-value { font-size: 48px; font-weight: 800; color: var(--blue); text-align: center; line-height: 1; }
.cop-label { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4px; }
.cop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }

/* Abweichung */
.abw-positive { color: var(--red); font-weight: 600; }
.abw-negative { color: var(--green); font-weight: 600; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: white; border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: white; border-radius: 12px 12px 0 0; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--dark); }
.modal-body { padding: 20px 24px 24px; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 8px 16px; border: none; background: none; cursor: pointer; font-size: 13.5px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab:hover { color: var(--dark); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Divider ──────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state svg { opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }
