
:root{
  --navy:#0b2f6b;
  --text:#172554;
  --muted:#64748b;
  --line:#cbd5e1;
  --bg:#f3f6fb;
  --white:#fff;

  --th:#7c3fb2;
  --pt:#25a8b5;
  --pr:#3275d8;
  --tc:#f18b21;
  --as:#34a447;
  --ev:#d9468f;
  --ep:#0f766e;

  --red:#c81e1e;

  --training:#f4f8ff;
  --training-title:#e8f1fd;

  --transition:#fff8ee;
  --transition-title:#ffedcf;

  --final:#fffbed;
  --final-title:#fff0ba;

  font-family:Inter,Arial,Helvetica,sans-serif;
}

*{box-sizing:border-box}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
}

button,input,select{
  font:inherit;
}

a{
  color:inherit;
}

.app-header{
  background:#fff;
  border-bottom:1px solid #dbe3ef;
  padding:13px 20px;
  display:flex;
  align-items:center;
  gap:18px;
  justify-content:space-between;
  position:sticky;
  top:0;
  z-index:30;
}

.brand{
  display:flex;
  align-items:center;
  gap:14px;
  min-width:0;
}

.brand-logo{
  width:105px;
  height:auto;
  object-fit:contain;
  flex:none;
}

.brand h1{
  font-size:20px;
  line-height:1.15;
  margin:0;
  color:var(--navy);
}

.brand p{
  margin:4px 0 0;
  font-size:12px;
  color:var(--muted);
}

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

.btn{
  border:1px solid #c8d2e1;
  background:#fff;
  color:var(--navy);
  border-radius:8px;
  padding:8px 11px;
  font-weight:750;
  cursor:pointer;
  font-size:12px;
  text-decoration:none;
}

.btn.primary{
  background:var(--navy);
  color:#fff;
  border-color:var(--navy);
}

.btn.ghost{
  background:#f8fafc;
}

.page-shell{
  max-width:1580px;
  margin:0 auto;
  padding:16px;
}

.status-strip{
  display:flex;
  align-items:center;
  gap:9px;
  background:#fff;
  border:1px solid #d9e2ef;
  border-radius:10px;
  padding:9px 12px;
  margin-bottom:12px;
  font-size:12px;
  color:#40536f;
}

.status-dot{
  width:9px;
  height:9px;
  border-radius:50%;
  background:#94a3b8;
}

.status-dot.ok{background:#22a447}
.status-dot.warn{background:#e6a11b}
.status-dot.bad{background:#d72b2b}

.dashboard{
  display:grid;
  grid-template-columns:1fr 1fr 1.15fr;
  gap:12px;
  margin-bottom:13px;
}

.metric{
  background:#fff;
  border:1px solid #d9e2ef;
  border-radius:10px;
  padding:12px 14px;
}

.metric-label{
  display:block;
  font-size:12px;
  color:var(--muted);
  font-weight:750;
}

.metric strong{
  display:block;
  font-size:22px;
  color:var(--navy);
  margin:3px 0 7px;
}

.metric-sub{
  font-size:11px;
  color:var(--muted);
  line-height:1.35;
}

.progress{
  height:8px;
  background:#edf2f7;
  border-radius:99px;
  overflow:hidden;
}

.progress span{
  display:block;
  height:100%;
  width:0;
  background:#3f8e45;
  transition:width .2s;
}

.progress.theme span{
  background:var(--th);
}

.next-list{
  display:flex;
  flex-direction:column;
  gap:5px;
  margin-top:5px;
}

.next-item{
  display:flex;
  gap:8px;
  align-items:center;
  font-size:11px;
}

.next-date{
  font-weight:800;
  color:var(--navy);
  min-width:68px;
}

.export-sheet{
  background:#fff;
  border:1px solid #d6deeb;
  border-radius:14px;
  padding:12px 12px 10px;
  box-shadow:0 6px 20px rgba(20,42,80,.05);
}

.export-header{
  display:grid;
  grid-template-columns:125px 1fr 245px;
  gap:12px;
  align-items:center;
  padding:2px 8px 9px;
}

.export-logo{
  width:112px;
  height:auto;
  object-fit:contain;
}

.export-title-wrap h2{
  text-transform:uppercase;
  text-align:center;
  color:var(--navy);
  font-size:24px;
  line-height:1.05;
  margin:0 0 10px;
  letter-spacing:.2px;
}

.abbr{
  font-size:11px;
  line-height:1.5;
  color:var(--text);
}

.legend{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;
  flex-wrap:wrap;
}

.legend-item{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:11px;
  font-weight:750;
}

.badge{
  width:27px;
  height:27px;
  min-width:27px;
  display:inline-grid;
  place-items:center;
  border-radius:5px;
  color:#fff;
  font-weight:900;
  font-size:10px;
}

.badge.mini{
  width:22px;
  height:22px;
  min-width:22px;
}

.badge.TH,.event-code.TH{background:var(--th)}
.badge.PT,.event-code.PT{background:var(--pt)}
.badge.PR,.event-code.PR{background:var(--pr)}
.badge.TC,.event-code.TC{background:var(--tc)}
.badge.AS,.event-code.AS{background:var(--as)}
.badge.EV,.event-code.EV{background:var(--ev)}
.badge.EP,.event-code.EP{background:var(--ep)}

.section{
  margin-top:8px;
}

.section-title{
  background:var(--navy);
  color:#fff;
  padding:5px 12px;
  border-radius:8px 8px 0 0;
  text-transform:uppercase;
  font-weight:850;
  font-size:14px;
  letter-spacing:.15px;
}

.month-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  border:1px solid #24467e;
  border-top:none;
}

.month-card{
  min-height:155px;
  border-right:1px solid #b8c6da;
  border-bottom:1px solid #b8c6da;
  padding:7px 8px 9px;
  position:relative;
  background:#fff;
}

.month-card:nth-child(4n){
  border-right:none;
}

.month-card.phase-training{
  background:var(--training);
}

.month-card.phase-transition{
  background:var(--transition);
}

.month-card.phase-final{
  background:var(--final);
}

.month-title{
  text-align:center;
  font-size:14px;
  font-weight:850;
  color:var(--navy);
  margin:-1px -1px 7px;
  padding:5px 6px;
  border-radius:6px;
  border:1px solid rgba(90,118,160,.2);
  background:#f3f6fa;
}

.phase-training .month-title{
  background:var(--training-title);
}

.phase-transition .month-title{
  background:var(--transition-title);
}

.phase-final .month-title{
  background:var(--final-title);
}

.event-list{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.event-row{
  display:grid;
  grid-template-columns:25px 1fr auto;
  align-items:center;
  gap:7px;
  border:1px solid rgba(148,163,184,.38);
  border-radius:5px;
  min-height:31px;
  padding:3px 5px;
  background:rgba(255,255,255,.95);
}

.event-row.done{
  opacity:.68;
}

.event-row.done .event-label{
  text-decoration:line-through;
  text-decoration-thickness:1.2px;
}

.event-row.done::after{
  content:"✓";
  font-weight:900;
  color:#15803d;
  padding-right:2px;
}

.event-code{
  width:21px;
  height:21px;
  display:grid;
  place-items:center;
  border-radius:4px;
  color:#fff;
  font-size:9.5px;
  line-height:1;
  font-weight:900;
}

.event-content{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:1px;
}

.event-label{
  font-size:11.5px;
  color:#182a4f;
  line-height:1.16;
}

.event-date{
  font-size:9.5px;
  color:#667892;
  line-height:1.1;
  font-weight:700;
}

.event-actions{
  display:flex;
  gap:3px;
  align-items:center;
}

.done-check{
  width:14px;
  height:14px;
  accent-color:#17803b;
  cursor:pointer;
}

.mini-btn{
  border:0;
  background:#eef3f9;
  color:#24467e;
  border-radius:4px;
  padding:3px 5px;
  cursor:pointer;
  font-size:10px;
  font-weight:800;
}

.mini-btn.delete{
  background:#fff0f0;
  color:#b91c1c;
}

.add-event{
  margin-top:6px;
  border:1px dashed #9db0ca;
  background:rgba(255,255,255,.75);
  color:#24467e;
  border-radius:6px;
  padding:4px 8px;
  font-size:11px;
  font-weight:800;
  cursor:pointer;
}

.month-note{
  margin-top:9px;
  padding:9px;
  border:1px solid #c3d3e8;
  background:#f7fbff;
  border-radius:8px;
  font-size:11.5px;
  line-height:1.25;
  color:var(--navy);
}

.upgrade{
  margin-top:8px;
  border:1.5px solid #f97316;
  background:#fff8f2;
  border-radius:8px;
  padding:10px;
  display:flex;
  align-items:center;
  gap:10px;
  color:#27364e;
}

.upgrade .icon{
  font-size:28px;
  color:#e45b0a;
}

.upgrade b{
  display:block;
  color:#e45b0a;
  font-size:14px;
  margin-bottom:2px;
}

.final-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  border:1px solid #24467e;
  border-top:none;
}

.final-col{
  padding:8px;
  border-right:1px solid #b8c6da;
  background:#fff;
}

.final-col:last-child{
  border-right:none;
}

.final-col.phase-final{
  background:var(--final);
}

.final-col.phase-visit{
  background:#fff5f5;
}

.final-title{
  text-align:center;
  font-weight:900;
  color:var(--navy);
  font-size:14px;
  margin:0 0 7px;
}

.final-note{
  text-align:center;
  font-size:11px;
  margin-top:6px;
  color:var(--text);
}

.visit-card{
  border:1.5px solid #dc2626;
  background:#fff6f5;
  border-radius:8px;
  overflow:hidden;
}

.visit-head{
  background:#cf1b1b;
  color:#fff;
  text-align:center;
  padding:5px;
  font-weight:900;
  font-size:14px;
}

.visit-body{
  display:flex;
  gap:14px;
  align-items:center;
  padding:14px;
}

.visit-icon{
  font-size:42px;
  color:#c81e1e;
}

.visit-body h3{
  color:#c81e1e;
  margin:0 0 5px;
  font-size:18px;
}

.visit-body p{
  margin:0;
  font-size:11.5px;
  line-height:1.35;
  font-weight:700;
}

.process-row{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  padding:10px 8px 2px;
  font-size:11px;
}

.process-step{
  display:flex;
  align-items:center;
  gap:7px;
  max-width:150px;
}

.process-step span{
  font-size:25px;
}

.process-step.green{color:#277534}
.process-step.blue{color:#1d4ed8}
.process-step.orange{color:#d97706}
.process-step.red{color:#c81e1e}

.process-arrow{
  font-weight:900;
  letter-spacing:1px;
  color:#507351;
}

.public-intro{
  background:linear-gradient(135deg,#0b2f6b,#245197);
  color:#fff;
  border-radius:13px;
  padding:17px 20px;
  margin-bottom:13px;
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:center;
}

.public-intro h2{
  margin:0 0 5px;
  font-size:22px;
}

.public-intro p{
  margin:0;
  font-size:12px;
  opacity:.92;
  white-space:nowrap;
}

.public-pill{
  background:rgba(255,255,255,.14);
  border:1px solid rgba(255,255,255,.25);
  padding:8px 12px;
  border-radius:999px;
  font-size:11px;
  font-weight:800;
  white-space:nowrap;
}

.admin-lock{
  display:flex;
  gap:8px;
  align-items:center;
  background:#fff8e8;
  border:1px solid #f0d18d;
  border-radius:10px;
  padding:9px 11px;
  margin-bottom:12px;
}

.admin-lock input{
  border:1px solid #cbd5e1;
  border-radius:7px;
  padding:7px 9px;
  min-width:220px;
  font-size:12px;
}

dialog{
  border:0;
  border-radius:14px;
  padding:0;
  width:min(500px,92vw);
  box-shadow:0 18px 55px rgba(0,0,0,.2);
}

dialog::backdrop{
  background:rgba(9,30,66,.42);
}

#eventForm{
  padding:16px;
  display:grid;
  gap:12px;
}

.dialog-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.dialog-head h3{
  margin:0;
  color:var(--navy);
}

.icon-btn{
  border:0;
  background:transparent;
  font-size:27px;
  cursor:pointer;
  color:#64748b;
}

#eventForm label{
  font-size:12px;
  font-weight:800;
  color:#324665;
  display:grid;
  gap:5px;
}

#eventForm input[type="text"],
#eventForm input[type="date"],
#eventForm select{
  width:100%;
  border:1px solid #b9c7da;
  border-radius:8px;
  padding:9px;
  background:#fff;
  color:#172554;
}

.date-fields{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.check-line{
  display:flex!important;
  align-items:center;
  gap:9px!important;
}

.dialog-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:4px;
}

.toast{
  position:fixed;
  right:18px;
  bottom:18px;
  background:#0b2f6b;
  color:#fff;
  padding:10px 14px;
  border-radius:8px;
  opacity:0;
  transform:translateY(8px);
  pointer-events:none;
  transition:.2s;
  font-size:12px;
  z-index:50;
}

.toast.show{
  opacity:1;
  transform:translateY(0);
}

.exporting .no-export,
.exporting .event-actions,
.exporting .add-event,
.exporting .done-check{
  display:none!important;
}

.exporting .event-row{
  grid-template-columns:25px 1fr auto;
}

@media(max-width:1200px){
  .public-intro p{
    white-space:normal;
  }
}

@media(max-width:1100px){
  .app-header{
    position:static;
    align-items:flex-start;
    flex-direction:column;
  }

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

  .export-header{
    grid-template-columns:95px 1fr;
  }

  .abbr{
    grid-column:1/-1;
    text-align:center;
  }

  .month-grid{
    grid-template-columns:repeat(2,1fr);
  }

  .month-card:nth-child(4n){
    border-right:1px solid #b8c6da;
  }

  .month-card:nth-child(2n){
    border-right:none;
  }

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

  .final-col{
    border-right:none;
    border-bottom:1px solid #b8c6da;
  }

  .public-intro{
    align-items:flex-start;
    flex-direction:column;
  }
}

@media(max-width:680px){
  .brand-logo{width:82px}
  .brand h1{font-size:17px}

  .export-header{
    display:block;
    text-align:center;
  }

  .export-logo{
    width:90px;
  }

  .export-title-wrap h2{
    font-size:19px;
  }

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

  .month-card{
    border-right:none!important;
  }

  .process-row{
    flex-wrap:wrap;
  }

  .admin-lock{
    align-items:stretch;
    flex-direction:column;
  }

  .admin-lock input{
    min-width:0;
    width:100%;
  }

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

@media print{
  body{
    background:#fff;
  }

  .no-export{
    display:none!important;
  }

  .page-shell{
    max-width:none;
    padding:0;
  }

  .export-sheet{
    border:0;
    box-shadow:none;
    border-radius:0;
    padding:0;
  }

  .event-actions,
  .add-event,
  .done-check{
    display:none!important;
  }

  .event-row{
    grid-template-columns:25px 1fr auto;
  }

  @page{
    size:A3 landscape;
    margin:8mm;
  }
}
