:root {
  --red: #C8102E;
  --red-dark: #9B0B22;
  --red-glow: rgba(200, 16, 46, .12);
  --bg: #0d0d0d;
  --bg-panel: #1c1c1c;
  --bg-input: #111;
  --border: #2a2a2a;
  --text: #f0ebe5;
  --text-dim: #999;
  --text-dimmer: #666;
  --green: #2ECC71;
  --amber: #F39C12;
}

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

body {
  font-family: 'Barlow', sans-serif;
  background:
    radial-gradient(ellipse 900px 500px at 85% -5%, rgba(200,16,46,.06) 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; }

/* ── App Shell / Sidebar ─────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo { padding: 1.75rem 1.5rem 1.25rem; border-bottom: 1px solid var(--border); position: relative; }
.sidebar-logo::after { content: ''; position: absolute; bottom: -1px; left: 1.5rem; width: 34px; height: 3px; background: var(--red); border-radius: 2px; }
.sidebar-logo h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.3rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
}
.sidebar-logo h1 span { color: var(--red); }
.sidebar-logo p { color: var(--text-dimmer); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; margin-top: .25rem; }

.sidebar-nav { flex: 1; padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .85rem; border-radius: 6px;
  text-decoration: none; color: var(--text-dim);
  font-size: .88rem; font-weight: 600;
  transition: all .15s; border-left: 3px solid transparent;
}
.sidebar-nav a .icon { font-size: 1rem; width: 1.2rem; text-align: center; }
.sidebar-nav a:hover { background: rgba(255,255,255,.05); color: var(--text); }
.sidebar-nav a.active { background: var(--red-glow); color: #ff8090; border-left: 3px solid var(--red); }
.sidebar-section { font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dimmer); padding: 1rem .85rem .35rem; }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: .65rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; flex-shrink: 0;
}
.sidebar-user-name { font-size: .82rem; font-weight: 600; }
.sidebar-user-role { font-size: .7rem; color: var(--text-dimmer); text-transform: uppercase; letter-spacing: .05em; }

.main-area { flex: 1; min-width: 0; }
.main-inner { max-width: 1100px; margin: 0 auto; padding: 2.25rem 2rem 3rem; }

/* ── Page header ──────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-head h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.6rem; font-weight: 700; letter-spacing: .02em; }
.page-head p { color: var(--text-dimmer); font-size: .85rem; margin-top: .2rem; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1.5rem; overflow: hidden; box-shadow: 0 4px 18px rgba(0,0,0,.22); }
.card-head { padding: .9rem 1.5rem; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.02); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card-head h3 { font-family: 'Barlow Condensed', sans-serif; font-size: 1rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.card-body { padding: 1.5rem; }

/* ── Stat tiles ───────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { background: var(--bg-panel); border: 1px solid var(--border); border-top: 2px solid var(--red); border-radius: 8px; padding: 1.2rem 1.4rem; box-shadow: 0 4px 18px rgba(0,0,0,.2); transition: transform .15s; }
.stat-tile:hover { transform: translateY(-2px); }
.stat-tile .value { font-family: 'Barlow Condensed', sans-serif; font-size: 2rem; font-weight: 700; color: #fff; }
.stat-tile .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dimmer); margin-top: .2rem; }
.stat-tile.accent .value { color: #ff8090; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.fg3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.fg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #888; }
input, select, textarea {
  background: var(--bg-input); border: 1px solid #333; border-radius: 5px;
  color: var(--text); padding: .55rem .85rem; font-family: inherit; font-size: .9rem;
  width: 100%; outline: none; transition: border-color .2s;
}
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { border-color: var(--red); }
input:disabled, select:disabled, textarea:disabled { opacity: .45; cursor: not-allowed; }
input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--red); }
.cb-row { display: flex; align-items: center; gap: .6rem; }
.cb-row > label { text-transform: none; font-size: .88rem; font-weight: 600; cursor: pointer; color: var(--text); letter-spacing: 0; }
.hint { font-size: .72rem; color: var(--text-dimmer); margin-top: .15rem; }
.mono { font-family: 'JetBrains Mono', monospace !important; font-size: .82rem !important; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.25rem; border-radius: 5px; font-family: 'Barlow', sans-serif;
  font-size: .85rem; font-weight: 700; cursor: pointer; border: 1px solid transparent;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 2px 10px rgba(200,16,46,.35); }
.btn-primary:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(200,16,46,.45); }
.btn-secondary { background: transparent; color: var(--text); border-color: #333; }
.btn-secondary:hover { background: rgba(255,255,255,.06); }
.btn-danger { background: transparent; color: #ff8090; border-color: rgba(200,16,46,.35); }
.btn-danger:hover { background: rgba(200,16,46,.12); }
.btn-lg { padding: .7rem 1.6rem; font-size: .92rem; }
.btn-sm { padding: .35rem .8rem; font-size: .75rem; }
.btn-block { width: 100%; }

/* ── Key display ──────────────────────────────────────────────────────── */
.key-box { background: #080808; border: 2px solid var(--red); border-radius: 6px; padding: 1.1rem 1.5rem; margin-bottom: .75rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; transition: all .2s; }
.key-box:hover { border-color: #e8334a; }
.key-code { font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; font-weight: 600; letter-spacing: .1em; color: #fff; word-break: break-all; }
.key-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.tag { background: var(--bg-panel); border: 1px solid var(--border); padding: .2rem .55rem; border-radius: 3px; font-size: .72rem; color: #aaa; }
.tag strong { color: var(--text); }
.copy-btn { background: rgba(200,16,46,.15); border: 1px solid rgba(200,16,46,.3); color: #ff8090; padding: .35rem .85rem; border-radius: 3px; font-size: .75rem; font-weight: 700; cursor: pointer; white-space: nowrap; font-family: 'Barlow', sans-serif; flex-shrink: 0; transition: all .2s; }
.copy-btn:hover { background: rgba(200,16,46,.3); }
.copy-btn.copied { background: rgba(46,204,113,.15); border-color: rgba(46,204,113,.3); color: #7dffa8; }

/* ── Alerts / badges ──────────────────────────────────────────────────── */
.alert { padding: .75rem 1.1rem; border-radius: 5px; border-left: 4px solid; font-size: .85rem; margin-bottom: 1rem; }
.alert-success { background: rgba(46,204,113,.1); border-color: var(--green); color: #7dffa8; }
.alert-danger  { background: rgba(200,16,46,.1); border-color: var(--red); color: #ff8090; }
.alert-warning { background: rgba(243,156,18,.1); border-color: var(--amber); color: #ffc96b; }

.badge { display: inline-block; font-size: .65rem; font-weight: 700; padding: .18rem .55rem; border-radius: 3px; text-transform: uppercase; letter-spacing: .05em; }
.badge-admin { background: rgba(200,16,46,.15); color: #ff8090; border: 1px solid rgba(200,16,46,.3); }
.badge-user { background: rgba(255,255,255,.06); color: #bbb; border: 1px solid var(--border); }
.badge-supporter { background: rgba(52,152,219,.12); color: #7ec3ff; border: 1px solid rgba(52,152,219,.3); }
.badge-active { background: rgba(46,204,113,.12); color: #7dffa8; border: 1px solid rgba(46,204,113,.3); }
.badge-inactive { background: rgba(150,150,150,.1); color: #888; border: 1px solid #333; }
.badge-type-PRO { background: rgba(200,16,46,.12); color: #ff8090; }
.badge-type-BASIC { background: rgba(52,152,219,.12); color: #7ec3ff; }
.badge-type-SITE { background: rgba(155,89,182,.12); color: #d9a6ff; }

.divider { border: none; border-top: 1px solid #222; margin: 1.5rem 0; }

/* ── Support-Box ──────────────────────────────────────────────────────── */
.support-box {
  background: rgba(200,16,46,.04); border: 1px solid rgba(200,16,46,.18);
  border-radius: 6px; padding: 1.1rem 1.3rem; margin-top: .5rem;
}
.new-customer-form { display: none; background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 6px; padding: 1.1rem 1.3rem; margin: 1rem 0 1.5rem; }
.new-customer-form.open-form { display: block; }

.activity-feed { display: flex; flex-direction: column; gap: .7rem; max-height: 360px; overflow-y: auto; }
.activity-item { background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 5px; padding: .65rem .9rem; }
.activity-text { font-size: .85rem; line-height: 1.4; }
.activity-meta { font-size: .7rem; color: var(--text-dimmer); margin-top: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.badge-support-active { background: rgba(46,204,113,.12); color: #7dffa8; border: 1px solid rgba(46,204,113,.3); }
.badge-support-inactive { background: rgba(200,16,46,.1); color: #ff8090; border: 1px solid rgba(200,16,46,.3); }
.badge-support-extended { background: rgba(243,156,18,.12); color: #ffc96b; border: 1px solid rgba(243,156,18,.3); }
.badge-demo { background: rgba(155,89,182,.16); color: #d9a6ff; border: 1px solid rgba(155,89,182,.4); margin-left: .4rem; }

.demo-box {
  background: rgba(155,89,182,.05); border: 1px solid rgba(155,89,182,.25);
  border-radius: 6px; padding: 1.1rem 1.3rem; margin-top: 1rem;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data-table th {
  text-align: left; padding: .7rem .9rem; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-dimmer); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td { padding: .7rem .9rem; border-bottom: 1px solid #1f1f1f; vertical-align: middle; }
table.data-table tr:hover td { background: rgba(255,255,255,.02); }
table.data-table td.mono { font-size: .78rem !important; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-dimmer); font-size: .88rem; }

/* ── Login page ───────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 20% 50%, rgba(200,16,46,.08) 0%, transparent 60%), var(--bg); padding: 1.5rem; }
.login-box { width: 380px; max-width: 100%; }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-family: 'Barlow Condensed', sans-serif; font-size: 2.2rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.login-logo h1 span { color: var(--red); }
.login-logo p { color: var(--text-dimmer); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; margin-top: .35rem; }
.footer-note { text-align: center; margin: 2rem 0 1rem; font-size: .68rem; color: #3a3a3a; }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.secret-status { padding: .75rem 1.25rem; border-radius: 5px; margin-bottom: 1.5rem; font-size: .85rem; display: flex; align-items: center; gap: .75rem; }
.secret-status.ok { background: rgba(46,204,113,.1); border: 1px solid rgba(46,204,113,.3); color: #7dffa8; }
.secret-status.missing { background: rgba(200,16,46,.1); border: 1px solid rgba(200,16,46,.3); color: #ff8090; }

.filter-bar { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; align-items: flex-end; }
.filter-bar .form-group { min-width: 160px; }

.chart-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 280px; }

/* ── Lizenz-anzeigen-Button (öffnet Detail-Modal) ────────────────────── */
.btn-license {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(200,16,46,.08); border: 1px solid rgba(200,16,46,.3); color: #ff8090;
  padding: .45rem .85rem; border-radius: 5px; font-size: .78rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; font-family: 'Barlow', sans-serif; transition: all .15s;
}
.btn-license:hover { background: rgba(200,16,46,.18); border-color: rgba(200,16,46,.5); }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  max-width: 520px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.55);
  animation: modalIn .15s ease; max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.05rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0 .3rem; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 1.4rem; }
.modal-key {
  font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; letter-spacing: .07em; color: #fff;
  background: #080808; border: 2px solid var(--red); border-radius: 6px;
  padding: .9rem 1.1rem; word-break: break-all; margin-bottom: 1.2rem; text-align: center;
}
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.2rem; }
.modal-field .l { font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dimmer); margin-bottom: .2rem; }
.modal-field .v { font-size: .9rem; font-weight: 600; }
.modal-actions { display: flex; gap: .6rem; padding: 1.1rem 1.4rem; border-top: 1px solid var(--border); }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: .5rem 1rem; }
  .sidebar-logo, .sidebar-footer { display: none; }
  .sidebar-nav { flex-direction: row; padding: .5rem 0; overflow-x: auto; }
  .fg3, .fg2 { grid-template-columns: 1fr; }
  .main-inner { padding: 1.25rem 1rem 2rem; }
}
