:root{
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e4e7ef;
  --text: #1c2233;
  --text-dim: #6b7286;
  --text-faint: #9aa0b4;
  --primary: #4f5eff;
  --primary-dark: #3c48d6;
  --primary-light: #eef0ff;
  --danger: #e5484d;
  --danger-light: #fdecec;
  --success: #17b26a;

  --early: #ffb547;
  --early-bg: #fff4e0;
  --late: #4f8bff;
  --late-bg: #e8f0ff;
  --night: #8452e8;
  --night-bg: #f1e9fe;
  --off: #6b7286;
  --off-bg: #eef0f4;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20,24,40,0.06);
  --shadow-md: 0 6px 20px rgba(30,35,60,0.10);
  --shadow-lg: 0 20px 45px rgba(20,24,50,0.18);
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Topbar ---------- */
.topbar{
  display:flex;
  align-items:center;
  gap: 24px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 30;
  flex-wrap: wrap;
}

.brand{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:700;
  font-size:18px;
  letter-spacing:-0.02em;
  color: var(--text);
  margin-right: 8px;
}
.brand-icon{
  display:flex;
  align-items:center;
  justify-content:center;
  width:32px;height:32px;
  border-radius:9px;
  background: linear-gradient(135deg, var(--primary), #7b6bff);
  color:white;
  box-shadow: 0 4px 10px rgba(79,94,255,0.35);
}

.week-nav{
  display:flex;
  align-items:center;
  gap:10px;
}
.week-label{
  font-weight:600;
  font-size:14px;
  min-width:190px;
  text-align:center;
  color: var(--text);
}

.top-actions{
  display:flex;
  align-items:center;
  gap:10px;
  margin-left:auto;
}

.stat-pill{
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size:13px;
  font-weight:600;
  padding:7px 13px;
  border-radius: 100px;
}
.stat-pill.warn{
  background: var(--danger-light);
  color: var(--danger);
}

.icon-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  width:32px;height:32px;
  border-radius:8px;
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor:pointer;
  transition: all .15s ease;
}
.icon-btn:hover{
  background: var(--surface-2);
  color: var(--text);
  border-color: #d5d9e5;
}

.btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:13.5px;
  font-weight:600;
  padding:8px 14px;
  border-radius:9px;
  border:1px solid transparent;
  cursor:pointer;
  transition: all .15s ease;
  font-family: inherit;
}
.btn-primary{
  background: var(--primary);
  color:white;
  box-shadow: 0 3px 8px rgba(79,94,255,0.32);
}
.btn-primary:hover{ background: var(--primary-dark); }
.btn-ghost{
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover{ background: var(--surface-2); color:var(--text); }
.btn-danger{
  background: var(--danger-light);
  color: var(--danger);
}
.btn-danger:hover{ background:#fadcdc; }

/* ---------- Main layout ---------- */
.main-layout{
  display:flex;
  flex:1;
  min-height:0;
}

/* ---------- Sidebar ---------- */
.sidebar{
  width: 280px;
  min-width:280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display:flex;
  flex-direction:column;
  padding: 18px 16px;
  overflow-y:auto;
}
.sidebar-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  margin-bottom:12px;
}
.sidebar-head h2{
  font-size:15px;
  margin:0;
}
.sidebar-head .hint{
  font-size:11px;
  color: var(--text-faint);
}

.search-box{
  display:flex;
  align-items:center;
  gap:8px;
  background: var(--surface-2);
  border:1px solid var(--border);
  border-radius:9px;
  padding:8px 10px;
  margin-bottom:10px;
  color: var(--text-faint);
}
.search-box input{
  border:none;
  background:transparent;
  outline:none;
  font-size:13px;
  width:100%;
  color: var(--text);
  font-family: inherit;
}

.role-filter{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-bottom:14px;
}
.role-chip{
  font-size:11.5px;
  padding:4px 10px;
  border-radius:100px;
  background: var(--surface-2);
  border:1px solid var(--border);
  color: var(--text-dim);
  cursor:pointer;
  user-select:none;
  transition: all .15s ease;
}
.role-chip.active{
  background: var(--primary);
  border-color: var(--primary);
  color:white;
}

.employee-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  flex:1;
}

.emp-card{
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: grab;
  transition: box-shadow .15s ease, transform .1s ease, border-color .15s ease;
}
.emp-card:hover{
  box-shadow: var(--shadow-sm);
  border-color:#d5d9e5;
}
.emp-card:active{ cursor: grabbing; }
.emp-card.dragging{ opacity: .4; }

.avatar{
  width:34px;height:34px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  color:white;
  font-weight:700;
  font-size:12.5px;
  flex-shrink:0;
}

.emp-meta{
  min-width:0;
}
.emp-name{
  font-size:13.5px;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.emp-role{
  font-size:11.5px;
  color: var(--text-faint);
}

.emp-empty{
  text-align:center;
  color: var(--text-faint);
  font-size:13px;
  padding: 24px 8px;
}

.legend{
  margin-top:16px;
  padding-top:14px;
  border-top:1px solid var(--border);
}
.legend-title{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.04em;
  color: var(--text-faint);
  margin-bottom:8px;
  font-weight:700;
}
.legend-item{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12.5px;
  color: var(--text-dim);
  padding:3px 0;
}
.dot{
  width:9px;height:9px;
  border-radius:50%;
  flex-shrink:0;
}
.dot-early{ background: var(--early); }
.dot-late{ background: var(--late); }
.dot-night{ background: var(--night); }
.dot-off{ background: var(--off); }

/* ---------- Calendar ---------- */
.calendar-wrap{
  flex:1;
  overflow:auto;
  padding: 18px;
}
.calendar{
  display:grid;
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  gap: 12px;
  min-width: 1260px;
  height:100%;
}

.day-col{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display:flex;
  flex-direction:column;
  min-height: 100%;
  transition: background .15s ease, border-color .15s ease;
}
.day-col.today{
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.day-col.dragover{
  background: var(--primary-light);
  border-color: var(--primary);
  border-style: dashed;
}

.day-head{
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.day-name{
  font-size:11.5px;
  text-transform:uppercase;
  letter-spacing:.05em;
  color: var(--text-faint);
  font-weight:700;
}
.day-date{
  font-size: 18px;
  font-weight:700;
  margin-top:2px;
}
.day-col.today .day-date{ color: var(--primary); }

.day-body{
  flex:1;
  padding: 10px;
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow-y:auto;
}

.day-drop-hint{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  color: var(--text-faint);
  font-size:12px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  min-height:70px;
  padding: 10px;
  text-align:center;
}

.shift-card{
  position:relative;
  border-radius: 10px;
  padding: 9px 10px 9px 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  animation: pop-in .18s ease;
}
.shift-card:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.shift-card::before{
  content:"";
  position:absolute;
  left:0; top:8px; bottom:8px;
  width:4px;
  border-radius:4px;
}
.shift-card.type-early{ background: var(--early-bg); }
.shift-card.type-early::before{ background: var(--early); }
.shift-card.type-late{ background: var(--late-bg); }
.shift-card.type-late::before{ background: var(--late); }
.shift-card.type-night{ background: var(--night-bg); }
.shift-card.type-night::before{ background: var(--night); }
.shift-card.type-off{ background: var(--off-bg); }
.shift-card.type-off::before{ background: var(--off); }

.shift-top{
  display:flex;
  align-items:center;
  gap:8px;
}
.shift-avatar{
  width:24px;height:24px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  color:white;
  font-size:10.5px;
  font-weight:700;
  flex-shrink:0;
}
.shift-name{
  font-size:13px;
  font-weight:700;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.shift-time{
  font-size:11.5px;
  color: var(--text-dim);
  margin-top:4px;
  font-variant-numeric: tabular-nums;
}
.shift-position{
  font-size:10.5px;
  color: var(--text-faint);
  margin-top:2px;
  text-transform:uppercase;
  letter-spacing:.03em;
}

@keyframes pop-in{
  from{ opacity:0; transform: scale(.92); }
  to{ opacity:1; transform: scale(1); }
}

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed;
  inset:0;
  background: rgba(20,24,40,0.42);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:100;
  opacity:0;
  pointer-events:none;
  transition: opacity .15s ease;
  backdrop-filter: blur(2px);
}
.modal-overlay.open{
  opacity:1;
  pointer-events:auto;
}
.modal{
  width: 440px;
  max-width: 92vw;
  max-height: 88vh;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display:flex;
  flex-direction:column;
  transform: translateY(10px) scale(.98);
  transition: transform .18s ease;
  overflow:hidden;
}
.modal-overlay.open .modal{
  transform: translateY(0) scale(1);
}
.modal-sm{ width: 380px; }

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 16px 20px;
  border-bottom:1px solid var(--border);
}
.modal-head h3{
  margin:0;
  font-size:16px;
}

.modal-body{
  padding: 18px 20px;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.modal-employee{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  background: var(--surface-2);
  border-radius:10px;
  font-weight:600;
  font-size:13.5px;
}

.form-row{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.form-row.two-col{
  flex-direction:row;
  gap:12px;
}
.form-row.two-col > div{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.form-row label{
  font-size:12px;
  font-weight:700;
  color: var(--text-dim);
  text-transform:uppercase;
  letter-spacing:.03em;
}
.form-row input,
.form-row select,
.form-row textarea{
  border:1px solid var(--border);
  border-radius:9px;
  padding:9px 11px;
  font-size:13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline:none;
  transition: border-color .15s ease;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus{
  border-color: var(--primary);
}
.form-row textarea{ resize: vertical; }

.shift-type-picker{
  display:flex;
  gap:8px;
}
.type-chip{
  flex:1;
  padding: 9px 6px;
  border-radius:9px;
  border:1.5px solid var(--border);
  background: var(--surface);
  font-size:12.5px;
  font-weight:700;
  cursor:pointer;
  color: var(--text-dim);
  transition: all .12s ease;
  font-family: inherit;
}
.type-chip.type-early.active{ background: var(--early-bg); border-color: var(--early); color:#8a5a10; }
.type-chip.type-late.active{ background: var(--late-bg); border-color: var(--late); color:#1c4fbd; }
.type-chip.type-night.active{ background: var(--night-bg); border-color: var(--night); color:#5b2fb0; }
.type-chip.type-off.active{ background: var(--off-bg); border-color: var(--off); color:#3d4152; }

.color-picker{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.color-swatch{
  width:26px;height:26px;
  border-radius:50%;
  cursor:pointer;
  border:2px solid transparent;
  transition: transform .1s ease;
}
.color-swatch:hover{ transform: scale(1.1); }
.color-swatch.selected{
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text);
}

.modal-foot{
  display:flex;
  align-items:center;
  padding: 14px 20px;
  border-top:1px solid var(--border);
  gap:10px;
}
.spacer{ flex:1; }

/* ---------- Toast ---------- */
.toast{
  position:fixed;
  bottom: 22px;
  left:50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c2233;
  color:white;
  padding: 11px 20px;
  border-radius:10px;
  font-size:13.5px;
  font-weight:600;
  box-shadow: var(--shadow-lg);
  opacity:0;
  pointer-events:none;
  transition: all .25s ease;
  z-index: 200;
}
.toast.show{
  opacity:1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background: #d5d9e5; border-radius:8px; }
::-webkit-scrollbar-thumb:hover{ background: #b9bfd0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px){
  .sidebar{ width: 230px; min-width:230px; }
  .calendar{ min-width: 1000px; }
}
