:root{
    --ink:#12151b;
    --surface:#1a1e26;
    --surface-2:#232834;
    --lane: rgba(243,239,231,0.12);
    --lane-strong: rgba(243,239,231,0.22);
    --chalk:#f3efe7;
    --muted:#8b93a5;
    --clay:#c1440e;
    --clay-soft:#e3703c;
    --go:#5fa777;
    --warn:#dfb24f;
    font-family:'Work Sans', sans-serif;
    color-scheme: dark;
    --radius: 10px;
  }
  :root[data-theme="light"]{
    color-scheme: light;
    --ink:#f4f5f0;
    --surface:#ffffff;
    --surface-2:#eef0e9;
    --lane: rgba(20,23,27,0.07);
    --lane-strong: rgba(20,23,27,0.16);
    --chalk:#1a1d23;
    --muted:#666d7a;
    --clay:#c1440e;
    --clay-soft:#a84a17;
    --go:#347a48;
    --warn:#95701a;
  }
  :root[data-theme="light"] ::selection{ color:#fff; }
  :root[data-theme="light"] .rail-brand .mark span{ color:var(--clay); }
  *{box-sizing:border-box;}
  html,body{height:100%;}
  body{
    margin:0;
    background:var(--ink);
    color:var(--chalk);
    padding-top:env(safe-area-inset-top,0px);
    padding-bottom:env(safe-area-inset-bottom,0px);
    -webkit-font-smoothing:antialiased;
  }
  ::selection{ background:var(--clay); color:var(--chalk); }

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

  /* ---------- Sidebar ---------- */
  .rail{
    width:236px;
    flex:0 0 236px;
    background:var(--surface);
    border-right:1px solid var(--lane);
    padding:28px 0 20px;
    display:flex;
    flex-direction:column;
    position:sticky;
    top:0;
    height:100vh;
  }
  .rail-brand{
    padding:0 24px 22px;
    border-bottom:1px solid var(--lane);
    margin-bottom:6px;
  }
  .rail-brand .mark{
    font-family:'Bebas Neue', sans-serif;
    font-size:30px;
    letter-spacing:1px;
    line-height:1;
    color:var(--chalk);
  }
  .rail-brand .mark span{ color:var(--clay-soft); display:block; font-size:16px; letter-spacing:4px; margin-top:3px; }
  .rail-brand .sub{
    font-size:12.5px;
    color:var(--muted);
    margin-top:4px;
  }
  .lanes{ list-style:none; margin:14px 0 0; padding:0; flex:1; }
  .lane-item{
    position:relative;
    display:flex;
    align-items:center;
    gap:12px;
    padding:13px 24px;
    cursor:pointer;
    border-left:3px solid transparent;
    color:var(--muted);
    font-size:14.5px;
    font-weight:500;
    transition:color .15s ease, background .15s ease, border-color .15s ease;
  }
  .lane-item .num{
    font-family:'Bebas Neue', sans-serif;
    font-size:19px;
    color:var(--muted);
    width:20px;
  }
  .lane-item:hover{ color:var(--chalk); background:rgba(243,239,231,0.03); }
  .lane-item.active{
    color:var(--chalk);
    border-left-color:var(--clay);
    background:rgba(193,68,14,0.10);
  }
  .lane-item.active .num{ color:var(--clay-soft); }
  .rail-foot{
    padding:14px 24px 0;
    border-top:1px solid var(--lane);
    font-size:11.5px;
    color:var(--muted);
    line-height:1.5;
  }

  /* ---------- Main ---------- */
  .main{ flex:1; min-width:0; }
  .topbar{
    padding:30px 40px 20px;
    border-bottom:1px solid var(--lane);
    display:flex;
    align-items:flex-end;
    justify-content:space-between;
    gap:20px;
    flex-wrap:wrap;
  }
  .topbar h1{
    font-family:'Bebas Neue', sans-serif;
    font-weight:400;
    font-size:32px;
    letter-spacing:.5px;
    margin:0 0 4px;
  }
  .topbar p{ margin:0; color:var(--muted); font-size:13.5px; max-width:520px; }
  .content{ padding:32px 40px 60px; max-width:1180px; }

  /* ---------- Generic building blocks ---------- */
  .grid{ display:grid; gap:20px; }
  .grid-2{ grid-template-columns: 1fr 1fr; }
  .grid-3{ grid-template-columns: repeat(3, 1fr); }

  .mobile-brand{
    display:none;
    font-family:'Bebas Neue', sans-serif;
    font-size:14px;
    letter-spacing:3px;
    color:var(--muted);
    margin-bottom:8px;
  }
  .mobile-brand span{ color:var(--clay-soft); }

  .bottom-nav{
    display:none;
    position:fixed; left:0; right:0; bottom:0;
    background:var(--surface);
    border-top:1px solid var(--lane-strong);
    padding-bottom:env(safe-area-inset-bottom,0px);
    z-index:40;
  }
  .bottom-nav-inner{ display:flex; }
  .bottom-nav-item{
    flex:1; display:flex; flex-direction:column; align-items:center; gap:2px;
    padding:9px 4px 7px; background:none; border:none; cursor:pointer;
    color:var(--muted); font-family:inherit; font-size:10.5px; font-weight:600;
    letter-spacing:.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  .bottom-nav-item .num{ font-family:'Bebas Neue', sans-serif; font-size:16px; line-height:1; color:var(--muted); }
  .bottom-nav-item.active{ color:var(--clay-soft); }
  .bottom-nav-item.active .num{ color:var(--clay); }

  @media (max-width: 880px){
    .grid-2, .grid-3{ grid-template-columns: 1fr; }
    .rail{ display:none; }
    .content, .topbar{ padding-left:18px; padding-right:18px; }
    .topbar{ padding-top:18px; }
    body{ padding-bottom: calc(60px + env(safe-area-inset-bottom,0px)); }
    .mobile-brand{ display:block; }
    .bottom-nav{ display:block; }
    .content{ padding-bottom:40px; }
  }

  .card{
    background:var(--surface);
    border:1px solid var(--lane);
    border-radius:var(--radius);
    padding:22px;
  }
  .card h2{
    font-family:'Bebas Neue', sans-serif;
    font-weight:400;
    font-size:19px;
    letter-spacing:.3px;
    margin:0 0 14px;
    display:flex; align-items:center; gap:8px;
  }
  .card h2 small{ font-family:'Work Sans',sans-serif; font-size:11.5px; color:var(--muted); font-weight:500; }

  label{ display:block; font-size:12px; color:var(--muted); margin:0 0 5px; font-weight:500; }
  input, select, textarea{
    width:100%;
    background:var(--surface-2);
    border:1px solid var(--lane-strong);
    color:var(--chalk);
    border-radius:7px;
    padding:9px 11px;
    font-size:14px;
    font-family:inherit;
    outline:none;
  }
  input:focus, select:focus, textarea:focus{ border-color:var(--clay-soft); }
  .field{ margin-bottom:13px; }
  .row{ display:flex; gap:12px; flex-wrap:wrap; }
  .row > .field{ flex:1 1 150px; min-width:0; }

  button{
    font-family:inherit; font-size:13.5px; font-weight:600;
    border-radius:7px; border:1px solid transparent; cursor:pointer;
    padding:9px 16px;
  }
  .btn-primary{ background:var(--clay); color:#fff; }
  .btn-primary:hover{ background:var(--clay-soft); }
  .btn-ghost{ background:transparent; border-color:var(--lane-strong); color:var(--chalk); }
  .btn-ghost:hover{ border-color:var(--clay-soft); color:var(--clay-soft); }
  .btn-danger{ background:transparent; border-color:var(--lane-strong); color:#d98a6f; }
  .btn-danger:hover{ border-color:#d98a6f; }
  .btn-sm{ padding:6px 11px; font-size:12.5px; }
  button:focus-visible, input:focus-visible, select:focus-visible, .lane-item:focus-visible{ outline:2px solid var(--clay-soft); outline-offset:2px; }

  table{ width:100%; border-collapse:collapse; font-size:13.5px; }
  th{ text-align:left; color:var(--muted); font-weight:600; font-size:11.5px; padding:0 10px 8px; border-bottom:1px solid var(--lane-strong); }
  td{ padding:11px 10px; border-bottom:1px solid var(--lane); vertical-align:middle; }
  tr:last-child td{ border-bottom:none; }
  tr.runner-row{ cursor:pointer; }
  tr.runner-row:hover{ background:rgba(243,239,231,0.03); }
  tr.runner-row.selected{ background:rgba(193,68,14,0.10); }

  .pill{
    display:inline-block; padding:3px 9px; border-radius:100px; font-size:11px; font-weight:600;
    background:var(--surface-2); color:var(--muted); border:1px solid var(--lane-strong);
  }
  .pill.go{ color:var(--go); border-color:rgba(95,167,119,.4); }
  .pill.warn{ color:var(--warn); border-color:rgba(223,178,79,.4); }
  .pill.clay{ color:var(--clay-soft); border-color:rgba(227,112,60,.4); }

  .empty{ color:var(--muted); font-size:13.5px; padding:26px 4px; text-align:center; border:1px dashed var(--lane-strong); border-radius:8px; }

  /* ---------- Calendario mensual ---------- */
  .cal-card{ padding:18px 18px 22px; }
  .cal-toolbar{ display:flex; align-items:center; gap:4px; margin-bottom:14px; }
  .cal-month-label{ font-family:'Bebas Neue', sans-serif; font-size:19px; letter-spacing:.5px; min-width:150px; text-align:center; }
  .cal-toolbar .icon-btn{ font-size:19px; border:1px solid var(--lane-strong); border-radius:7px; padding:2px 10px; }
  .cal-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
  .cal-weekhead{ margin-bottom:6px; }
  .cal-weekday{ text-align:center; font-size:11px; font-weight:600; color:var(--muted); padding:2px 0 4px; }
  .cal-day{
    min-height:74px; border:1px solid var(--lane); border-radius:8px; padding:7px 8px;
    cursor:pointer; display:flex; flex-direction:column; gap:3px; background:var(--surface-2);
    transition:border-color .15s ease, background .15s ease;
  }
  .cal-day:hover{ border-color:var(--lane-strong); }
  .cal-day.other-month{ background:transparent; border-color:transparent; cursor:default; }
  .cal-day.today .cal-daynum{ color:var(--clay-soft); }
  .cal-day.selected{ border-color:var(--clay-soft); background:rgba(193,68,14,0.08); }
  .cal-day.has-session{ box-shadow: inset 3px 0 0 var(--clay); }
  .cal-daynum{ font-family:'Bebas Neue', sans-serif; font-size:16px; color:var(--muted); }
  .cal-chip{ font-size:11px; font-weight:600; color:var(--chalk); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .cal-chip-sub{ font-size:10.5px; color:var(--muted); }
  @media (max-width:640px){
    .cal-grid{ gap:4px; }
    .cal-day{ min-height:52px; padding:5px 5px; border-radius:6px; }
    .cal-chip, .cal-chip-sub{ display:none; }
    .cal-day.has-session::after{ content:''; display:block; width:6px; height:6px; border-radius:50%; background:var(--clay-soft); margin-top:auto; }
  }

  .day-editor-title{ font-family:'Bebas Neue', sans-serif; font-size:19px; letter-spacing:.3px; text-transform:capitalize; }
  .day-editor-name{ margin-top:6px; max-width:280px; }
  .muted-note{ color:var(--muted); font-size:13px; margin-top:4px; }
  .table-wrap{ overflow-x:auto; margin-top:14px; }
  .day-table{ min-width:640px; }
  .day-table input, .day-table select{ padding:6px 8px; font-size:13px; }
  .empty-row{ text-align:center; color:var(--muted); padding:18px 4px !important; border-bottom:none !important; }
  .chip-toggle-sm button{ padding:6px 8px; font-size:11.5px; }
  .stat-mini{ display:flex; flex-direction:column; gap:1px; }
  .stat-mini b{ font-size:15px; }
  .stat-mini span{ font-size:11px; color:var(--muted); }
  .day-tools-label{ font-size:12.5px; color:var(--muted); margin-bottom:8px; font-weight:500; }
  .weekday-check{ display:inline-flex; align-items:center; gap:5px; font-size:12.5px; color:var(--chalk); background:var(--surface-2); border:1px solid var(--lane-strong); border-radius:7px; padding:5px 9px; cursor:pointer; }
  .weekday-check input{ width:auto; margin:0; accent-color:var(--clay); }

  .stat{ display:flex; flex-direction:column; gap:2px; }
  .stat .n{ font-family:'Bebas Neue', sans-serif; font-size:30px; line-height:1; color:var(--chalk); }
  .stat .l{ font-size:11.5px; color:var(--muted); }
  .stat .n span{ font-size:15px; color:var(--muted); font-family:'Work Sans',sans-serif; }

  .divider-lane{ height:1px; background: repeating-linear-gradient(90deg, var(--lane-strong) 0 14px, transparent 14px 22px); margin:18px 0; }

  .block-card{
    border:1px solid var(--lane-strong); border-radius:9px; padding:16px; background:var(--surface-2);
    margin-bottom:12px; position:relative;
  }
  .block-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; gap:10px; flex-wrap:wrap; }
  .block-head .tag{ font-family:'Bebas Neue',sans-serif; font-size:16px; letter-spacing:.3px; }
  .block-result{
    display:flex; gap:18px; flex-wrap:wrap; margin-top:10px; padding-top:10px; border-top:1px dashed var(--lane-strong);
    font-size:12.5px; color:var(--muted);
  }
  .block-result b{ color:var(--chalk); font-weight:600; }

  .macropausa-strip{
    display:flex; align-items:center; gap:10px; margin:6px 0 14px; padding:8px 14px;
    background:rgba(223,178,79,.08); border:1px dashed rgba(223,178,79,.4); border-radius:8px;
    font-size:12.5px; color:var(--warn);
  }

  .chip-toggle{ display:flex; border:1px solid var(--lane-strong); border-radius:7px; overflow:hidden; }
  .chip-toggle button{ flex:1; border-radius:0; background:transparent; color:var(--muted); border:none; }
  .chip-toggle button.on{ background:var(--clay); color:#fff; }

  .session-tab{
    padding:8px 14px; border-radius:7px 7px 0 0; border:1px solid var(--lane-strong); border-bottom:none;
    background:var(--surface-2); color:var(--muted); cursor:pointer; font-size:13px; font-weight:600;
  }
  .session-tab.active{ color:var(--chalk); background:var(--surface); border-color:var(--clay-soft); }
  .session-tabs{ display:flex; gap:6px; flex-wrap:wrap; align-items:flex-end; }

  .zone-table td.zname{ font-weight:600; }
  .zone-row-0{ box-shadow: inset 3px 0 0 var(--muted); }
  .zone-row-1{ box-shadow: inset 3px 0 0 var(--go); }
  .zone-row-2{ box-shadow: inset 3px 0 0 #8fbf6f; }
  .zone-row-3{ box-shadow: inset 3px 0 0 var(--warn); }
  .zone-row-4{ box-shadow: inset 3px 0 0 var(--clay-soft); }
  .zone-row-5{ box-shadow: inset 3px 0 0 var(--clay); }

  .canvas-wrap{ position:relative; height:280px; }

  .kv{ display:flex; justify-content:space-between; font-size:13px; padding:7px 0; border-bottom:1px solid var(--lane); }
  .kv:last-child{ border-bottom:none; }
  .kv .k{ color:var(--muted); }
  .kv .v{ font-weight:600; }

  select.runner-picker{ max-width:280px; }

  .theme-toggle{ display:flex; border:1px solid var(--lane-strong); border-radius:8px; overflow:hidden; flex:0 0 auto; }
  .theme-toggle button{ border-radius:0; background:transparent; color:var(--muted); border:none; padding:8px 14px; font-size:12.5px; }
  .theme-toggle button.on{ background:var(--clay); color:#fff; }

  .icon-btn{ background:transparent; border:none; color:var(--muted); cursor:pointer; padding:4px; font-size:15px; }
  .icon-btn:hover{ color:var(--clay-soft); }

  ::-webkit-scrollbar{ width:9px; height:9px; }
  ::-webkit-scrollbar-thumb{ background:var(--lane-strong); border-radius:10px; }

  /* ---------- Exportar planificación (hoja PDF) ---------- */
  .export-sheet{
    background:#ffffff; color:#1a1d23; border-radius:var(--radius);
    padding:32px; max-width:820px; margin:0 auto;
    box-shadow:0 1px 3px rgba(0,0,0,.18);
  }
  .export-header{ text-align:center; margin-bottom:22px; padding-bottom:16px; border-bottom:2px solid #c1440e; }
  .export-header h1{ font-family:'Bebas Neue',sans-serif; font-weight:400; font-size:26px; letter-spacing:.5px; margin:0 0 4px; }
  .export-sub{ font-size:14px; font-weight:600; }
  .export-resumen{ color:#666d7a; font-size:12px; margin-top:6px; }
  .export-session{ border:1px solid #e5e2da; border-radius:9px; padding:16px 18px; margin-bottom:14px; page-break-inside:avoid; }
  .export-session h2{ font-family:'Bebas Neue',sans-serif; font-weight:400; font-size:17px; letter-spacing:.3px; margin:0 0 10px; color:#c1440e; }
  .export-bloques{ list-style:none; margin:0; padding:0; }
  .export-bloques li{ font-size:13px; padding:7px 0; border-bottom:1px dashed #ece9e1; }
  .export-bloques li:last-child{ border-bottom:none; }
  .export-macropausa{ font-size:11.5px; color:#95701a; font-style:italic; margin-top:3px; }
  .export-sin-bloques{ color:#95701a; font-size:12.5px; }
  .export-totales{ margin-top:8px; font-size:12.5px; font-weight:600; color:#347a48; text-align:right; }

  @media print{
    body *{ visibility:hidden; }
    #export-sheet, #export-sheet *{ visibility:visible; }
    #export-sheet{ position:absolute; left:0; top:0; width:100%; box-shadow:none; margin:0; padding:0 16px; }
    .no-print{ display:none !important; }
  }
