:root{
  --bg:#faf7f2;--surface:#ffffff;--text:#222222;--muted:#717171;--line:#ebe7e0;--accent:#ff385c;
  --airbnb:#ff385c;--booking:#003580;--direct:#00a699;--blocked:#717171;--danger:#e00b41;--warning:#e07a00;
  --shadow:0 6px 24px rgba(40,30,20,.05);--radius:16px;
  --sat:env(safe-area-inset-top, 0px);
  --sab:env(safe-area-inset-bottom, 0px);
  --sal:env(safe-area-inset-left, 0px);
  --sar:env(safe-area-inset-right, 0px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
body{
  margin:0;
  font-family:Inter,-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",Roboto,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  touch-action:manipulation;
  overscroll-behavior-y:none;
}
button,input,select,textarea{font:inherit;touch-action:manipulation}
button{cursor:pointer;user-select:none;-webkit-user-select:none}

.shell{
  min-height:100vh;
  min-height:100dvh;
  background:var(--bg);
  display:flex;
  flex-direction:column;
  padding-left:var(--sal);
  padding-right:var(--sar);
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:calc(12px + var(--sat)) 24px 14px 24px;
  background:rgba(250,247,242,.92);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
  border-bottom:1px solid var(--line);
}
.brand-group{display:flex;align-items:center;gap:10px}
.brand-badge{background:var(--accent);color:#fff;font-size:11px;font-weight:800;padding:3px 8px;border-radius:6px;letter-spacing:.04em;text-transform:uppercase}
.brand{font-weight:700;font-size:18px;letter-spacing:-.02em;color:var(--text);display:flex;align-items:center;gap:8px}

.nav{display:flex;gap:6px;flex-wrap:wrap}
.nav button,.ghost,.seg button{border:0;background:transparent;color:var(--muted);padding:10px 14px;border-radius:10px;font-weight:500;transition:all .15s;min-height:40px}
.nav button:hover,.ghost:hover{background:rgba(0,0,0,.04);color:var(--text)}
.nav button:active,.ghost:active,.seg button:active{transform:scale(0.97)}
.nav button.active,.seg button.active{background:var(--surface);color:var(--text);box-shadow:0 2px 8px rgba(0,0,0,.08);font-weight:600}

.primary{border:0;background:var(--text);color:#fff;padding:12px 18px;border-radius:12px;font-weight:600;min-height:44px;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:transform .1s,background .15s}
.primary:hover{background:#000;transform:translateY(-1px)}
.primary:active{transform:scale(0.97)}
.danger-btn{border:0;background:#fff0f2;color:var(--danger);padding:12px 18px;border-radius:12px;font-weight:600;min-height:44px;display:inline-flex;align-items:center;justify-content:center}
.danger-btn:hover{background:#ffe2e6}

.content{
  max-width:1500px;
  width:100%;
  margin:0 auto;
  padding:24px;
  padding-bottom:calc(32px + var(--sab));
  flex:1;
}

.page-head{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;margin-bottom:24px}
.page-head h1{margin:0;font-size:28px;letter-spacing:-.03em;font-weight:800}
.sub{color:var(--muted);font-size:14px;margin-top:4px}
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap}

.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.calendar-card{overflow:hidden;border-radius:var(--radius)}

.calendar-wrap {
  overflow: auto;
  max-height: 72vh;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
  position:relative;
}

.calendar-grid{
  min-width:1380px;
  display:grid;
  grid-template-columns:110px repeat(28,minmax(46px,1fr));
  position:relative;
  background:var(--surface);
}

.cell{border-right:1px solid var(--line);border-bottom:1px solid var(--line);min-height:58px;background:#fff}
.headcell{min-height:60px;padding:10px 4px;text-align:center;color:var(--muted);font-size:12px;background:#fcfaf7;position:sticky;top:0;z-index:5;backdrop-filter:blur(8px)}
.unitcell{position:sticky;left:0;z-index:6;display:flex;align-items:center;padding:0 12px;font-weight:700;background:#fcfaf7;font-size:13px;border-right:2px solid var(--line);box-shadow:2px 0 8px rgba(0,0,0,.03)}
.corner{top:0;z-index:8}
.today-col{background:#f7efdf!important}
.today-col.headcell{background:#f0e3cc!important;color:#443311;font-weight:700}

.booking{
  align-self:center;
  height:40px;
  border-radius:9px;
  margin:0 2px;
  padding:8px 10px;
  color:#fff;
  font-size:12px;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  z-index:4;
  box-shadow:0 3px 8px rgba(0,0,0,.15);
  transition:transform .15s ease, box-shadow .15s ease;
  display:flex;
  align-items:center;
  cursor:pointer;
}
.booking:active{transform:scale(0.97)}
.airbnb{background:var(--airbnb)}
.bookingcom{background:var(--booking)}
.direct{background:var(--direct)}
.blocked{background:var(--blocked)}
.cancelled{background:#b0b0b0;text-decoration:line-through}
.available-slot{transition:background .15s}
.available-slot:active{background:#f2e8d8}

.legend{display:flex;gap:18px;flex-wrap:wrap;padding:14px 20px;border-top:1px solid var(--line);font-size:13px;color:var(--muted);background:#fcfaf7}
.dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:6px}

.kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.kpi{padding:20px;background:var(--surface);border-radius:var(--radius)}
.kpi .label{font-size:12px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.05em}
.kpi .value{font-size:26px;font-weight:800;margin-top:8px;letter-spacing:-.03em;color:var(--text)}
.kpi .mini{font-size:13px;color:var(--muted);margin-top:6px}

.grid2{display:grid;grid-template-columns:1.4fr 1fr;gap:20px;margin-top:20px}
.panel{padding:22px;background:var(--surface);border-radius:var(--radius)}
.panel h3{margin:0 0 16px;font-size:18px;font-weight:700}
.list{display:flex;flex-direction:column;gap:12px}
.rowitem{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:14px 0;border-bottom:1px solid var(--line)}
.rowitem:last-child{border-bottom:0}

.pill{padding:6px 12px;border-radius:999px;font-size:12px;font-weight:700;background:#f5f0e8;color:var(--text)}
.pill.warn{background:#fff3e0;color:#c66900}
.pill.good{background:#e6f7f5;color:#007a70}
.pill.bad{background:#fff0f2;color:var(--danger)}

.barline{height:8px;background:#f0eae1;border-radius:999px;overflow:hidden}
.barline span{display:block;height:100%;background:var(--text);border-radius:999px}

.table-wrap{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.table{width:100%;border-collapse:collapse;min-width:600px}
.table th,.table td{text-align:left;padding:14px 12px;border-bottom:1px solid var(--line);font-size:13px}
.table th{color:var(--muted);font-weight:600}
.empty{padding:32px;text-align:center;color:var(--muted)}

.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
  display:flex;
  justify-content:flex-end;
  z-index:100;
  animation:fadeIn .2s ease-out;
}
.drawer{
  width:min(580px,100%);
  height:100%;
  background:var(--surface);
  padding:28px;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  box-shadow:-10px 0 40px rgba(0,0,0,.15);
  position:relative;
}
.drawer-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}
.drawer h2{margin:0;font-size:22px;font-weight:800}
.close{
  border:0;
  background:#f2ede4;
  width:38px;
  height:38px;
  border-radius:50%;
  font-size:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--text);
  transition:background .15s;
  flex-shrink:0;
}
.close:active{background:#e5ded3;transform:scale(0.95)}

.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.field{display:flex;flex-direction:column;gap:6px}
.field.full{grid-column:1/-1}
.field label{font-size:12px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.03em}
.field input,.field select,.field textarea{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px 14px;
  background:#fff;
  outline:none;
  font-size:16px; /* Prevents iOS auto-zoom on input focus */
  color:var(--text);
  transition:border-color .15s, box-shadow .15s;
  min-height:46px;
}
.field textarea{min-height:80px;resize:vertical}
.field input:focus,.field select:focus,.field textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3.5px rgba(255,56,92,.18);
}
.form-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:24px}
.notice{padding:12px 14px;border-radius:12px;background:#f9f5ee;color:var(--muted);font-size:13px;margin:14px 0;border:1px solid var(--line)}
.notice.error{background:#fff0f2;color:var(--danger);border-color:#ffd6dc}
.settings-list{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.setting-row{padding:18px;background:var(--surface);border-radius:var(--radius)}
.setting-row input{width:100%;margin-top:8px;border:1px solid var(--line);padding:10px 12px;border-radius:10px;font-size:16px;min-height:44px}
.muted{color:var(--muted)}
.edit-apt{border-radius:8px!important;transition:all .15s}
.edit-apt:hover{background:#eee9df!important;color:var(--text)}

/* Mobile Bottom Navigation Bar (iPhone 14 Pro - 16 Pro Max) */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--sab));
  padding-bottom: var(--sab);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  z-index: 90;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  width: 20%;
  height: 100%;
  transition: color 0.15s;
}
.tab-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform 0.15s;
}
.tab-item.active {
  color: var(--accent);
}
.tab-item.active svg {
  transform: scale(1.1);
}

/* Floating Action Button (FAB) on Mobile */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: calc(76px + var(--sab));
  right: 18px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(255, 56, 92, 0.4);
  z-index: 89;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 400;
  transition: transform 0.15s;
}
.mobile-fab:active {
  transform: scale(0.92);
}

/* Network IP & Database Box styling */
.access-box {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  padding: 22px;
  border-radius: 16px;
  margin-top: 20px;
}
.access-box h3 { margin: 0 0 10px; color: #fff; font-size: 18px; display:flex; align-items:center; gap:8px }
.access-box code {
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 15px;
  color: #38bdf8;
  font-family: monospace;
}
.access-steps { margin-top: 14px; padding-left: 20px; line-height: 1.6; color: #cbd5e1; font-size: 14px }

/* Supabase DB Connection Box */
.db-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: #fff;
  padding: 24px;
  border-radius: 18px;
  margin-top: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.db-card h3 { margin: 0 0 8px; color: #fff; font-size: 20px; display:flex; align-items:center; justify-content:space-between }
.db-status { display:inline-flex; align-items:center; gap:8px; padding:6px 14px; border-radius:999px; font-size:12px; font-weight:700 }
.db-status.connected { background:rgba(16,185,129,0.2); color:#34d399; border:1px solid rgba(52,211,153,0.3) }
.db-status.disconnected { background:rgba(239,68,68,0.2); color:#fca5a5; border:1px solid rgba(252,165,165,0.3) }
.sql-box {
  background: #090d16;
  color: #a7f3d0;
  padding: 14px;
  border-radius: 12px;
  font-family: monospace;
  font-size: 12px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.1);
  margin-top: 10px;
}

@keyframes fadeIn{from{opacity:0}to{opacity:1}}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:translateY(0)}}

/* Responsive Adjustments for Mobile & iPhone 14 Pro - 16 Pro Max */
@media(max-width:900px){
  .content{padding:16px;padding-bottom:calc(84px + var(--sab))}
  .topbar{padding:calc(10px + var(--sat)) 16px 12px 16px}
  .nav{display:none} /* Navigation moves to bottom tab bar on mobile */
  .mobile-tab-bar{display:flex}
  .mobile-fab{display:flex}
  .kpis{grid-template-columns:1fr 1fr}
  .grid2{grid-template-columns:1fr}
  .settings-list{grid-template-columns:1fr 1fr}
  .page-head{align-items:flex-start;flex-direction:column;gap:12px;margin-bottom:18px}
  .page-head h1{font-size:24px}
  .page-head .toolbar{width:100%;justify-content:space-between}
  .form-grid{grid-template-columns:1fr}
  .field.full{grid-column:auto}
}

@media(max-width:640px){
  .kpis{grid-template-columns:1fr}
  .settings-list{grid-template-columns:1fr}
  .content{padding:12px;padding-bottom:calc(84px + var(--sab))}
  
  /* Native iOS Bottom Sheet Drawer */
  .modal-backdrop{align-items:flex-end}
  .drawer{
    width:100%;
    max-height:88vh;
    max-height:88dvh;
    height:auto;
    border-radius:24px 24px 0 0;
    padding:20px 20px calc(24px + var(--sab)) 20px;
    box-shadow:0 -10px 40px rgba(0,0,0,.25);
    animation:slideUp .25s cubic-bezier(0.1, 0.9, 0.2, 1.0);
  }
  .drawer::before {
    content:'';
    display:block;
    width:40px;
    height:5px;
    background:#e2ddd4;
    border-radius:3px;
    margin:0 auto 16px auto;
  }
  .drawer-head{margin-bottom:16px}
  .drawer h2{font-size:20px}
  
  .booking{font-size:11px;padding:6px 8px;height:40px}
  .headcell{font-size:11px;padding:8px 2px}
  .unitcell{font-size:12px;padding:0 8px;width:95px}
  .calendar-grid{grid-template-columns:95px repeat(28,minmax(42px,1fr));min-width:1270px}
  
  button,.primary,.danger-btn,.ghost{min-height:46px}
  .access-box{padding:16px}
}


