:root {
  --mk-bg: #004b91;
  --mk-bg-2: #004b91;
  --mk-accent: #38bdf8;
  --mk-accent-2: #7dd3fc;
  --mk-ok: #22c55e;
  --mk-warn: #f59e0b;
  --mk-bad: #ef4444;
  --mk-text-dark: #06243a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #1e3a5f 0%, var(--mk-bg) 48%, #07101f 100%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
  overflow: hidden;
}

.app{
  position: fixed;
  inset: 0;
  display:flex;
  flex-direction:column;
}

.header{
  display:flex;
  gap:10px;
  padding:14px 16px 8px;
  align-items:center;
}

.header img{
  width:40px;
  height:40px;
  border-radius:10px;
}

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

.header h1{
  font-size:.98rem;
  font-weight:700;
  margin:0;
  opacity:.95;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.profileBtn{
  flex:0 0 auto;
  width:auto;
  height:34px;
  padding:0 12px;
  border-radius:12px;
  font-size:.72rem;
  background:rgba(255,255,255,.14);
  color:#fff;
  border:1px solid rgba(255,255,255,.18);
}

.netline{ display:none; }

.pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:2px 8px;
  border-radius:999px;
  font-size:.62rem;
  font-weight:800;
  letter-spacing:.14em;
  background: rgba(255,255,255,.18);
  border:1px solid rgba(255,255,255,.22);
}
.pill.online{ background: rgba(34,197,94,.22); border-color: rgba(34,197,94,.45); }
.pill.offline{ background: rgba(239,68,68,.20); border-color: rgba(239,68,68,.40); }

.netmeta{
  font-size:.68rem;
  opacity:.85;
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.syncbar{
  display:flex;
  gap:10px;
  align-items:center;
  padding:6px 12px 8px;
}

.syncinfo{ flex:1; }
.synctitle{ font-size:.72rem; font-weight:800; letter-spacing:.08em; opacity:.92; }
.syncmeta{ font-size:.68rem; opacity:.85; }

button.send{
  width:120px;
  height:44px;
  border:none;
  border-radius:14px;
  font-size:.9rem;
  font-weight:800;
  cursor:pointer;
  background: rgba(255,255,255,.18);
  color:#fff;
}

.core{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  padding-top:6px;
}

.circle{
  width:152px;
  height:152px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background: rgba(56, 189, 248, .10);
  border: 2px solid rgba(125, 211, 252, .24);
  box-shadow: 0 0 0 1px rgba(255,255,255,.04) inset, 0 20px 48px rgba(0,0,0,.20);
  transition: background .08s linear, border-color .08s linear, transform .08s linear;
}

.circle span{
  font-size:.7rem;
  font-weight:850;
  letter-spacing:.16em;
}

.led{
  width:10px;
  height:10px;
  border-radius:50%;
  background:#9ca3af;
}

.clock{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size:.96rem;
}

.hint{
  min-height:1.4rem;
  font-size:.75rem;
  opacity:.92;
  padding:0 16px;
  text-align:center;
  line-height:1.25rem;
  font-weight:700;
}

.sessions{
  flex:1;
  overflow:auto;
  padding:8px 12px;
}

.session{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:10px 10px;
  margin-bottom:8px;
  border-radius:12px;
  font-size:.78rem;
  background: rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.08);
  cursor:default;
}

.sessionTop{
  display:flex;
  align-items:flex-start;
  gap:8px;
}

.sessionMain{
  flex:1;
  min-width:0;
}

.session .title{
  font-weight:760;
  line-height:1.15;
  overflow-wrap:anywhere;
}

.session .subtitle{
  margin-top:2px;
  font-size:.63rem;
  opacity:.78;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.badges{
  display:flex;
  gap:6px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.badge{
  font-size:.60rem;
  font-weight:900;
  letter-spacing:.09em;
  padding:2px 8px;
  border-radius:999px;
  background: rgba(255,255,255,.16);
  border:1px solid rgba(255,255,255,.20);
  white-space:nowrap;
}
.badge.rec{ background: rgba(56,189,248,.18); border-color: rgba(56,189,248,.48); }
.badge.unsent{ background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.40); }
.badge.ready{ background: rgba(56,189,248,.16); border-color: rgba(56,189,248,.40); }
.badge.auto{ background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.42); }

.session .meta{
  font-size:.65rem;
  opacity:.84;
  overflow:hidden;
  text-overflow:ellipsis;
}

.controls{
  display:flex;
  gap:10px;
  padding:10px 12px calc(10px + env(safe-area-inset-bottom));
}

button{
  flex:1;
  height:50px;
  border:none;
  border-radius:14px;
  font-size:.9rem;
  font-weight:850;
  cursor:pointer;
}

.start{ background: var(--mk-accent); color:var(--mk-text-dark); }
.stop{ background: rgba(255,255,255,.18); color:#fff; }

button:disabled{ opacity:.5; cursor:not-allowed; }

/* v4.0.3: estados locales/limpieza */
.subhint{
  min-height:1.1rem;
  font-size:.64rem;
  opacity:.78;
  padding:0 16px;
  text-align:center;
  line-height:1rem;
}
#heldInfo{
  opacity:.72;
}
.badge.hold{
  background: rgba(245,158,11,.16);
  border-color: rgba(245,158,11,.42);
}
.badge.done{
  background: rgba(34,197,94,.16);
  border-color: rgba(34,197,94,.42);
}


.tagbar{
  display:grid;
  grid-template-columns: minmax(120px,.9fr) minmax(0,1.7fr) auto;
  gap:8px;
  padding:0 12px 8px;
  align-items:end;
}
.tagField{display:flex;flex-direction:column;gap:4px;min-width:0;}
.tagField span{font-size:.62rem;font-weight:900;letter-spacing:.09em;opacity:.78;text-transform:uppercase;}
.tagField select,.tagField input{
  width:100%;height:38px;border:1px solid rgba(255,255,255,.18);border-radius:12px;
  background:rgba(255,255,255,.12);color:#fff;padding:0 10px;outline:none;font-size:.78rem;
}
.tagField select option{background:#0f172a;color:#fff;}
.tagField input::placeholder{color:rgba(255,255,255,.52);}
.tagSave{height:38px;border:0;border-radius:12px;background:rgba(56,189,248,.28);color:#fff;font-weight:900;padding:0 12px;}
.tagbar.invalid .tagField select,.tagbar.invalid .tagField input{border-color:rgba(239,68,68,.68);box-shadow:0 0 0 2px rgba(239,68,68,.12);}
.session .tagline{font-size:.65rem;opacity:.90;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

@media (max-width:390px){.tagbar{grid-template-columns:1fr}.tagSave{width:100%;}}

/* Coordinaciones v6 */
:root,
html[data-coordinator-type="neutral"]{
  --theme-rgb:5,53,105;
  --theme-bg:#eef2f6;
  --theme-surface:#ffffff;
  --theme-surface-strong:#f7f9fb;
  --theme-border:#d4dae1;
  --theme-text:#17202b;
  --theme-muted:#657180;
  --theme-accent:#053569;
  --theme-accent-soft:#dce8f5;
  --theme-accent-contrast:#ffffff;
  --theme-shadow:0 18px 44px rgba(19,31,45,.10);
}

html[data-coordinator-type="promocion"]{
  --theme-rgb:229,102,0;
  --theme-bg:#fff7f0;
  --theme-surface:#ffffff;
  --theme-surface-strong:#fffaf5;
  --theme-border:#efd7c5;
  --theme-text:#2d2118;
  --theme-muted:#756558;
  --theme-accent:#e56600;
  --theme-accent-soft:#ffead8;
  --theme-accent-contrast:#ffffff;
  --theme-shadow:0 18px 44px rgba(105,53,12,.10);
}

html[data-coordinator-type="recuperacion"]{
  --theme-rgb:20,87,184;
  --theme-bg:#f2f6fc;
  --theme-surface:#ffffff;
  --theme-surface-strong:#f7faff;
  --theme-border:#cedaeb;
  --theme-text:#13263f;
  --theme-muted:#617087;
  --theme-accent:#1457b8;
  --theme-accent-soft:#dfeafb;
  --theme-accent-contrast:#ffffff;
  --theme-shadow:0 18px 44px rgba(16,52,103,.10);
}

html[data-coordinator-type="administrativo"]{
  --theme-rgb:99,108,119;
  --theme-bg:#eef0f2;
  --theme-surface:#ffffff;
  --theme-surface-strong:#f7f8f9;
  --theme-border:#c9ced4;
  --theme-text:#20252b;
  --theme-muted:#68717b;
  --theme-accent:#636c77;
  --theme-accent-soft:#e4e7ea;
  --theme-accent-contrast:#ffffff;
  --theme-shadow:0 18px 44px rgba(35,41,48,.11);
}

html,body{
  background:var(--theme-bg);
  color:var(--theme-text);
}

body{
  display:grid;
  place-items:center;
}

.app{
  left:50%;
  right:auto;
  width:min(100%,680px);
  transform:translateX(-50%);
  background:var(--theme-bg);
  color:var(--theme-text);
  border-inline:1px solid var(--theme-border);
}

.header{
  gap:12px;
  padding:16px 18px 10px;
  background:var(--theme-surface);
  border-bottom:1px solid var(--theme-border);
}

.header img{
  width:48px;
  height:48px;
  border:1px solid var(--theme-border);
  border-radius:14px;
  background:#fff;
}

.header h1{
  color:var(--theme-text);
  font-size:1.02rem;
  letter-spacing:.01em;
  opacity:1;
}

.identitySummary{
  display:flex;
  flex-direction:column;
  min-width:0;
  color:var(--theme-muted);
  font-size:.64rem;
  line-height:1.15rem;
  letter-spacing:.045em;
}

#identityName{
  color:var(--theme-text);
  font-weight:850;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

#identityMeta{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.profileBtn{
  flex:0 0 auto;
  width:auto;
  height:36px;
  padding:0 13px;
  border:1px solid var(--theme-border);
  border-radius:11px;
  background:var(--theme-surface-strong);
  color:var(--theme-text);
  font-size:.72rem;
}

.syncbar{
  margin:10px 12px 0;
  padding:10px 12px;
  border:1px solid var(--theme-border);
  border-radius:14px;
  background:var(--theme-surface);
  box-shadow:0 6px 20px rgba(24,34,45,.045);
}

.synctitle{
  color:var(--theme-text);
  opacity:1;
}

.syncmeta{
  color:var(--theme-muted);
  opacity:1;
}

button.send{
  width:126px;
  height:38px;
  border:1px solid var(--theme-border);
  border-radius:11px;
  background:var(--theme-accent-soft);
  color:var(--theme-accent);
  font-size:.78rem;
}

.tagbar{
  display:none;
  grid-template-columns:minmax(200px,1.4fr) minmax(140px,.8fr) minmax(170px,1fr) auto;
  gap:9px;
  margin:10px 12px 0;
  padding:12px;
  border:1px solid var(--theme-border);
  border-radius:14px;
  background:var(--theme-surface);
  box-shadow:var(--theme-shadow);
}

.tagbar.is-open{display:grid;}
.tagField span{color:var(--theme-muted);opacity:1;}

.tagField select,.tagField input{
  height:42px;
  border-color:var(--theme-border);
  border-radius:10px;
  background:var(--theme-surface-strong);
  color:var(--theme-text);
  font-size:.8rem;
}

.tagField input{text-transform:uppercase;}
.tagField input::placeholder{color:var(--theme-muted);opacity:.65;}
.tagField select option{background:#fff;color:#17202b;}

.tagSave{
  height:42px;
  align-self:end;
  padding:0 16px;
  border-radius:10px;
  background:var(--theme-accent);
  color:var(--theme-accent-contrast);
}

.core{
  gap:8px;
  padding-top:18px;
}

.circle{
  width:166px;
  height:166px;
  background:rgba(var(--theme-rgb),.10);
  border-color:rgba(var(--theme-rgb),.28);
  box-shadow:0 0 0 1px rgba(255,255,255,.5) inset,var(--theme-shadow);
  color:var(--theme-accent);
}

.circle.is-active{color:var(--theme-text);}
.led{background:#a7afb8;box-shadow:0 0 0 4px rgba(99,108,119,.10);}
.led.is-active{background:var(--theme-accent);box-shadow:0 0 0 5px rgba(var(--theme-rgb),.14);}
.clock,.hint{color:var(--theme-text);}
.subhint{color:var(--theme-muted);opacity:1;}

.sessions{padding:10px 12px;}
.session{
  background:var(--theme-surface);
  border-color:var(--theme-border);
  box-shadow:0 5px 16px rgba(24,34,45,.04);
}
.session .subtitle,.session .meta{color:var(--theme-muted);opacity:1;}
.badge{background:var(--theme-surface-strong);border-color:var(--theme-border);color:var(--theme-text);}
.badge.rec,.badge.ready{background:var(--theme-accent-soft);border-color:rgba(var(--theme-rgb),.32);color:var(--theme-accent);}

.controls{
  padding:10px 12px calc(12px + env(safe-area-inset-bottom));
  background:var(--theme-surface);
  border-top:1px solid var(--theme-border);
}

.start{background:var(--theme-accent);color:var(--theme-accent-contrast);}
.stop{background:var(--theme-surface-strong);color:var(--theme-text);border:1px solid var(--theme-border);}
.administrative-mode .stop{display:none;}

button:focus-visible,.tagField select:focus-visible,.tagField input:focus-visible{
  outline:3px solid rgba(var(--theme-rgb),.22);
  outline-offset:2px;
}

@media (max-width:720px){
  .tagbar{grid-template-columns:1fr 1fr;}
  .tagName{grid-column:1/-1;}
}

@media (max-width:480px){
  .header{padding:12px 14px 9px;}
  .tagbar{grid-template-columns:1fr;}
  .tagName{grid-column:auto;}
  .tagSave{width:100%;}
  .circle{width:148px;height:148px;}
}

.onboardingBrand{display:none;}

body.onboarding-required{
  display:block;
  overflow:auto;
  background:var(--theme-bg);
}

.onboarding-required .header,
.onboarding-required .syncbar,
.onboarding-required .core,
.onboarding-required .sessions,
.onboarding-required .controls{
  display:none;
}

.onboarding-required .app{
  position:static;
  width:100%;
  min-height:100dvh;
  transform:none;
  border:0;
}

.onboarding-required .tagbar,
.onboarding-required .tagbar.is-open{
  position:fixed;
  inset:0;
  z-index:1000;
  display:grid;
  grid-template-columns:minmax(0,520px);
  align-content:center;
  justify-content:center;
  gap:14px;
  margin:0;
  padding:24px max(18px,calc((100vw - 520px)/2));
  overflow:auto;
  border:0;
  border-radius:0;
  background:var(--theme-bg);
  box-shadow:none;
}

.onboarding-required .onboardingBrand{
  display:grid;
  justify-items:center;
  gap:5px;
  margin-bottom:10px;
  color:var(--theme-muted);
  letter-spacing:.12em;
}

.onboarding-required .onboardingBrand img{
  width:88px;
  height:88px;
  margin-bottom:8px;
  border:1px solid var(--theme-border);
  border-radius:22px;
}

.onboarding-required .onboardingBrand span{
  font-size:.68rem;
  font-weight:800;
}

.onboarding-required .onboardingBrand strong{
  color:var(--theme-text);
  font-size:1.1rem;
  letter-spacing:.08em;
}

.onboarding-required .tagField,
.onboarding-required .tagSave{
  width:100%;
}

.onboarding-required .tagSave{
  margin-top:4px;
}
