:root{
  --bg:#f5f7fb;
  --bg-grad-1:#f5f7fb;
  --bg-grad-2:#eef2f8;
  --panel:rgba(255,255,255,.84);
  --panel-strong:rgba(255,255,255,.94);
  --panel2:#f3f6fb;
  --line:#dde5ef;
  --line-soft:#e9eef5;
  --text:#0f172a;
  --muted:#64748b;
  --accent:#4f8df7;
  --accent-soft:rgba(79,141,247,.14);
  --accent-soft-2:rgba(79,141,247,.07);
  --ok:#22c55e;
  --ok-soft:rgba(34,197,94,.12);
  --warn:#f59e0b;
  --warn-soft:rgba(245,158,11,.12);
  --danger:#ef4444;
  --danger-soft:rgba(239,68,68,.10);
  --shadow:0 12px 34px rgba(15,23,42,.08);
  --radius-card:20px;
  --radius-input:14px;
  --radius-output:18px;
  --radius-pill:999px;
}
*{box-sizing:border-box}
html,body{min-height:100%}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","Inter","Segoe UI",Roboto,Arial,sans-serif;
  background:
    radial-gradient(circle at top center, rgba(79,141,247,.10), transparent 28%),
    linear-gradient(180deg,var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
h1,h2,h3{margin-top:0;letter-spacing:-0.02em}
h1{font-size:clamp(30px,4vw,40px);line-height:1.08}
h2{font-size:clamp(19px,2.4vw,22px);line-height:1.16}
h3{font-size:clamp(15px,2vw,17px);line-height:1.2}
.sub{
  margin:0 0 22px;
  color:var(--muted);
  line-height:1.5;
  font-size:15px;
}
.card{
  background:linear-gradient(180deg,var(--panel) 0%, var(--panel-strong) 100%);
  border:1px solid var(--line);
  border-radius:var(--radius-card);
  padding:18px;
  box-shadow:var(--shadow);
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
}
.card h2{margin:0 0 12px;font-size:18px}
label{
  display:block;
  font-size:13px;
  color:var(--muted);
  margin-bottom:6px;
  font-weight:600;
}
input,select,textarea,button{
  width:100%;
  font:inherit;
  border-radius:var(--radius-input);
  border:1px solid var(--line);
  background:linear-gradient(180deg,#f8faff 0%, #f1f5fb 100%);
  color:var(--text);
  padding:11px 13px;
  outline:none;
  transition:border-color .16s ease, box-shadow .16s ease, transform .16s ease, background .16s ease;
}
input::placeholder, textarea::placeholder{color:#8b98ab}
input:focus, select:focus, textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 4px var(--accent-soft);
}
textarea{
  min-height:90px;
  resize:vertical;
  line-height:1.45;
}
button{cursor:pointer;font-weight:600}
button:hover{transform:translateY(-1px)}
button:active{transform:translateY(0)}
.btn-primary{
  background:linear-gradient(180deg,#5d99fb 0%, #4f8df7 100%);
  color:#ffffff;
  border-color:#4f8df7;
  font-weight:700;
}
.btn-soft{
  background:linear-gradient(180deg,rgba(79,141,247,.14) 0%, rgba(79,141,247,.08) 100%);
  color:#245dc8;
  border-color:#c7d9fb;
}
.btn-ok{
  background:linear-gradient(180deg,rgba(34,197,94,.14) 0%, rgba(34,197,94,.08) 100%);
  border-color:#bcebcf;
  color:#15713a;
}
.btn-danger{
  background:linear-gradient(180deg,rgba(239,68,68,.13) 0%, rgba(239,68,68,.07) 100%);
  border-color:#f0c2c2;
  color:#b42318;
}
.btn-inline{width:auto}
.actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.grid2,.grid3,.grid4{display:grid;gap:12px}
.grid2{grid-template-columns:1fr 1fr}
.grid3{grid-template-columns:repeat(3,1fr)}
.grid4{grid-template-columns:repeat(4,1fr)}
.tiny{
  font-size:12px;
  color:var(--muted);
  line-height:1.45;
}
.output{
  white-space:pre-wrap;
  background:linear-gradient(180deg,#f9fbff 0%, #f2f6fc 100%);
  border:1px solid var(--line-soft);
  border-radius:var(--radius-output);
  min-height:420px;
  padding:16px;
  line-height:1.5;
}
.tableWrap{
  overflow:auto;
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(255,255,255,.55);
  -webkit-overflow-scrolling:touch;
}
table{width:100%;border-collapse:collapse}
th,td{
  border-bottom:1px solid var(--line-soft);
  padding:10px 12px;
  text-align:left;
  vertical-align:top;
}
th{
  background:#f1f5fb;
  font-size:13px;
  font-weight:700;
}
.area-badge{
  display:inline-flex;
  align-items:flex-start;
  flex-direction:column;
  border:1px solid var(--line);
  border-radius:var(--radius-pill);
  padding:6px 10px;
  font-size:12px;
  color:var(--muted);
  background:rgba(255,255,255,.7);
}
.staff-summary-detail{
  display:block;
  font-size:11px;
  color:var(--muted);
  margin-top:2px;
}
.pill{
  width:auto;
  border-radius:var(--radius-pill);
  padding:8px 12px;
  background:linear-gradient(180deg,#ffffff 0%, #f2f6fc 100%);
  border:1px solid var(--line);
  color:var(--text);
  font-size:13px;
}
.cch-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  margin-bottom:18px;
}
.cch-brand{
  display:flex;
  align-items:center;
  gap:14px;
  min-width:0;
}
.cch-logo{
  width:58px;
  height:58px;
  object-fit:contain;
  flex:0 0 auto;
  filter:drop-shadow(0 6px 16px rgba(15,23,42,.12));
}
.cch-brand-text{min-width:0}
.cch-eyebrow{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--line);
  border-radius:var(--radius-pill);
  padding:6px 10px;
  color:var(--muted);
  background:rgba(255,255,255,.65);
  font-size:12px;
  margin-bottom:8px;
}
.cch-page-title{margin:0}
.cch-page-subtitle{
  margin:6px 0 0;
  color:var(--muted);
  line-height:1.45;
  font-size:15px;
}
.cch-header-side{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.cch-chip{
  width:auto;
  border-radius:var(--radius-pill);
  padding:8px 12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.65);
  color:var(--muted);
  font-size:12px;
}
.sep{
  height:1px;
  background:linear-gradient(90deg,transparent 0%, var(--line) 18%, var(--line) 82%, transparent 100%);
  margin:16px 0;
}
.shared-topnav{
  position:sticky;
  top:0;
  width:100%;
  z-index:9999;
  background:linear-gradient(180deg,rgba(255,255,255,.84),rgba(255,255,255,.72));
  border-bottom:1px solid var(--line);
  box-shadow:0 8px 24px rgba(15,23,42,.06);
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
}
.shared-topnav-inner{
  width:min(calc(100% - 40px), 1620px);
  margin:0 auto;
  padding:12px 0;
  display:flex;
  justify-content:center;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.shared-topnav a{
  color:var(--muted);
  text-decoration:none;
  font-size:14px;
  line-height:1;
  padding:9px 12px;
  border-radius:10px;
  border:1px solid transparent;
  transition:background .15s ease,color .15s ease,border-color .15s ease,transform .15s ease;
}
.shared-topnav a:hover{
  background:#eef4ff;
  color:#163767;
  border-color:#d4e3ff;
  transform:translateY(-1px);
}
.shared-topnav a.active{
  background:linear-gradient(180deg,#5d99fb 0%, #4f8df7 100%);
  color:#fff;
  border-color:#4f8df7;
  font-weight:700;
}
body .wrap{padding-top:24px}
@media (max-width:1400px){
  .grid3,.grid4{grid-template-columns:1fr 1fr}
}
@media (max-width:980px){
  h1{font-size:clamp(28px,7vw,34px)}
  h2{font-size:clamp(18px,5vw,20px)}
  h3{font-size:15px}
  .grid2,.grid3,.grid4{grid-template-columns:1fr}
  .cch-header{
    flex-direction:column;
    align-items:flex-start;
    gap:14px;
  }
  .cch-brand{align-items:flex-start}
  .cch-header-side{
    justify-content:flex-start;
    width:100%;
  }
  .cch-page-title{
    font-size:clamp(28px,8vw,34px);
    line-height:1.12;
  }
  .cch-page-subtitle{
    font-size:14px;
    max-width:100%;
  }
  .cch-logo{
    width:50px;
    height:50px;
  }
  .actions{
    flex-direction:column;
    align-items:stretch;
  }
  .actions > *{width:100%}
  .btn-inline{width:100%}
  .pill{
    width:100%;
    text-align:center;
    justify-content:center;
  }
  .area-badge{
    width:100%;
    border-radius:16px;
  }
}
@media (max-width:900px){
  .shared-topnav-inner{
    width:min(calc(100% - 20px), 100%);
    padding:10px 0;
    justify-content:flex-start;
    gap:8px;
    overflow-x:auto;
    flex-wrap:nowrap;
    scrollbar-width:none;
  }
  .shared-topnav-inner::-webkit-scrollbar{display:none}
  .shared-topnav a{
    font-size:13px;
    padding:8px 10px;
    white-space:nowrap;
    flex:0 0 auto;
  }
  body .wrap{padding-top:18px}
  .card{
    padding:16px;
    border-radius:18px;
  }
  input,select,textarea,button{
    padding:12px 12px;
    font-size:16px;
  }
  select{min-height:46px}
  textarea{min-height:110px}
  .output{
    min-height:280px;
    padding:14px;
  }
  th,td{
    padding:9px 10px;
    font-size:13px;
  }
}
@media (max-width:560px){
  .cch-eyebrow,
  .cch-chip{
    font-size:11px;
    padding:6px 9px;
  }
  .card{padding:14px}
  .shared-topnav a{border-radius:9px}
  .sub,.cch-page-subtitle{line-height:1.4}
}


/* ===== LAYOUT INTEGRATED ===== */

.wrap{
  width:min(calc(100% - 40px), 1620px);
  margin:0 auto;
  padding:24px 0 28px;
}
.layout{
  display:grid;
  grid-template-columns:minmax(360px, 430px) minmax(0, 1fr);
  gap:18px;
  align-items:start;
}
.pair-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
  align-items:start;
}
.stack-md > * + *{
  margin-top:18px;
}
.module-inline-gap{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-start;
}
.module-inline-gap > *{
  margin:0 !important;
}
@media (min-width:2560px){
  .wrap{
    width:min(calc(100vw - 500px), 1980px);
  }
}
@media (max-width:1400px){
  .layout{grid-template-columns:1fr}
}
@media (max-width:980px){
  .pair-grid{grid-template-columns:1fr}
  .layout{gap:16px}
  .stack-md > * + *{margin-top:16px}
}
@media (max-width:900px){
  .wrap{
    width:min(calc(100% - 20px), 100%);
    padding:18px 0 22px;
  }
  .layout{
    grid-template-columns:1fr;
    gap:14px;
  }
  .pair-grid{
    grid-template-columns:1fr;
    gap:14px;
  }
  .module-inline-gap{
    flex-direction:column;
    align-items:stretch;
  }
}
@media (max-width:560px){
  .wrap{
    width:min(calc(100% - 16px), 100%);
    padding:14px 0 18px;
  }
  .layout,.pair-grid{gap:12px}
  .stack-md > * + *{margin-top:12px}
}



/* ===== CCH DOKU / SPACING / COLLAPSE FIX ===== */
.stack,
.stack-md{
  display:flex;
  flex-direction:column;
  gap:18px;
}

.pillbar{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-start;
}

.list-toggle-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:12px 0 10px;
}

.list-toggle-head h3{
  margin:0;
  font-size:15px;
}

.collapse-toggle{
  width:auto !important;
  min-width:38px;
  height:38px;
  padding:0 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:linear-gradient(180deg,#ffffff 0%, #eef4fb 100%);
  color:var(--text);
  font-weight:800;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 2px 10px rgba(15,23,42,.05);
}

.actions.module-inline-gap{
  gap:10px;
}

.actions.module-inline-gap + .tableWrap,
.actions.module-inline-gap + .output{
  margin-top:4px;
}

.tableWrap + .pillbar,
.tableWrap + .tiny{
  margin-top:12px;
}

.small-table table{
  min-width:100%;
}

.checkitem{
  display:flex;
  gap:10px;
  align-items:flex-start;
}

.checkitem input{
  width:auto;
  margin-top:3px;
}

.area-add-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.area-add-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(255,255,255,.62);
}

.area-add-item strong{
  display:block;
  margin-bottom:3px;
}

.area-meta{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:4px;
}

.area-block{
  border:1px solid var(--line);
  border-radius:18px;
  overflow:hidden;
  background:rgba(255,255,255,.60);
  box-shadow:0 8px 20px rgba(15,23,42,.04);
  margin-top:12px;
}

.area-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:14px 16px;
  background:linear-gradient(180deg,#f7faff 0%, #eef4fb 100%);
  border-bottom:1px solid var(--line);
}

.area-head strong,
.area-head b{
  font-size:15px;
}

.area-body{
  padding:16px;
}

.collapsed .area-body{
  display:none;
}

.task-group{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  margin-bottom:12px;
  background:rgba(255,255,255,.7);
}

.task-group h4{
  margin:0 0 10px;
  font-size:14px;
}

.problem-box{
  margin-top:12px;
  padding-top:12px;
  border-top:1px dashed var(--line);
  display:none;
}

.problem-box.show{
  display:block;
}

.route-list .item,
.mini-list .item{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(255,255,255,.62);
  margin-bottom:10px;
}

.item strong{
  display:block;
}

#routeActionList{
  display:grid;
  gap:8px;
}

#activeAreas > * + *,
#areaAddList > * + *,
#addedAreaList > * + *,
.route-list > * + *{
  margin-top:10px;
}

#addRouteBtn{
  width:100%;
  min-height:48px;
}

#routeToTasks{
  width:auto !important;
}

#addProblemRow,
#addDocRow,
#addCommRow,
#addStaffRow,
#addTaskRow{
  width:auto !important;
}

#staffTimeSummary{
  margin-top:12px;
}

#activeAreas{
  margin-top:8px;
}

.card > h2 + .actions,
.card > h2 + .tiny,
.card > h2 + .grid2,
.card > h2 + .grid3,
.card > h2 + .grid4{
  margin-top:10px;
}

@media (max-width:980px){
  .list-toggle-head{
    align-items:flex-start;
  }

  .area-head{
    align-items:flex-start;
  }

  .route-list .item,
  .mini-list .item,
  .area-add-item{
    flex-direction:column;
    align-items:stretch;
  }
}



/* =========================================================
   CCH Dienstplan DB-only Clean Helpers
   ========================================================= */
body.cch-page-cch-dienstplan-erstellen .mt-8{margin-top:8px !important}
body.cch-page-cch-dienstplan-erstellen .mt-10{margin-top:10px !important}
body.cch-page-cch-dienstplan-erstellen .mt-12{margin-top:12px !important}
body.cch-page-cch-dienstplan-erstellen .mt-14{margin-top:14px !important}
body.cch-page-cch-dienstplan-erstellen .modal-title{margin:8px 0 0 !important}
body.cch-page-cch-dienstplan-erstellen .modal-subtitle{font-size:14px !important;margin-top:8px !important}
body.cch-page-cch-dienstplan-erstellen .modal-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
}
body.cch-page-cch-dienstplan-erstellen .status-line{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}
body.cch-page-cch-dienstplan-erstellen .empty-state{
  padding:18px;
  border:1px dashed var(--line);
  border-radius:18px;
  color:var(--muted);
  text-align:center;
  background:rgba(255,255,255,.54);
}
@media(max-width:760px){
  body.cch-page-cch-dienstplan-erstellen .modal-head{
    flex-direction:column;
  }
}


/* =========================================================
   CCH Global Modal / DB-Load Overlay Fix
   Ensures DB load dialogs stay hidden until .show is set.
   ========================================================= */
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.34);
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:120;
  padding:18px;
}
.modal-backdrop.show{
  display:flex;
}
.modal-card{
  width:min(860px, calc(100% - 28px));
  max-height:min(82vh, 900px);
  overflow:auto;
  background:linear-gradient(180deg, rgba(255,255,255,.92) 0%, rgba(255,255,255,.98) 100%);
  border:1px solid var(--line);
  border-radius:24px;
  box-shadow:0 20px 60px rgba(15,23,42,.24);
  padding:18px;
}
.plan-pick-list{
  display:grid;
  gap:10px;
  margin-top:14px;
}
.plan-pick-item{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(255,255,255,.70);
}
.plan-pick-meta{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:8px;
}
.plan-pick-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.mode-chip-online{
  color:#15713a;
  border-color:#bcebcf;
  background:#f4fff7;
}
.mode-chip-offline{
  color:#9a6700;
  border-color:#f1dfb6;
  background:#fffaf0;
}
@media(max-width:1100px){
  .modal-backdrop{
    align-items:flex-end;
    padding:0;
  }
  .modal-card{
    width:100%;
    max-width:100%;
    max-height:92vh;
    border-radius:22px 22px 0 0;
    padding:16px;
  }
}
@media print{
  .modal-backdrop{display:none !important;}
}
