:root{
  --bg:#f3f6fa;
  --card:#fff;
  --ink:#10243d;
  --muted:#6e7b8b;
  --line:#dbe3ec;
  --navy:#0c2b47;
  --blue:#0b78bd;
  --blue-soft:#eaf6fd;
  --green:#1b8b50;
  --green-soft:#edf9f2;
  --amber:#a76b00;
  --amber-soft:#fff6dc;
  --shadow:0 8px 28px rgba(18,39,63,.08);
}

*{box-sizing:border-box}

body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

header{
  background:var(--navy);
  color:#fff;
  padding:18px 22px;
}

.header-inner{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-start;
}

.user-bar{
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.user-meta{
  text-align:right;
}

.user-name{
  font-weight:800;
}

.user-email,
.user-role{
  color:#c8d6e3;
  font-size:12px;
}

.ghost{
  background:transparent;
  color:#fff;
  border:1px solid #c8d6e3;
}

.login-view{
  min-height:calc(100vh - 88px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:40px 20px;
}

.login-card{
  width:min(440px,100%);
  background:var(--card);
  border:1px solid var(--line);
  border-radius:12px;
  box-shadow:var(--shadow);
  padding:32px 28px 28px;
}

.login-brand{
  margin-bottom:22px;
}

.login-org{
  margin:0;
  font-size:11px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--muted);
}

.login-product{
  margin:6px 0 0;
  font-size:20px;
  font-weight:800;
  color:var(--navy);
  line-height:1.25;
}

.login-card h2{
  margin:0;
  font-size:17px;
  font-weight:800;
  color:var(--ink);
}

.login-lead{
  margin:6px 0 22px;
  font-size:13px;
  color:var(--muted);
}

.login-card label{
  margin:0 0 6px;
  font-size:12px;
  font-weight:700;
  letter-spacing:0;
  text-transform:none;
  color:#3d5163;
}

.login-card input[type="email"],
.login-card input[type="password"],
.login-card input[type="text"]{
  width:100%;
  height:46px;
  margin:0 0 16px;
  padding:0 12px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font:15px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

.login-card input:focus{
  outline:2px solid var(--blue);
  outline-offset:1px;
  border-color:var(--blue);
}

.login-password-wrap{
  position:relative;
  margin:0 0 16px;
}

.login-password-wrap input{
  margin:0;
  padding-right:92px;
}

.login-toggle{
  position:absolute;
  top:50%;
  right:8px;
  transform:translateY(-50%);
  width:auto;
  margin:0;
  padding:6px 8px;
  border:0;
  border-radius:6px;
  background:transparent;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}

.login-toggle:hover,
.login-toggle:focus{
  color:var(--navy);
  background:#f3f6fa;
  outline:2px solid var(--blue);
  outline-offset:1px;
}

.login-error{
  margin:0 0 12px;
  color:#8a1f1f;
  background:#fdecec;
  border-radius:8px;
  padding:8px 10px;
  font-size:13px;
  line-height:1.4;
}

.login-submit{
  width:100%;
  height:46px;
  margin:0;
  border-radius:8px;
  font-size:15px;
}

.login-submit:hover{
  background:#0969a8;
}

.login-submit:focus{
  outline:2px solid var(--navy);
  outline-offset:2px;
}

.login-submit:disabled{
  opacity:.55;
  cursor:not-allowed;
}

@media(max-width:600px){
  .login-view{
    padding:20px;
    align-items:flex-start;
  }

  .login-card{
    width:100%;
    padding:24px 18px 20px;
  }
}

.toolbar.firebase-mode{
  /* Filterleiste bleibt flexibel; DEV-Rollensimulation ist ausgeblendet. */
}

header h1{
  margin:0;
  font-size:21px;
}

header p{
  margin:4px 0 0;
  color:#c8d6e3;
}

.wrap{
  max-width:1500px;
  margin:auto;
  padding:16px;
}

.toolbar,
.filter-bar{
  display:flex;
  flex-wrap:wrap;
  gap:10px 12px;
  align-items:flex-end;
  background:#fff;
  padding:12px 14px;
  border-radius:14px;
  box-shadow:var(--shadow);
  margin-bottom:14px;
}

.filter-search{
  flex:1 1 240px;
  min-width:180px;
}

.filter-control{
  flex:0 1 150px;
  min-width:118px;
  max-width:190px;
}

.filter-new{
  flex:0 0 auto;
  margin-left:auto;
  height:40px;
  padding:0 16px;
  white-space:nowrap;
}

.filter-bar label{
  margin-bottom:4px;
  text-transform:none;
  letter-spacing:0;
}

.filter-bar input,
.filter-bar select,
.toolbar input,
.toolbar select{
  width:100%;
  height:40px;
  padding:0 10px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font:inherit;
}

.filter-bar input:focus,
.filter-bar select:focus,
.toolbar input:focus,
.toolbar select:focus{
  outline:2px solid var(--blue);
  outline-offset:1px;
  border-color:var(--blue);
}

label{
  display:block;
  font-size:11px;
  font-weight:800;
  color:var(--muted);
  margin-bottom:5px;
  text-transform:uppercase;
}

input[readonly],
input.lot-locked{
  background:#e9eef4;
  color:#294055;
  cursor:not-allowed;
}

button{
  border:0;
  border-radius:10px;
  padding:10px 13px;
  font:inherit;
  font-weight:800;
  cursor:pointer;
}

.primary{
  background:var(--blue);
  color:#fff;
}

.secondary{
  background:#e9eef4;
  color:#294055;
}

.grid{
  display:grid;
  grid-template-columns:300px 1fr;
  gap:14px;
}

.panel{
  background:var(--card);
  border-radius:16px;
  box-shadow:var(--shadow);
  overflow:hidden;
}

.panel-title{
  padding:13px 15px;
  border-bottom:1px solid var(--line);
  font-weight:850;
}

.list{
  padding:8px;
}

.case{
  padding:11px;
  border:1px solid transparent;
  border-radius:11px;
  margin-bottom:7px;
  cursor:pointer;
}

.case:hover{
  background:#f7f9fc;
}

.case.active{
  background:#e9f5fd;
  border-color:#b9dff5;
}

.row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}

.small{
  font-size:12px;
  color:var(--muted);
}

.badge{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:4px 8px;
  font-size:11px;
  font-weight:850;
  background:#edf2f7;
  color:#526273;
}

.b-blue{
  background:#e5f3fd;
  color:#075e95;
}

.b-green{
  background:var(--green-soft);
  color:var(--green);
}

.b-amber{
  background:var(--amber-soft);
  color:var(--amber);
}

.b-archive{
  background:#f4e8ff;
  color:#6b2fa0;
}

.headline-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:flex-start;
  justify-content:flex-end;
}

.admin-menu{
  position:relative;
}

.admin-menu-btn{
  background:#e9eef4;
  color:#294055;
  padding:7px 11px;
  font-size:12px;
  font-weight:750;
}

.admin-menu-list{
  position:absolute;
  right:0;
  top:calc(100% + 4px);
  min-width:210px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  box-shadow:var(--shadow);
  padding:6px;
  z-index:20;
}

.admin-menu-list button{
  display:block;
  width:100%;
  text-align:left;
  background:transparent;
  color:var(--ink);
  font-weight:650;
  font-size:13px;
  padding:8px 10px;
  border-radius:8px;
}

.admin-menu-list button:hover{
  background:#f3f6fa;
}

.admin-menu-list .danger-item{
  color:#8a1f1f;
}

.admin-menu-list .danger-item:hover{
  background:#fdecec;
}

.notice-archive{
  border:1px solid #d8b4fe;
  background:#faf5ff;
  color:#5b21b6;
  border-radius:12px;
  padding:10px 12px;
  margin:12px 0;
}

.delete-dialog{
  padding:28px 28px 22px;
}

.delete-dialog h3{
  margin:0;
  color:#8a1f1f;
}

.delete-meta{
  margin:12px 0;
  padding:10px 12px;
  background:#f7f9fc;
  border-radius:10px;
  font-size:13px;
}

.delete-warning{
  margin:12px 0;
  padding:10px 12px;
  background:#fdecec;
  border-radius:10px;
  color:#8a1f1f;
}

.delete-warning ul{
  margin:8px 0 0;
  padding-left:18px;
}

.delete-error{
  margin:12px 0 0;
  padding:10px 12px;
  background:#fdecec;
  border-radius:10px;
  color:#8a1f1f;
  font-size:13px;
}

.danger{
  background:#b42318;
  color:#fff;
}

.danger:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.content{
  padding:16px;
}

.headline{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
}

.headline h2{
  margin:0;
  font-size:20px;
}

.kpis{
  display:grid;
  grid-template-columns:repeat(4,minmax(140px,1fr));
  gap:10px;
  margin:14px 0;
}

.kpi{
  border:1px solid var(--line);
  border-radius:12px;
  padding:11px;
  background:#fff;
}

.kpi .l{
  font-size:11px;
  color:var(--muted);
  font-weight:800;
  text-transform:uppercase;
}

.kpi .v{
  font-size:15px;
  font-weight:850;
  margin-top:3px;
}

.current-box{
  border:1px solid #9fd2ef;
  background:var(--blue-soft);
  border-radius:14px;
  padding:14px;
  margin:12px 0;
}

.current-box .top{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}

.current-box h3{
  margin:0;
  font-size:16px;
}

.current-box .next{
  margin-top:8px;
  font-size:12px;
  color:#496579;
}

.site-timing{
  display:flex;
  flex-wrap:wrap;
  gap:4px 18px;
  margin-top:8px;
  font-size:12px;
  color:#496579;
}

.site-timing b{
  color:var(--ink);
  font-weight:750;
}

.progress{
  height:8px;
  background:#e8edf3;
  border-radius:999px;
  overflow:hidden;
  margin-top:10px;
}

.progress span{
  display:block;
  height:100%;
  background:var(--blue);
}

.phase{
  border:1px solid var(--line);
  border-radius:14px;
  margin:12px 0;
  overflow:hidden;
}

.phase-title{
  padding:10px 12px;
  background:#f7f9fc;
  font-weight:850;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.phase-body{
  padding:0 12px;
}

.step-row{
  display:grid;
  grid-template-columns:34px minmax(260px,1fr) 170px 170px auto;
  gap:10px;
  align-items:center;
  padding:11px 0;
  border-bottom:1px solid var(--line);
}

.step-row:last-child{
  border-bottom:0;
}

.dot{
  width:28px;
  height:28px;
  border-radius:50%;
  display:grid;
  place-items:center;
  font-size:12px;
  font-weight:900;
  background:#edf2f7;
  color:#657486;
}

.step-row.done .dot{
  background:var(--green);
  color:#fff;
}

.step-row.current .dot{
  background:var(--blue);
  color:#fff;
}

.step-title{
  font-weight:800;
}

.step-help{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}

.owner,
.closer{
  font-size:12px;
}

.owner b,
.closer b{
  display:block;
  color:#34495e;
}

.step-action{
  justify-self:end;
}

.step-action button{
  padding:8px 10px;
  background:#eaf3fb;
  color:#0b5b8d;
}

.step-action button.go{
  background:var(--blue);
  color:#fff;
}

.step-action button[disabled]{
  opacity:.35;
  cursor:not-allowed;
}

.section{
  border:1px solid var(--line);
  border-radius:12px;
  margin-top:12px;
  overflow:hidden;
}

.section h3{
  margin:0;
  padding:10px 12px;
  background:#f7f9fc;
  font-size:14px;
}

.section .body{
  padding:12px;
}

table{
  width:100%;
  border-collapse:collapse;
}

th,
td{
  padding:8px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
}

th{
  font-size:11px;
  color:var(--muted);
  text-transform:uppercase;
}

.empty{
  padding:36px;
  text-align:center;
  color:var(--muted);
}

dialog{
  border:0;
  border-radius:18px;
  padding:0;
  width:min(760px,calc(100% - 24px));
  box-shadow:0 28px 80px rgba(10,26,40,.32);
}

dialog::backdrop{
  background:rgba(10,26,40,.52);
}

.modal{
  padding:28px 28px 22px;
}

.modal h3{
  margin:0;
  font-size:20px;
  font-weight:800;
  color:var(--navy);
}

.modal-lead{
  margin:6px 0 22px;
  font-size:13px;
  color:var(--muted);
  line-height:1.45;
}

.formgrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}

.span2{
  grid-column:1/-1;
}

.modal label{
  margin:0 0 6px;
  font-size:12px;
  font-weight:700;
  letter-spacing:0;
  text-transform:none;
  color:#3d5163;
}

.req{
  color:#b42318;
  font-weight:800;
}

.modal input,
.modal select,
.modal textarea{
  width:100%;
  height:44px;
  margin:0;
  padding:0 12px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font:15px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

.modal textarea{
  height:auto;
  min-height:92px;
  padding:10px 12px;
  resize:vertical;
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus{
  outline:2px solid var(--blue);
  outline-offset:1px;
  border-color:var(--blue);
}

.field-hint{
  margin:6px 0 0;
  font-size:12px;
  color:var(--muted);
  text-transform:none;
  font-weight:500;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:22px;
  padding-top:16px;
  border-top:1px solid var(--line);
}

.modal-actions .primary,
.modal-actions .secondary{
  height:42px;
  padding:0 16px;
}

@media(max-width:1050px){
  .kpis{
    grid-template-columns:1fr 1fr;
  }

  .step-row{
    grid-template-columns:34px 1fr 150px auto;
  }

  .closer{
    display:none;
  }
}

@media(max-width:800px){
  .toolbar,
  .filter-bar{
    padding:12px;
  }

  .filter-search,
  .filter-control,
  .filter-new{
    flex:1 1 100%;
    max-width:none;
    min-width:0;
    margin-left:0;
  }

  .filter-new{
    height:44px;
  }

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

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

  .step-row{
    grid-template-columns:32px 1fr auto;
  }

  .owner{
    grid-column:2;
  }

  .step-action{
    grid-column:3;
    grid-row:1/3;
  }

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

  .span2{
    grid-column:auto;
  }

  .modal{
    padding:22px 18px 18px;
  }
}

@media(max-width:520px){
  .wrap{
    padding:10px;
  }

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

  .content{
    padding:12px;
  }

  .step-row{
    grid-template-columns:30px 1fr;
  }

  .step-action{
    grid-column:2;
    grid-row:auto;
    justify-self:start;
  }

  .owner{
    grid-column:2;
  }
}

.login-view[hidden],
#appView[hidden],
#extView[hidden],
#userBar[hidden],
#roleSimBox[hidden],
#archiveFilterBox[hidden],
#deleteTaskWarning[hidden],
#deleteError[hidden]{
  display:none !important;
}

.ext-toolbar{
  margin-bottom:14px;
}

.ext-toolbar-head{
  margin:0 0 10px 2px;
}

.ext-toolbar h2{
  margin:0;
  font-size:18px;
}

.ext-filter-bar{
  margin-bottom:0;
}

.ext-table,
.site-table{
  width:100%;
}

.site-nr{
  white-space:nowrap;
  font-weight:850;
}

.site-mark{
  display:inline-block;
  min-width:1.1em;
  color:var(--green);
}

tr.current td{
  background:var(--blue-soft);
}

tr.current .step-title{
  font-weight:850;
}

tr.done td{
  background:var(--green-soft);
}

.ext-history td{
  background:#f7f9fc;
}

@media(max-width:900px){
  .ext-filter-bar .filter-search,
  .ext-filter-bar .filter-control{
    flex:1 1 calc(50% - 12px);
    max-width:none;
  }
}

@media(max-width:640px){
  .ext-filter-bar .filter-search,
  .ext-filter-bar .filter-control{
    flex:1 1 100%;
  }
}

.process-tabs{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:12px 0 4px;
}

.process-tab{
  background:#e9eef4;
  color:#294055;
  padding:8px 12px;
}

.process-tab.active{
  background:var(--navy);
  color:#fff;
}

.dual-status,
.overview-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin:12px 0;
}

.process-card{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
  background:#fff;
}

.process-card h3{
  margin:0 0 10px;
  font-size:15px;
}

.process-card .v{
  font-size:15px;
  font-weight:850;
  margin:4px 0 6px;
}

.notice{
  border:1px solid var(--line);
  background:#fff;
  border-radius:12px;
  padding:10px 12px;
  margin:10px 0;
  font-size:13px;
}

.notice-warn{
  border-color:#e3c48a;
  background:var(--amber-soft);
}

.notice-task{
  border-color:#9fd2ef;
  background:var(--blue-soft);
}

.notice-link{
  border-color:#c5e0f0;
  background:#f7fbfe;
}

.notice-list{
  margin:8px 0 0;
  padding-left:18px;
}

.notice-actions{
  margin-top:8px;
}

.compare-box{
  border:1px solid #9fd2ef;
  background:var(--blue-soft);
  border-radius:12px;
  padding:12px;
  margin:12px 0 0;
  font-weight:750;
}

.kpis-stack{
  grid-template-columns:1fr;
  margin:0 0 12px;
}

.site-decision{
  margin-top:12px;
  padding-top:10px;
  border-top:1px solid #c5e0f0;
}

.site-decision-row{
  display:flex;
  gap:16px;
  margin:6px 0 10px;
}

.site-decision .choice{
  display:flex;
  gap:6px;
  align-items:center;
  text-transform:none;
  font-size:13px;
  font-weight:700;
  color:var(--ink);
}

.site-decision textarea{
  width:100%;
  border:1px solid var(--line);
  border-radius:10px;
  padding:8px 10px;
  font:inherit;
}

@media(max-width:800px){
  .dual-status,
  .overview-grid{
    grid-template-columns:1fr;
  }
}
