:root {
  --bg:         #10101a;
  --bg-card:    #16161f;
  --bg-card2:   #1c1c28;
  --bg-grid:    #13131e;
  --bg-col:     #15151f;
  --bg-col-alt: #131320;
  --bg-today:   #1c1a10;
  --border:     rgba(255,255,255,0.08);
  --border-h:   rgba(255,255,255,0.04);
  --white:      #f0f0f8;
  --muted:      #7a7a9a;
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--white);
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.is-hidden.is-hidden { display: none; }

/* ── LOCATION MODAL ────────────────────────── */
.loc-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.loc-overlay.visible { display: flex; }
.loc-modal {
  background: #111318; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px; width: 100%; max-width: 680px;
  overflow: hidden; display: flex; flex-direction: column;
  max-height: 90vh;
}
.loc-header {
  padding: 18px 20px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.loc-header-left { display: flex; align-items: center; gap: 10px; }
.loc-pin-emoji { font-size: 20px; }
.loc-title { font-size: 15px; font-weight: 800; color: #f0f0f0; }
.loc-subtitle { font-size: 12px; color: #888; }
.loc-close {
  background: rgba(255,255,255,0.07); border: none; color: #aaa;
  width: 30px; height: 30px; border-radius: 50%; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.loc-close:hover { background: rgba(255,255,255,0.14); color: #fff; }
#loc-map { width: 100%; height: 340px; }
.loc-info {
  padding: 14px 20px; display: flex; gap: 20px; flex-wrap: wrap;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.loc-stat { display: flex; flex-direction: column; gap: 2px; }
.loc-stat-label { font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: #666; }
.loc-stat-value { font-size: 14px; font-weight: 700; color: #f0f0f0; }
.loc-status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle;
}
.loc-status-on  { background: #4ccfa0; box-shadow: 0 0 6px #4ccfa0; }
.loc-status-off { background: #666; box-shadow: 0 0 6px #666; }
.loc-marker-emoji { font-size: 28px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.loc-footer {
  padding: 10px 20px; font-size: 11px; color: #555;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex; justify-content: space-between; align-items: center;
}
.loc-refresh {
  background: none; border: 1px solid rgba(255,255,255,0.1); color: #888;
  border-radius: 20px; padding: 4px 12px; font-size: 11px; cursor: pointer;
  font-family: 'Montserrat', sans-serif; transition: all .2s;
}
.loc-refresh:hover { border-color: rgba(255,255,255,0.25); color: #ccc; }
.loc-no-data {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 340px; gap: 12px; color: #666;
}
.loc-no-data-icon { font-size: 40px; }
.loc-no-data-text { font-size: 14px; font-weight: 600; }
.loc-no-data-sub { font-size: 12px; color: #444; text-align: center; max-width: 300px; }

/* ── APP ───────────────────────────────────── */
#screen-app { display: none; flex-direction: column; height: 100vh; overflow: hidden; }

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 12px; flex-shrink: 0; flex-wrap: wrap;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-back {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500;
  transition: color .2s; white-space: nowrap;
}
.header-back:hover { color: var(--white); }
.portal-link-badge {
  text-decoration: none; display: flex; align-items: center; gap: 6px;
  background: rgba(184,151,90,0.12); border: 1px solid rgba(184,151,90,0.3);
  color: var(--gold-light); font-size: 12px; font-weight: 700;
  padding: 5px 13px; border-radius: 100px; letter-spacing: 0.04em;
  transition: background .2s;
}
.portal-link-badge:hover { background: rgba(184,151,90,0.22); }
.header-car {
  background: rgba(184,151,90,0.12); border: 1px solid rgba(184,151,90,0.22);
  color: var(--gold-light); padding: 5px 14px; border-radius: 100px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap;
}
.week-nav { display: flex; align-items: center; gap: 6px; }
.btn-nav {
  background: var(--bg-card2); border: 1px solid var(--border); color: var(--white);
  width: 30px; height: 30px; border-radius: 8px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s; flex-shrink: 0;
}
.btn-nav:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.15); }
.week-label {
  font-size: 13px; font-weight: 700; white-space: nowrap;
  min-width: 150px; text-align: center; color: var(--white);
}
.btn-today {
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 5px 11px; border-radius: 7px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em; font-family: 'Montserrat', sans-serif; cursor: pointer;
  transition: border-color .2s, color .2s; white-space: nowrap; text-transform: uppercase;
}
.btn-today:hover { border-color: var(--gold); color: var(--gold); }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-user { font-size: 12px; color: var(--muted); white-space: nowrap; }
.btn-new-res {
  background: var(--gold); color: #000; border: none;
  border-radius: 8px; padding: 8px 16px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.03em; font-family: 'Montserrat', sans-serif; cursor: pointer;
  transition: background .2s; white-space: nowrap;
}
.btn-new-res:hover { background: var(--gold-light); }
.btn-block {
  background: rgba(233,47,49,0.12); border: 1px solid rgba(233,47,49,0.35); color: #ff8080;
  border-radius: 8px; padding: 8px 16px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.03em; font-family: 'Montserrat', sans-serif; cursor: pointer;
  transition: background .2s; white-space: nowrap;
}
.btn-block:hover { background: rgba(233,47,49,0.22); }
.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 12px; border-radius: 7px; font-size: 11px; font-weight: 600;
  font-family: 'Montserrat', sans-serif; cursor: pointer;
  transition: border-color .2s, color .2s; white-space: nowrap;
}
.btn-logout:hover { border-color: rgba(255,255,255,0.2); color: var(--white); }
.btn-location {
  background: rgba(62,207,207,0.12); border: 1px solid rgba(62,207,207,0.3);
  color: #3ecfcf; border-radius: 100px; padding: 6px 14px;
  font-size: 12px; font-weight: 700; font-family: 'Montserrat', sans-serif;
  cursor: pointer; transition: all .2s;
}
.btn-location:hover { background: rgba(62,207,207,0.22); }

/* ── LEGEND ────────────────────────────────── */
.legend-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.legend-label { font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-right: 4px; }
.legend-item {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  border: 1px solid transparent;
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-name { }

/* Per-person colors (mismo orden que TEAM_MEMBERS/COLORS en neta.js) */
.legend-c0  { background: rgba(108,142,255,0.18); border-color: #6c8eff; }
.legend-c0 .legend-dot { background: #6c8eff; }
.legend-c0 .legend-name { color: #8fabff; }
.legend-c1  { background: rgba(76,207,160,0.18); border-color: #4ccfa0; }
.legend-c1 .legend-dot { background: #4ccfa0; }
.legend-c1 .legend-name { color: #6de0b8; }
.legend-c2  { background: rgba(165,108,255,0.18); border-color: #a56cff; }
.legend-c2 .legend-dot { background: #a56cff; }
.legend-c2 .legend-name { color: #bf8fff; }
.legend-c3  { background: rgba(255,107,107,0.18); border-color: #ff6b6b; }
.legend-c3 .legend-dot { background: #ff6b6b; }
.legend-c3 .legend-name { color: #ff9090; }
.legend-c4  { background: rgba(255,167,38,0.2); border-color: #ffa726; }
.legend-c4 .legend-dot { background: #ffa726; }
.legend-c4 .legend-name { color: #ffbe55; }
.legend-c5  { background: rgba(62,207,207,0.18); border-color: #3ecfcf; }
.legend-c5 .legend-dot { background: #3ecfcf; }
.legend-c5 .legend-name { color: #60dfdf; }
.legend-c6  { background: rgba(255,107,178,0.18); border-color: #ff6bb2; }
.legend-c6 .legend-dot { background: #ff6bb2; }
.legend-c6 .legend-name { color: #ff8fc6; }
.legend-c7  { background: rgba(184,151,90,0.22); border-color: #b8975a; }
.legend-c7 .legend-dot { background: #b8975a; }
.legend-c7 .legend-name { color: #d4b278; }
.legend-c8  { background: rgba(120,200,80,0.18); border-color: #78c850; }
.legend-c8 .legend-dot { background: #78c850; }
.legend-c8 .legend-name { color: #96e06e; }
.legend-c9  { background: rgba(100,180,255,0.18); border-color: #64b4ff; }
.legend-c9 .legend-dot { background: #64b4ff; }
.legend-c9 .legend-name { color: #82c8ff; }
.legend-c10 { background: rgba(220,100,220,0.18); border-color: #dc64dc; }
.legend-c10 .legend-dot { background: #dc64dc; }
.legend-c10 .legend-name { color: #f082f0; }
.legend-c11 { background: rgba(255,140,100,0.18); border-color: #ff8c64; }
.legend-c11 .legend-dot { background: #ff8c64; }
.legend-c11 .legend-name { color: #ffaa82; }
.legend-c12 { background: rgba(100,220,180,0.18); border-color: #64dcb4; }
.legend-c12 .legend-dot { background: #64dcb4; }
.legend-c12 .legend-name { color: #82f0c8; }

/* ── WEEK GRID ─────────────────────────────── */
.week-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

/* Sticky day-name header */
.week-days-header {
  display: grid;
  grid-template-columns: 48px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
.wdh-gutter { flex-shrink: 0; }
.wdh-day {
  padding: 12px 6px 10px;
  text-align: center;
  border-left: 1px solid var(--border);
  transition: background .2s;
}
.wdh-day.is-weekend { background: rgba(0,0,0,0.15); }
.wdh-day-name {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); display: block;
  margin-bottom: 4px;
}
.wdh-day-num {
  font-size: 22px; font-weight: 800; line-height: 1; display: block;
  color: var(--white);
}
.wdh-day.is-today {
  background: rgba(184,151,90,0.07);
  border-bottom: 2px solid var(--gold);
}
.wdh-day.is-today .wdh-day-num {
  background: var(--gold); color: #000;
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.wdh-day.is-today .wdh-day-name { color: var(--gold-light); }

/* Scrollable body */
.week-body {
  flex: 1; overflow-y: auto; overflow-x: auto;
  display: grid;
  grid-template-columns: 48px repeat(7, minmax(100px, 1fr));
  background: var(--bg-grid);
  border-top: 1px solid var(--border);
}
.week-body::-webkit-scrollbar { width: 5px; height: 5px; }
.week-body::-webkit-scrollbar-track { background: transparent; }
.week-body::-webkit-scrollbar-thumb { background: #2a2a3a; border-radius: 3px; }

/* Time gutter */
.time-gutter { position: relative; background: var(--bg-card); border-right: 1px solid var(--border); }
.time-label {
  position: absolute; right: 8px;
  font-size: 10px; color: #7878a0; font-weight: 700;
  transform: translateY(-50%); white-space: nowrap; user-select: none;
  letter-spacing: 0.05em;
}

/* Day columns */
.day-col {
  position: relative; border-left: 1px solid var(--border);
  background: var(--bg-col); cursor: pointer;
  transition: background .15s;
}
.day-col:nth-child(even) { background: var(--bg-col-alt); }
.day-col:hover { background: rgba(255,255,255,0.025); }
.day-col.is-today {
  background: var(--bg-today);
  border-left: 1px solid rgba(184,151,90,0.25);
}
.day-col.is-weekend { background: rgba(0,0,0,0.2); }
.day-col.is-past { opacity: 0.45; cursor: default; }

/* Grid lines */
.hour-line {
  position: absolute; left: 0; right: 0;
  border-top: 1px solid rgba(255,255,255,0.07);
  pointer-events: none;
}
.hour-line.half {
  border-top: 1px dashed rgba(255,255,255,0.03);
}

/* Reservation block */
.res-block {
  position: absolute; left: 3px; right: 3px;
  border-radius: 6px; padding: 4px 8px;
  overflow: hidden; cursor: pointer;
  border-left-width: 3px; border-left-style: solid;
  border-top: 1px solid; border-right: 1px solid; border-bottom: 1px solid;
  transition: filter .15s, transform .1s;
  z-index: 2;
}
.res-block:hover { filter: brightness(1.2); transform: scaleX(0.98); }
.res-block-name { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-block-dest { font-size: 10px; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.res-block-time { font-size: 10px; opacity: 0.5; margin-top: 1px; }

/* Per-person reservation colors (mismo orden que legend-c*) */
.res-c0  { background: rgba(108,142,255,0.18); border-color: #6c8eff; }
.res-c0 .res-block-name, .res-c0 .res-block-dest, .res-c0 .res-block-time { color: #8fabff; }
.res-c1  { background: rgba(76,207,160,0.18); border-color: #4ccfa0; }
.res-c1 .res-block-name, .res-c1 .res-block-dest, .res-c1 .res-block-time { color: #6de0b8; }
.res-c2  { background: rgba(165,108,255,0.18); border-color: #a56cff; }
.res-c2 .res-block-name, .res-c2 .res-block-dest, .res-c2 .res-block-time { color: #bf8fff; }
.res-c3  { background: rgba(255,107,107,0.18); border-color: #ff6b6b; }
.res-c3 .res-block-name, .res-c3 .res-block-dest, .res-c3 .res-block-time { color: #ff9090; }
.res-c4  { background: rgba(255,167,38,0.2); border-color: #ffa726; }
.res-c4 .res-block-name, .res-c4 .res-block-dest, .res-c4 .res-block-time { color: #ffbe55; }
.res-c5  { background: rgba(62,207,207,0.18); border-color: #3ecfcf; }
.res-c5 .res-block-name, .res-c5 .res-block-dest, .res-c5 .res-block-time { color: #60dfdf; }
.res-c6  { background: rgba(255,107,178,0.18); border-color: #ff6bb2; }
.res-c6 .res-block-name, .res-c6 .res-block-dest, .res-c6 .res-block-time { color: #ff8fc6; }
.res-c7  { background: rgba(184,151,90,0.22); border-color: #b8975a; }
.res-c7 .res-block-name, .res-c7 .res-block-dest, .res-c7 .res-block-time { color: #d4b278; }
.res-c8  { background: rgba(120,200,80,0.18); border-color: #78c850; }
.res-c8 .res-block-name, .res-c8 .res-block-dest, .res-c8 .res-block-time { color: #96e06e; }
.res-c9  { background: rgba(100,180,255,0.18); border-color: #64b4ff; }
.res-c9 .res-block-name, .res-c9 .res-block-dest, .res-c9 .res-block-time { color: #82c8ff; }
.res-c10 { background: rgba(220,100,220,0.18); border-color: #dc64dc; }
.res-c10 .res-block-name, .res-c10 .res-block-dest, .res-c10 .res-block-time { color: #f082f0; }
.res-c11 { background: rgba(255,140,100,0.18); border-color: #ff8c64; }
.res-c11 .res-block-name, .res-c11 .res-block-dest, .res-c11 .res-block-time { color: #ffaa82; }
.res-c12 { background: rgba(100,220,180,0.18); border-color: #64dcb4; }
.res-c12 .res-block-name, .res-c12 .res-block-dest, .res-c12 .res-block-time { color: #82f0c8; }
.res-blocked { background: rgba(233,47,49,0.15); border-color: #e92f31; }
.res-blocked .res-block-name, .res-blocked .res-block-dest, .res-blocked .res-block-time { color: #ff8080; }

/* Now indicator */
.now-line {
  position: absolute; left: 0; right: 0;
  border-top: 2px solid #ff4d6a; z-index: 3; pointer-events: none;
}
.now-line::before {
  content: ''; position: absolute; left: -4px; top: -4px;
  width: 8px; height: 8px; background: #ff4d6a; border-radius: 50%;
}

/* Popup */
.res-popup {
  position: fixed; z-index: 300;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 18px 20px;
  min-width: 230px; max-width: 280px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.res-popup-color-bar { height: 3px; border-radius: 2px; margin-bottom: 12px; }
.res-popup-name { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.res-popup-time { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.res-popup-dest { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.res-popup-notes { font-size: 12px; color: #555; font-style: italic; margin-bottom: 12px; }
.res-popup-del {
  background: rgba(233,47,49,0.1); border: 1px solid rgba(233,47,49,0.25);
  color: #ff8080; border-radius: 8px; padding: 8px 14px;
  font-size: 12px; font-weight: 600; font-family: 'Montserrat', sans-serif;
  cursor: pointer; width: 100%; transition: background .2s;
}
.res-popup-del:hover { background: rgba(233,47,49,0.2); }

/* ── MODAL ─────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 24px;
}
.overlay.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px; padding: 36px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px;
}
.modal-head h3 { font-size: 20px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--muted); font-size: 24px;
  cursor: pointer; line-height: 1; transition: color .2s;
}
.modal-close:hover { color: var(--white); }
.fg { margin-bottom: 18px; }
.fg label {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
.fg input, .fg select, .fg textarea {
  width: 100%; background: var(--bg-card2); border: 1px solid var(--border);
  color: var(--white); border-radius: 10px; padding: 12px 14px;
  font-size: 14px; font-family: 'Montserrat', sans-serif;
  outline: none; appearance: none; transition: border-color .2s;
}
.fg input:focus, .fg select:focus, .fg textarea:focus { border-color: var(--gold); }
.fg select option { background: #14141f; }
.fg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.allday-label { display: flex; align-items: center; gap: 10px; text-transform: none; font-size: 13px; cursor: pointer; }
.allday-checkbox { width: 16px; height: 16px; accent-color: var(--red); cursor: pointer; }
.conflict-msg {
  background: rgba(233,47,49,0.1); border: 1px solid rgba(233,47,49,0.3);
  color: #ff8080; border-radius: 10px; padding: 12px 14px;
  font-size: 13px; margin-bottom: 18px; display: none;
}
.btn-submit {
  width: 100%; background: var(--gold); color: #000; border: none;
  border-radius: 12px; padding: 14px; font-size: 14px; font-weight: 700;
  font-family: 'Montserrat', sans-serif; cursor: pointer;
  transition: background .2s, transform .15s;
}
.btn-submit:hover { background: var(--gold-light); transform: translateY(-1px); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── TOAST ─────────────────────────────────── */
#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 999; pointer-events: none; }
.toast {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; border-radius: 12px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  animation: tIn .3s ease, tOut .3s ease 2.7s forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.ok  { background: var(--green); color: #fff; }
.toast.err { background: var(--red);   color: #fff; }
@keyframes tIn  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes tOut { to { opacity:0; } }

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 768px) {
  .week-days-header { grid-template-columns: 40px repeat(7, minmax(72px, 1fr)); }
  .week-body        { grid-template-columns: 40px repeat(7, minmax(72px, 1fr)); }
  .header-user      { display: none; }
  .week-label       { min-width: 110px; font-size: 11px; }
  .legend-bar       { display: none; }
}
@media (max-width: 540px) {
  .app-header { padding: 10px 12px; }
  .header-car { display: none; }
  .modal { padding: 24px 18px; }
  .fg-row { grid-template-columns: 1fr; }
}
