/* ── Reset & Base ────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#f4f5f7;--surface:#fff;--border:#dfe1e6;
  --text:#172b4d;--text-muted:#6b778c;
  --primary:#c0392b;--primary-hover:#a93226;--primary-light:#fadbd8;
  --accent:#2980b9;--accent-hover:#2471a3;
  --success:#27ae60;--warning:#f39c12;--danger:#e74c3c;
  --sidebar-bg:#1a1a2e;--sidebar-text:#e0e0e0;--sidebar-active:#c0392b;
  --radius:6px;--shadow:0 1px 3px rgba(0,0,0,.08);
  --font:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
}
html{font-size:14px}
body{font-family:var(--font);color:var(--text);background:var(--bg);line-height:1.5;min-height:100vh}
a{color:var(--accent);text-decoration:none}
a:hover{color:var(--accent-hover);text-decoration:underline}

/* ── Layout ─────────────────────────────────────────────── */
.layout{display:flex;min-height:100vh}
.sidebar{width:240px;background:var(--sidebar-bg);color:var(--sidebar-text);display:flex;flex-direction:column;position:fixed;top:0;left:0;bottom:0;z-index:100;transition:transform .2s}
.sidebar__brand{padding:1.2rem 1rem;font-size:1.15rem;font-weight:700;color:#fff;border-bottom:1px solid rgba(255,255,255,.08);display:flex;align-items:center;gap:.6rem}
.sidebar__brand span{font-size:1.4rem}
.sidebar__nav{flex:1;padding:.6rem 0}
.sidebar__link{display:flex;align-items:center;gap:.7rem;padding:.65rem 1.2rem;color:var(--sidebar-text);font-size:.92rem;border-left:3px solid transparent;transition:all .15s}
.sidebar__link:hover{background:rgba(255,255,255,.06);text-decoration:none;color:#fff}
.sidebar__link--active{background:rgba(255,255,255,.08);border-left-color:var(--sidebar-active);color:#fff;font-weight:600}
.sidebar__link svg,.sidebar__link .icon{width:18px;height:18px;flex-shrink:0;opacity:.7}
.sidebar__footer{padding:1rem;border-top:1px solid rgba(255,255,255,.08);font-size:.82rem}
.sidebar__footer a{color:var(--sidebar-text)}

.main{margin-left:240px;flex:1;padding:1.8rem 2rem;min-width:0}

/* ── Page Header ────────────────────────────────────────── */
.page-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:1.5rem;flex-wrap:wrap;gap:.8rem}
.page-header h1{font-size:1.5rem;font-weight:700}

/* ── Card ───────────────────────────────────────────────── */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);padding:1.4rem;margin-bottom:1.2rem}
.card--flush{padding:0}
.card__header{padding:1rem 1.4rem;border-bottom:1px solid var(--border);font-weight:600;display:flex;align-items:center;justify-content:space-between}

/* ── Table ──────────────────────────────────────────────── */
table{width:100%;border-collapse:collapse}
th,td{padding:.6rem .8rem;text-align:left;border-bottom:1px solid var(--border)}
th{background:var(--bg);font-weight:600;font-size:.82rem;text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);position:sticky;top:0}
tr:hover td{background:rgba(0,0,0,.015)}
.table-wrap{overflow-x:auto}

/* ── Buttons ────────────────────────────────────────────── */
.btn{display:inline-flex;align-items:center;gap:.4rem;padding:.5rem 1rem;border:none;border-radius:var(--radius);font-size:.88rem;font-weight:500;cursor:pointer;transition:all .15s;line-height:1.4}
.btn--primary{background:var(--primary);color:#fff}.btn--primary:hover{background:var(--primary-hover)}
.btn--accent{background:var(--accent);color:#fff}.btn--accent:hover{background:var(--accent-hover)}
.btn--success{background:var(--success);color:#fff}.btn--success:hover{background:#219a52}
.btn--danger{background:var(--danger);color:#fff}.btn--danger:hover{background:#c0392b}
.btn--outline{background:transparent;border:1px solid var(--border);color:var(--text)}.btn--outline:hover{background:var(--bg)}
.btn--sm{padding:.35rem .7rem;font-size:.8rem}
.btn--icon{padding:.4rem;border-radius:var(--radius)}
.btn:disabled{opacity:.5;cursor:not-allowed}

/* ── Forms ──────────────────────────────────────────────── */
.form-group{margin-bottom:1rem}
.form-group label{display:block;margin-bottom:.3rem;font-weight:600;font-size:.85rem;color:var(--text-muted)}
.form-control{width:100%;padding:.5rem .7rem;border:1px solid var(--border);border-radius:var(--radius);font-size:.9rem;font-family:var(--font);transition:border-color .15s}
.form-control:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px rgba(41,128,185,.15)}
select.form-control{appearance:none;background:var(--surface) url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b778c'/%3E%3C/svg%3E") no-repeat right .7rem center/10px}
textarea.form-control{min-height:80px;resize:vertical}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
.form-actions{display:flex;gap:.6rem;margin-top:1.2rem}

/* ── Badges / Tags ──────────────────────────────────────── */
.badge{display:inline-block;padding:.15rem .5rem;border-radius:10px;font-size:.75rem;font-weight:600;line-height:1.4}
.badge--active{background:#d5f5e3;color:#1e8449}
.badge--inactive{background:#fadbd8;color:#922b21}
.badge--info{background:#d6eaf8;color:#1a5276}
.badge--warning{background:#fdebd0;color:#935116}
.badge.badge--dg{font-size:.78rem;font-weight:700;background:#dc2626;color:#fff;border-radius:4px}
.badge.badge--dg-v{font-size:.78rem;font-weight:700;background:#1e40af;color:#fff;border-radius:4px}
.badge.badge--dg-gold{font-size:.78rem;font-weight:700;background:#fbbf24;color:#1f2937;border:1.5px solid #dc2626;border-radius:4px}
.badge.badge--dg-v-gold{font-size:.78rem;font-weight:700;background:#fbbf24;color:#1f2937;border:1.5px solid #1e40af;border-radius:4px}
.badge.badge--dg-goldtext{font-size:.78rem;font-weight:700;background:#dc2626;color:#fbbf24;border-radius:4px}
.badge.badge--dg-v-goldtext{font-size:.78rem;font-weight:700;background:#1e40af;color:#fbbf24;border-radius:4px}
.badge.badge--dg-jfm{font-size:.78rem;font-weight:700;background:#fff;color:#1f2937;border:1.5px solid #1f2937;border-radius:4px}
.badge.badge--dg-ft{font-size:.78rem;font-weight:700;background:#78350f;color:#fff;border-radius:4px}
.badge.badge--dg-bfarzt{font-size:.78rem;font-weight:700;background:#fbbf24;color:#1f2937;border:1.5px solid #1f2937;border-radius:4px}

/* ── Alert / Toast ──────────────────────────────────────── */
.alert{padding:.8rem 1rem;border-radius:var(--radius);margin-bottom:1rem;font-size:.9rem;border:1px solid transparent}
.alert--success{background:#d5f5e3;color:#1e8449;border-color:#a9dfbf}
.alert--error{background:#fadbd8;color:#922b21;border-color:#f5b7b1}
.alert--info{background:#d6eaf8;color:#1a5276;border-color:#aed6f1}
.alert--warning{background:#fdebd0;color:#935116;border-color:#f8c471}

/* ── Dashboard Grid ─────────────────────────────────────── */
.dash-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:1.2rem;margin-bottom:1.5rem}
.stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:1.2rem;box-shadow:var(--shadow)}
.stat-card__value{font-size:2rem;font-weight:700;color:var(--primary)}
.stat-card__label{font-size:.85rem;color:var(--text-muted);margin-top:.2rem}

/* ── Login ──────────────────────────────────────────────── */
.login-wrap{display:flex;align-items:center;justify-content:center;min-height:100vh;background:var(--sidebar-bg)}
.login-card{background:var(--surface);border-radius:var(--radius);padding:2.5rem;width:100%;max-width:380px;box-shadow:0 4px 20px rgba(0,0,0,.2)}
.login-card h1{text-align:center;margin-bottom:.3rem;color:var(--primary);font-size:1.5rem}
.login-card .subtitle{text-align:center;color:var(--text-muted);margin-bottom:1.8rem;font-size:.9rem}

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.4);display:flex;align-items:center;justify-content:center;z-index:200}
.modal{background:var(--surface);border-radius:var(--radius);padding:1.6rem;width:100%;max-width:520px;box-shadow:0 8px 30px rgba(0,0,0,.15);max-height:85vh;overflow-y:auto}
.modal h2{margin-bottom:1rem;font-size:1.2rem}

/* ── Import / Drop Zone ─────────────────────────────────── */
.dropzone{border:2px dashed var(--border);border-radius:var(--radius);padding:2.5rem;text-align:center;cursor:pointer;transition:all .2s;color:var(--text-muted)}
.dropzone:hover,.dropzone--active{border-color:var(--accent);background:rgba(41,128,185,.04);color:var(--accent)}
.dropzone__icon{font-size:2.5rem;margin-bottom:.5rem}
.dropzone input[type=file]{display:none}

.preview-table{max-height:400px;overflow-y:auto}
.preview-actions{display:flex;gap:.8rem;margin-top:1rem;align-items:center}

/* ── Misc ───────────────────────────────────────────────── */
.text-muted{color:var(--text-muted)}
.text-right{text-align:right}
.mt-1{margin-top:.5rem}.mt-2{margin-top:1rem}
.mb-1{margin-bottom:.5rem}.mb-2{margin-bottom:1rem}
.hidden{display:none}
.htmx-indicator{display:none}.htmx-request .htmx-indicator{display:inline-block}
.spinner{display:inline-block;width:16px;height:16px;border:2px solid var(--border);border-top-color:var(--primary);border-radius:50%;animation:spin .6s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.empty-state{text-align:center;padding:3rem 1rem;color:var(--text-muted)}
.empty-state__icon{font-size:3rem;margin-bottom:.5rem}

/* ── Responsive ─────────────────────────────────────────── */
@media(max-width:768px){
  .sidebar{transform:translateX(-100%)}
  .sidebar--open{transform:translateX(0)}
  .main{margin-left:0;padding:1rem}
  .form-row{grid-template-columns:1fr}
}
