:root {
  --primary: #1A56C4;
  --primary-dark: #1445A0;
  --primary-soft: #E8F0FE;
  --secondary: #3B82F6;
  --orange: #F59E0B;
  --red: #EF4444;
  --green: #10B981;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-400: #94A3B8;
  --gray-600: #475569;
  --gray-800: #1E293B;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(26, 86, 196, 0.08);
  --font: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--gray-800); background:
  radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 55%),
  radial-gradient(900px 500px at 100% 0%, #eff6ff 0%, transparent 50%),
  var(--gray-50); min-height: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0F3D9A 0%, var(--primary) 55%, #2563EB 100%);
  color: #fff; padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.brand { font-size: 1.55rem; font-weight: 800; letter-spacing: 0.04em; padding: 0 .5rem; }
.brand::after { content: " · Dein Vertragsmanager"; display: block; font-size: .72rem; font-weight: 500; opacity: .85; letter-spacing: 0; margin-top: .15rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar nav a {
  color: rgba(255,255,255,.85); padding: .7rem .85rem; border-radius: 10px; text-decoration: none; font-weight: 500;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }
.sidebar-user { padding: .85rem; background: rgba(0,0,0,.15); border-radius: 12px; font-size: .9rem; }
.sidebar-user span { display: block; opacity: .8; font-size: .8rem; margin-top: .15rem; }

.main { padding: 1.75rem 2rem 5rem; max-width: 1100px; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 1.75rem; letter-spacing: -0.03em; }
.muted { color: var(--gray-600); }

.card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.stat { text-align: left; }
.stat .label { color: var(--gray-600); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin-top: .2rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: 10px; padding: .7rem 1.1rem; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none !important;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }

.form { display: flex; flex-direction: column; gap: .9rem; }
.form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .92rem; }
.form input, .form select, .form textarea {
  border: 1.5px solid var(--gray-200); border-radius: 10px; padding: .7rem .85rem; font: inherit;
  background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,196,.15);
}
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a, .tabs button {
  border: none; background: var(--gray-100); color: var(--gray-600); padding: .55rem 1rem;
  border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.tabs a.active, .tabs button.active { background: var(--primary-soft); color: var(--primary); }

.list { display: flex; flex-direction: column; gap: .75rem; }
.contract-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center;
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1rem 1.15rem;
  text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease;
}
.contract-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.traffic {
  width: 12px; height: 12px; border-radius: 50%;
}
.traffic.green { background: var(--green); }
.traffic.yellow { background: var(--orange); }
.traffic.red { background: var(--red); }
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700;
}
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-orange { background: #FEF3C7; color: #92400E; }

.group-title { margin: 1.25rem 0 .6rem; font-size: 1rem; color: var(--gray-600); font-weight: 600; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  width: min(420px, 100%); background: #fff; border-radius: 20px; padding: 2rem;
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}
.auth-card h1 { margin: 0 0 .35rem; font-size: 1.7rem; letter-spacing: -0.03em; }
.auth-card .lead { color: var(--gray-600); margin: 0 0 1.5rem; }
.auth-hero {
  width: min(420px, 100%); text-align: center; margin-bottom: 1rem;
}
.auth-hero .logo { font-size: 2rem; font-weight: 800; color: var(--primary); letter-spacing: 0.04em; }
.auth-hero .logo-sub { color: var(--primary-dark); font-weight: 600; margin-top: .25rem; }

.flash { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash-success { background: #D1FAE5; color: #065F46; }
.flash-error { background: #FEE2E2; color: #991B1B; }
.flash-info { background: var(--primary-soft); color: var(--primary-dark); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .7rem .5rem; border-bottom: 1px solid var(--gray-200); }
.table th { color: var(--gray-600); font-size: .85rem; font-weight: 600; }

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; margin-bottom: 1.25rem;
}
.cal-head { text-align: center; font-size: .8rem; color: var(--gray-600); font-weight: 600; padding: .35rem; }
.cal-day {
  min-height: 64px; background: #fff; border: 1px solid var(--gray-200); border-radius: 10px;
  padding: .35rem; font-size: .8rem;
}
.cal-day.muted { opacity: .45; }
.cal-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day .n { font-weight: 700; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 2px; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--gray-600); margin-top: 1rem; }
.mobile-nav { display: none; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 1.25rem 1rem 6rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid var(--gray-200); padding: .45rem .25rem calc(.45rem + env(safe-area-inset-bottom));
    z-index: 50;
  }
  .mobile-nav a {
    text-align: center; color: var(--gray-600); font-size: .7rem; font-weight: 600; text-decoration: none; padding: .35rem;
  }
  .mobile-nav a.active { color: var(--primary); }
}
