:root {
  --color-primary: #c8102e;
  --color-primary-dark: #8e0a20;
  --color-primary-light: #ff5a68;
  --color-bg: #f5f5f5;
  --color-sidebar: #121212;
  --color-sidebar-active: #c8102e;
  --color-text: #1a1a1a;
  --color-muted: #6b6b6b;
  --color-border: #e2e2e2;
  --color-white: #ffffff;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--color-sidebar);
  color: #e6e6e6;
  display: flex;
  flex-direction: column;
  border-right: 3px solid var(--color-primary);
}

.sidebar-brand {
  padding: 18px;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo { width: 54px; height: 54px; object-fit: contain; flex-shrink: 0; border-radius: 12px; }

.sidebar nav { flex: 1; overflow-y: auto; }
.sidebar ul { list-style: none; margin: 0; padding: 10px 0; }
.sidebar li a {
  display: block;
  padding: 11px 18px;
  color: #cfcfcf;
  text-decoration: none;
  font-size: 0.93rem;
  border-left: 3px solid transparent;
}
.sidebar li.active a, .sidebar li a:hover {
  background: rgba(200,16,46,0.15);
  border-left-color: var(--color-sidebar-active);
  color: #fff;
}

.sidebar-user {
  padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
}
.sidebar-user-name { font-weight: 600; color: #fff; }
.sidebar-user-role { color: #a0a0a0; margin-bottom: 8px; }
.logout-link { color: var(--color-primary-light); text-decoration: none; }
.logout-link:hover { text-decoration: underline; }

.content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

.content h1 { margin-top: 0; }

.placeholder-box {
  background: var(--color-white);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--color-muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: box-shadow 0.15s ease, transform 0.08s ease;
}
.card .card-value { font-size: 1.7rem; font-weight: 700; color: var(--color-primary-dark); }
.card .card-label { color: var(--color-muted); font-size: 0.85rem; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-sidebar), var(--color-primary-dark));
}
.login-box {
  background: var(--color-white);
  padding: 36px 32px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 340px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-logo { display: block; width: 96px; height: 96px; object-fit: contain; margin: 0 auto 14px; }
.login-box h1 { font-size: 1.2rem; margin-top: 0; text-align: center; }
.login-box label { display: block; margin-bottom: 14px; font-size: 0.85rem; color: var(--color-muted); }
.login-box input {
  width: 100%;
  padding: 9px 10px;
  margin-top: 4px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.95rem;
}
.login-box button {
  width: 100%;
  padding: 14px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(200,16,46,0.35);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.login-box button:hover { box-shadow: 0 6px 18px rgba(200,16,46,0.42); transform: translateY(-1px); }
.login-box button:hover { background: var(--color-primary-dark); }

.alert { padding: 10px 12px; border-radius: 6px; font-size: 0.85rem; }
.alert-error { background: #fdecea; color: #b3261e; }
.alert-success { background: #e6f4ea; color: #1e7e34; }
.alert-info { background: #e8f0fe; color: #1a53c4; }

table.data-table { width: 100%; border-collapse: collapse; background: #fff; }
table.data-table th, table.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}
table.data-table th { color: var(--color-muted); font-weight: 600; }
table.data-table tbody tr:hover { background: #fafbfa; }

.btn {
  display: inline-block;
  padding: 14px 26px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:hover { background: #f0f2f1; box-shadow: 0 5px 14px rgba(0,0,0,0.16); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(0,0,0,0.14); }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; box-shadow: 0 4px 14px rgba(200,16,46,0.35); }
.btn-primary:hover { background: var(--color-primary-dark); box-shadow: 0 6px 18px rgba(200,16,46,0.42); }
.btn-danger { background: #fff; border-color: #e0b4b0; color: #b3261e; }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }

.search-form { margin: 16px 0; display: flex; gap: 8px; }
.search-form input {
  padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 6px; min-width: 260px;
}

.form-card {
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 24px; max-width: 720px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid.full, .form-full { grid-column: 1 / -1; }
.form-card label { display: block; font-size: 0.85rem; color: var(--color-muted); margin-bottom: 4px; }
.form-card input, .form-card select, .form-card textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--color-border);
  border-radius: 6px; font-size: 0.92rem; font-family: inherit;
}
.form-card textarea { min-height: 70px; resize: vertical; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
}
.badge-entwurf { background: #eef0ef; color: #5a655e; }
.badge-versendet { background: #fff4d6; color: #8a6d1d; }
.badge-bestaetigt { background: #e4f5ea; color: #1f6f4f; }
.badge-abgelehnt { background: #fdecea; color: #b3261e; }
.badge-offen { background: #eef0ef; color: #5a655e; }
.badge-in_arbeit { background: #fff4d6; color: #8a6d1d; }
.badge-erledigt { background: #e4f5ea; color: #1f6f4f; }
.badge-storniert { background: #fdecea; color: #b3261e; }

.section-title { margin-top: 34px; margin-bottom: 10px; font-size: 1.05rem; }

.items-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.items-table th { text-align: left; font-size: 0.8rem; color: var(--color-muted); padding: 6px 8px; }
.items-table td { padding: 6px 8px; }
.items-table input { width: 100%; padding: 7px 8px; border: 1px solid var(--color-border); border-radius: 6px; }
.items-table td.qty, .items-table td.price, .items-table td.total { width: 110px; }
.items-table td.unit { width: 90px; }
.items-table td.remove { width: 36px; text-align: center; }
.items-table td.discount { width: 90px; }
.items-table td.discount input { text-align: right; }
.desc-toolbar { display: flex; gap: 4px; margin-bottom: 4px; }
.desc-toolbar .fmt-btn { min-width: 28px; padding: 2px 8px; font-weight: 700; line-height: 1.4; }
.items-table td.drag-handle-cell { width: 28px; text-align: center; padding: 6px 2px; }
.items-table .drag-handle { cursor: grab; touch-action: none; user-select: none; color: var(--color-muted); font-size: 1.15rem; display: inline-block; padding: 4px 6px; line-height: 1; }
.items-table .drag-handle:active { cursor: grabbing; }
.items-table tbody tr.dragging { opacity: 0.4; background: var(--color-bg-soft, #f5f5f5); }
.items-total-row td { font-weight: 700; padding-top: 10px; }

.calc-box {
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 20px; margin-top: 16px;
}
.calc-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.calc-tabs button {
  padding: 7px 14px; border-radius: 20px; border: 1px solid var(--color-border);
  background: #fff; cursor: pointer; font-size: 0.85rem;
}
.calc-tabs button.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.calc-panel { display: none; }
.calc-panel.active { display: block; }
.calc-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin: 16px 0; }
.calc-results .card { padding: 12px 14px; }
.calc-results .card .card-value { font-size: 1.3rem; }
.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.link-list li:last-child { border-bottom: none; }
.muted { color: var(--color-muted); }
.calculator-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; }
.calculator-cards a.card { text-decoration: none; color: inherit; display: block; }
.calculator-cards a.card:hover { border-color: var(--color-primary); }
.calculator-cards .card h3 { margin: 0 0 6px 0; font-size: 1rem; }
.calculator-cards .card p { margin: 0; color: var(--color-muted); font-size: 0.85rem; }

.checklist { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 10px; }
.checklist-item { display: flex !important; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--color-text) !important; margin: 0 !important; }
.checklist-item input { width: auto !important; }

.confirm-panel { display: none; margin-top: 14px; }
.confirm-panel.active { display: block; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 10px; margin-top: 10px; }
.photo-grid img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); }

.signature-img { max-width: 320px; border: 1px solid var(--color-border); border-radius: 6px; background: #fff; }

.timer-display { font-size: 2.4rem; font-weight: 700; color: var(--color-primary-dark); margin: 10px 0; }
.timer-box { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; text-align: center; max-width: 360px; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.calendar-day-name { text-align: center; font-size: 0.78rem; color: var(--color-muted); padding: 4px 0; }
.calendar-cell {
  background: #fff; border: 1px solid var(--color-border); border-radius: 6px;
  min-height: 96px; min-width: 0; padding: 6px; font-size: 0.78rem; overflow: hidden;
}
.calendar-cell.other-month { background: #f7f8f7; color: #b9c2bd; }
.calendar-cell .day-number { font-weight: 600; margin-bottom: 4px; }
.calendar-cell.today { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); }
.calendar-event {
  display: block; background: var(--color-primary); color: #fff; border-radius: 4px;
  padding: 2px 5px; margin-bottom: 3px; font-size: 0.72rem; text-decoration: none; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.calendar-nav { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; }

/* ------------------------------------------------------------------ */
/* Einheitliche Linkfarbe im Inhaltsbereich statt Standard-Browserblau */
/* ------------------------------------------------------------------ */
.content a:not(.btn) {
  color: var(--color-primary-dark);
  text-decoration: none;
  font-weight: 600;
}
.content a:hover {
  text-decoration: underline;
}
.content table.data-table a {
  font-weight: 600;
}

/* Karten und Tabellenzeilen wirken beim Hover etwas "greifbarer" */
.card:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
table.data-table tbody tr {
  transition: background 0.1s ease;
}

/* ------------------------------------------------------------------ */
/* Formulare (z.B. "Mitarbeiter anlegen") ans übrige Design angleichen: */
/* farbige Abschnittstitel statt reinem Fließtext, dezenter Kartenschatten, */
/* roter Fokus-Rahmen statt Standard-Browserblau.                        */
/* ------------------------------------------------------------------ */
.form-card {
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
}
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary-dark);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-primary);
  display: table;
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus,
.search-form input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.14);
}


/* ------------------------------------------------------------------ */
/* Dashboard: klickbare, farbige Stat-Kacheln + Logo-Wasserzeichen     */
/* ------------------------------------------------------------------ */
.dashboard-watermark {
  position: relative;
}
.dashboard-watermark::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -40px;
  width: 460px;
  height: 460px;
  background: url('/assets/img/logo-login.png') no-repeat center / contain;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}
.dashboard-watermark > * {
  position: relative;
  z-index: 1;
}

.stat-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--stat-color, var(--color-primary));
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 26px rgba(0,0,0,0.12);
}
.stat-card .stat-icon {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--stat-color, var(--color-primary-dark));
  line-height: 1;
}
.stat-card .stat-label {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin-top: 6px;
  font-weight: 600;
}
.stat-customers { --stat-color: #c8102e; }
.stat-objects { --stat-color: #1d7a8c; }
.stat-orders { --stat-color: #d9822b; }
.stat-quotes { --stat-color: #6b46c1; }
.stat-invoices { --stat-color: #1f8a4c; }
.stat-reports { --stat-color: #2563eb; }


/* Einsatzplanung: 3-Spalten-Layout (Mitarbeiter | Kalender | Tagesplan) */
.einsatzplanung-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
  margin-top: 8px;
}
.einsatz-col {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
}
.einsatz-employees { display: flex; flex-direction: column; gap: 4px; }
.employee-pick {
  display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none;
  font-size: 0.88rem; font-weight: 600; color: inherit;
}
.employee-pick:hover { background: var(--color-bg-soft, #f5f5f5); text-decoration: none; }
.employee-pick.active { background: var(--color-primary); color: #fff; }
.einsatz-day { max-height: 640px; overflow-y: auto; }
.einsatz-card {
  border: 1px solid var(--color-border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px;
}
.calendar-cell.selected-day { box-shadow: inset 0 0 0 2px var(--color-primary-dark); }
@media (max-width: 980px) {
  .einsatzplanung-layout { grid-template-columns: 1fr; }
}


/* ================================================================== */
/* Mobile-Navigation: Sidebar wird bei schmalen Bildschirmen zum        */
/* ausklappbaren Off-Canvas-Menue statt permanent Platz zu blockieren.  */
/* ================================================================== */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
    /* Alle zweispaltigen Formulare (Kunden, Objekte, Angebote, Rechnungen, Kalkulationsrechner
       usw.) sonst auf schmalen Bildschirmen/Tablets nebeneinander gequetscht statt gestapelt. */
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        background: var(--color-sidebar); color: #fff;
        padding: 12px 16px; position: sticky; top: 0; z-index: 150;
        border-bottom: 3px solid var(--color-primary);
    }
    .mobile-topbar img { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; }
    .mobile-topbar span { font-weight: 700; font-size: 1rem; }
    .mobile-menu-btn {
        background: none; border: none; color: #fff; font-size: 1.6rem;
        line-height: 1; cursor: pointer; padding: 4px 8px; margin-right: 2px;
    }

    .app-shell { display: block; }

    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 250px; max-width: 82vw;
        transform: translateX(-100%); transition: transform 0.25s ease;
        z-index: 200; overflow-y: auto;
    }
    .sidebar.is-open { transform: translateX(0); }

    .sidebar-backdrop.is-open {
        display: block; position: fixed; inset: 0; background: rgba(20,18,15,0.5); z-index: 190;
    }

    .content { padding: 18px 16px; max-width: 100%; }

    .form-grid { grid-template-columns: 1fr; }

    table.data-table { display: block !important; overflow-x: auto !important; white-space: nowrap; -webkit-overflow-scrolling: touch; }

    .mailbar { flex-wrap: wrap; }
    .mailpop { left: 0; width: calc(100vw - 32px); }
}


/* ================================================================== */
/* Mobile Bottom-Navigation: feste Leiste unten mit den wichtigsten     */
/* Punkten, wie bei App-Oberflaechen ueblich.                           */
/* ================================================================== */
.bottom-nav { display: none; }
@media (max-width: 900px) {
    .bottom-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 180;
        background: var(--color-sidebar); border-top: 3px solid var(--color-primary);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    }
    .bottom-nav a, .bottom-nav button {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        background: none; border: none; color: #b8b8b8; text-decoration: none;
        font-size: 0.66rem; padding: 6px 2px; cursor: pointer; font-family: inherit;
        position: relative;
    }
    .bottom-nav .bn-icon { font-size: 1.3rem; line-height: 1; }
    .bottom-nav a.active { color: #fff; }
    .bottom-nav .bn-badge {
        position: absolute; top: 2px; right: calc(50% - 20px);
        background: #c8102e; color: #fff; font-size: 0.6rem; font-weight: 700;
        line-height: 1; padding: 2px 5px; border-radius: 8px; min-width: 14px; text-align: center;
    }
    .content { padding: 18px 16px 86px; max-width: 100%; }
}

/* Abmelden läuft seit dem Sicherheitsumbau über ein Formular (Audit SEC-01).
   Der Knopf soll weiterhin wie ein Link aussehen. */
.logout-form { display: inline; }
button.logout-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.logout-link:hover { text-decoration: underline; }
.myday-header button.logout-link { color: inherit; }
