:root{
  --bg: #f6f7f9;
  --card: #ffffff;
  --muted: #6b7280;
  --accent: #0b7cff;
  --danger: #e11d48;
  --gap: 4px;
  --radius: 6px;
  --pad: 6px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:#0f172a;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  display:flex;
  flex-direction:column;
  min-height:100vh;
  padding:8px;
}

/* Header */
.header{
  display:flex;
  gap:6px;
  align-items:center;
  justify-content:space-between;
  margin-bottom:4px;
}
.logo-wrap{
  display:flex;
  gap:6px;
  align-items:center;
}
.logo{
  width:28px;
  height:28px;
  object-fit:cover;
  border-radius:6px;
  flex:0 0 28px;
}
.header h1{
  font-size:13px;
  margin:0;
}
.search-wrap{
  flex:1;
  margin-left:8px;
}
.search-wrap input{
  width:100%;
  padding:4px 6px;
  border-radius:6px;
  border:1px solid #e6e9ee;
  background:white;
  font-size:12px;
}

/* Controls */
.controls{
  display:flex;
  gap:6px;
  margin-bottom:6px;
}
.btn{
  flex:1;
  padding:6px;
  border-radius:6px;
  border:1px solid #d1d5db;
  background:var(--card);
  font-size:12px;
}
.btn.primary{
  background:linear-gradient(180deg,var(--accent),#066fe0);
  color:white;
  border:none;
  box-shadow:0 2px 6px rgba(11,124,255,0.12);
}

/* Grid */
.grid{
  display:grid;
  gap:6px;
  grid-template-columns:repeat(6,1fr);
  align-items:stretch;
  width:100%;
  margin-bottom:6px;
}

/* Card */
.card{
  background:var(--card);
  border-radius:var(--radius);
  padding:6px;
  box-shadow:0 1px 2px rgba(12,16,25,0.04);
  display:flex;
  flex-direction:column;
  gap:4px;
  min-height:84px;
  height:100%;
}
.card h3{
  margin:0;
  font-size:12px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.hours-grid{
  display:flex;
  flex-direction:column;
  gap:2px;
  font-size:11px;
  width:100%;
  flex:1 1 auto;
  min-height:0;
}
.hours-cell{
  background:#f8fafc;
  padding:4px;
  border-radius:6px;
  text-align:left;
  color:var(--muted);
  display:flex;
  flex-direction:column;
  gap:2px;
}
.day-label{
  font-weight:700;
  font-size:11px;
  color:var(--muted);
}
.day-time{
  font-size:11px;
  color:var(--accent);
}
.card-footer{
  display:flex;
  gap:6px;
  justify-content:center;
  align-items:flex-start;
  /* stacked layout on cards */
  flex-direction:column;
  align-items:stretch;
  margin-top:auto;
}

/* ensure the inner actions container fills card width and stacks buttons */
.card-footer > div {
  width:100%;
  display:flex;
  flex-direction:column;
  gap:4px;
}

/* make card buttons full width */
.card-footer .btn{
  width:100%;
  padding:6px;
  border-radius:6px;
  box-sizing:border-box;
}

/* Modal */
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  background:rgba(2,6,23,0.35);
  padding:8px;
}
.modal.hidden{display:none}
.modal-panel{
  width:100%;
  max-width:720px;
  background:var(--card);
  border-radius:10px;
  padding:8px;
  box-shadow:0 12px 30px rgba(2,6,23,0.25);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* ensure the day list within the modal can also scroll if many rows */
.day-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.modal-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:6px;
}
.icon-btn{
  background:transparent;
  border:none;
  font-size:18px;
  line-height:1;
}

/* Hours form */
.hours-form{display:flex;flex-direction:column;gap:6px}
.form-branch-name{font-weight:600;margin-bottom:4px;font-size:13px}
.day-row{
  display:flex;
  gap:6px;
  align-items:center;
  border-radius:8px;
  padding:4px;
  background:#fbfdff;
}
.day-name{width:56px;font-size:11px;color:var(--muted)}
.toggle-closed{display:flex;gap:6px;align-items:center;margin-left:auto}
.time-chips{display:flex;gap:6px;flex-wrap:wrap;flex:1;min-width:0}
.time-chip{
  display:flex;
  gap:6px;
  align-items:center;
  background:white;
  border:1px solid #e6eef9;
  padding:4px 6px;
  border-radius:6px;
  font-size:11px;
  width:100%;
  box-sizing:border-box;
}
.time-chip > div { /* inputsWrap */
  display:flex;
  gap:6px;
  flex:1;
  min-width:0;
}
.time-chip input{
  border:none;
  background:transparent;
  width:100%;
  max-width:100%;
  font-size:11px;
  padding:2px 3px;
}
.small-btn{
  background:#f3f4f6;border:none;padding:5px;border-radius:6px;font-size:11px
}

/* Modal actions */
.modal-actions{display:flex;gap:6px;justify-content:flex-end;margin-top:6px}

/* Loading overlay + toast */
.loading-overlay{
  position:fixed;
  inset:0;
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,0.7);
  z-index:80;
}
.loading-overlay.hidden{display:none}
.loader{
  width:36px;
  height:36px;
  border-radius:50%;
  border:4px solid rgba(11,124,255,0.12);
  border-top-color:var(--accent);
  animation:spin 1s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.loading-text{font-size:13px;color:var(--muted)}

/* Toasts */
.toasts{
  position:fixed;
  bottom:12px;
  left:12px;
  display:flex;
  flex-direction:column;
  gap:8px;
  z-index:90;
}
.toast{
  background:rgba(0,0,0,0.85);
  color:white;
  padding:8px 12px;
  border-radius:8px;
  font-size:13px;
  box-shadow:0 6px 18px rgba(2,6,23,0.2);
  max-width:calc(100vw - 48px);
}

/* Responsive fits mobile single-screen */
@media (max-width:420px){
  .grid{grid-template-columns:repeat(1,1fr)}
  body{padding:8px}
  .header{flex-direction:column;align-items:stretch;gap:6px}
}