/* ======================================================
   MACS – Stylesheet
   ====================================================== */

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

:root {
  --c-bg:        #f1f5f9;
  --c-surface:   #ffffff;
  --c-border:    #e2e8f0;
  --c-text:      #1e293b;
  --c-muted:     #64748b;
  --c-primary:   #1e3a5f;
  --c-accent:    #3b82f6;
  --c-accent-h:  #2563eb;
  --c-success:   #22c55e;
  --c-danger:    #ef4444;
  --c-warn:      #f59e0b;
  --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);
  --font:        'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
}

/* ── DARK MODE VARIABLES ── */
html.dark {
  --c-bg:        #0f172a;
  --c-surface:   #1e293b;
  --c-border:    #334155;
  --c-text:      #e2e8f0;
  --c-muted:     #94a3b8;
  --c-primary:   #1e40af;
  --c-accent:    #60a5fa;
  --c-accent-h:  #3b82f6;
  --c-success:   #4ade80;
  --c-danger:    #f87171;
  --c-warn:      #fbbf24;
  --shadow:      0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md:   0 4px 6px rgba(0,0,0,.3), 0 2px 4px rgba(0,0,0,.2);
}

/* ── DARK MODE ELEMENT OVERRIDES ── */
html.dark body              { background: #0f172a; color: #e2e8f0; }
html.dark .card,
html.dark .stat-card,
html.dark .login-box,
html.dark .modal-box        { background: #1e293b; border-color: #334155; }
html.dark .form-control     { background: #1e293b; color: #e2e8f0; border-color: #334155; }
html.dark .form-control:focus { border-color: #60a5fa; }
html.dark .form-label       { color: #94a3b8; }
html.dark .btn-secondary    { background: #1e293b; color: #e2e8f0; border-color: #334155; }
html.dark .btn-secondary:hover { background: #263548; }
html.dark .data-table th    { color: #94a3b8; border-color: #334155; }
html.dark .data-table td    { border-color: #334155; color: #e2e8f0; }
html.dark .data-table tr:hover td { background: #263548; }
html.dark .page-title       { color: #93c5fd; }
html.dark .card-title       { color: #93c5fd; }
html.dark .alert-success    { background: #14532d; color: #86efac; border-color: #4ade80; }
html.dark .alert-error      { background: #7f1d1d; color: #fca5a5; border-color: #f87171; }
html.dark .abc-btn          { background: #1e293b; color: #94a3b8; border-color: #334155; }
html.dark .abc-btn:hover    { background: #334155; color: #e2e8f0; }
html.dark .abc-btn.active   { background: #60a5fa; color: #fff; }
html.dark .search-input     { background: #1e293b; color: #e2e8f0; border-color: #334155; }
html.dark .table-counter    { background: #1a2d40; border-color: #334155; }
html.dark .toggle-track     { background: #475569; }
html.dark .reporting-table tfoot td { background: #1e293b; }
html.dark .modal-overlay    { background: rgba(0,0,0,.65); }
html.dark .nav-links a      { color: rgba(255,255,255,.6); }
html.dark .nav-links a:hover,
html.dark .nav-links a.active { color: #fff; }
html.dark .user-chip        { color: rgba(255,255,255,.85); }
html.dark .dm-sun           { display: block; }
html.dark .dm-moon          { display: none; }

/* ── DARK MODE TOGGLE BUTTON ── */
.darkmode-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.7);
  padding: .4rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.darkmode-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.dm-sun  { display: none; }
.dm-moon { display: block; }

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── NAVBAR ── */
.navbar {
  background: #1e293b;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 1.75rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .01em;
  min-width: 160px;
  white-space: nowrap;
  margin-right: 1.5rem;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0;
  flex: 1;
  height: 56px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 500;
  padding: 0 .7rem;
  height: 56px;
  letter-spacing: .01em;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.nav-links a svg { opacity: .7; transition: opacity .15s; }
.nav-links a:hover { color: rgba(255,255,255,.9); border-bottom-color: rgba(255,255,255,.25); }
.nav-links a:hover svg { opacity: 1; }
.nav-links a.active { color: #fff; border-bottom-color: #60a5fa; }
.nav-links a.active svg { opacity: 1; }

.nav-user {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-left: auto;
  padding-left: 1rem;
  border-left: 1px solid rgba(255,255,255,.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  color: rgba(255,255,255,.8);
  font-size: .8rem;
  padding: .3rem .55rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.user-chip:hover { background: rgba(255,255,255,.08); color: #fff; }

.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rolle-tag {
  background: rgba(96,165,250,.2);
  color: #93c5fd;
  font-size: .65rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 4px;
  letter-spacing: .06em;
  text-transform: uppercase;
  border: 1px solid rgba(96,165,250,.3);
}

.btn-logout {
  color: rgba(255,255,255,.45);
  padding: .4rem;
  border-radius: 6px;
  display: flex;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.9); }

/* ── MAIN ── */
.main-content {
  flex: 1;
  padding: 2rem 1.75rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}
.main-content.full-width {
  max-width: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
}

/* ── FOOTER ── */
.site-footer {
  background: #1e293b;
  color: rgba(255,255,255,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: .72rem;
  padding: .6rem 1.75rem;
  border-top: 1px solid rgba(255,255,255,.06);
  letter-spacing: .03em;
}

/* ── ALERTS ── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--c-success); }
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--c-danger); }

/* ── CARDS ── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card-body { padding: 1.4rem; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-primary);
}
.page-subtitle { color: var(--c-muted); font-size: .9rem; margin-top: .15rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
.btn-icon svg { pointer-events: none; }
.btn-primary   { background: var(--c-accent); color: #fff; }
.btn-primary:hover { background: var(--c-accent-h); }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-bg); }
.btn-danger    { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm        { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon      { padding: .4rem; min-width: 30px; min-height: 30px; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm.btn-icon { padding: .35rem; min-width: 28px; min-height: 28px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  text-align: left;
  padding: .75rem 1rem;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.data-table td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.data-table .actions { display: flex; gap: .35rem; flex-wrap: nowrap; }

table.data-table[style*="table-layout:fixed"] td,
table.data-table[style*="table-layout:fixed"] th {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── BADGE ── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
}

/* ── FORMS ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.1rem;
}
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full { grid-column: 1/-1; }
.form-label {
  font-size: .825rem;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-control {
  padding: .55rem .85rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
textarea.form-control { resize: vertical; min-height: 90px; }

.form-actions {
  display: flex;
  gap: .75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-border);
  margin-top: 1rem;
}

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.stat-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-muted);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--c-primary);
  line-height: 1;
}
.stat-sub { font-size: .8rem; color: var(--c-muted); }
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .25rem;
}

/* ── LOGIN ── */
.login-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .75rem;
}
.login-logo h1 { font-size: 1.3rem; font-weight: 700; color: var(--c-primary); }
.login-logo p  { color: var(--c-muted); font-size: .875rem; margin-top: .2rem; }

/* ── SEARCH / FILTER ── */
.filter-bar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.search-input {
  padding: .5rem .9rem .5rem 2.4rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .875rem;
  background: var(--c-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat .75rem center;
  min-width: 200px;
  color: var(--c-text);
}
.search-input:focus { outline: none; border-color: var(--c-accent); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--c-muted);
}
.empty-state svg { opacity: .3; margin-bottom: 1rem; }
.empty-state p { font-size: .95rem; }

/* ── CONFIRM MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--c-surface);
  border-radius: 12px;
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; color: var(--c-primary); }
.modal-text  { color: var(--c-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ── MISC ── */
.text-muted { color: var(--c-muted); }
.mono { font-family: var(--font-mono); font-size: .85em; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }

/* ── ABC-REGISTER ── */
.abc-register {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-bottom: 1rem;
}
.abc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 .4rem;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--c-muted);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  transition: all .15s;
}
.abc-btn:hover { background: var(--c-bg); color: var(--c-text); border-color: var(--c-accent); }
.abc-btn.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }

/* ── TOGGLE SWITCH ── */
.toggle-group { display: flex; flex-direction: column; gap: .35rem; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-track {
  position: relative;
  width: 42px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-label input:checked + .toggle-track { background: var(--c-accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.toggle-label input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-text { font-size: .875rem; font-weight: 500; color: var(--c-text); }

/* ── TABELLEN-ZÄHLER ── */
.table-counter {
  padding: .5rem 1rem;
  font-size: .78rem;
  color: var(--c-muted);
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
  border-radius: 0 0 var(--radius) var(--radius);
  text-align: right;
}

/* ── FORM SECTION TITLE ── */
.form-section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-accent);
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--c-accent);
  display: inline-block;
}

/* ── REPORTING TABLE ── */
.reporting-table th, .reporting-table td { font-size: .8rem; padding: .6rem .85rem; white-space: nowrap; }
.reporting-table tfoot td { border-top: 2px solid var(--c-primary); background: #f1f5f9; padding: .75rem; }

/* ── RESPONSIVE ── */
@media (max-width: 680px) {
  .navbar { padding: 0 1rem; gap: 1rem; }
  .nav-links a span { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media(max-width:700px){.dashboard-grid{grid-template-columns:1fr!important}}
@media (max-width: 900px) {
  .reporting-table th:nth-child(n+4), .reporting-table td:nth-child(n+4) { display: none; }
  .reporting-table th:last-child, .reporting-table td:last-child { display: table-cell; }
}
