:root{
  --bg:#f5f6f8;
  --card:#ffffff;
  --muted:#6b7280;
  --accent:#0f63ff;
  --danger:#dc3545;
  --radius:10px;
  --gap:12px;
  --max-width:1200px;
  font-family: Inter, 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:#111827;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  padding:18px;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  min-height:100vh;
}
.header{
  width:100%;
  max-width:var(--max-width);
  display:flex;
  gap:12px;
  align-items:flex-start;
  flex-wrap:wrap;
  margin-bottom:12px;
}
.header-summary{
  width:100%;
  font-size:13px;
  color:var(--muted);
  margin:4px 0 0 0;
}
.branch-count{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
}
.logo{
  width:36px;
  height:36px;
  border-radius:8px;
  flex:0 0 auto;
  object-fit:cover;
  margin-right:8px;
}
.header h1{
  font-size:18px;
  margin:0;
  flex:0 0 auto;
}
.header input{
  flex:1 1 auto;
  padding:10px 12px;
  border-radius:8px;
  border:1px solid #e6e9ee;
  background:white;
  font-size:14px;
}

/* grid: 6 columns */
.grid{
  width:100%;
  max-width:var(--max-width);
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap:var(--gap);
}

/* Branch card */
.card{
  background:var(--card);
  border-radius:var(--radius);
  padding:10px;
  box-shadow:0 1px 2px rgba(16,24,40,0.04);
  display:flex;
  flex-direction:column;
  min-height:110px;
  overflow:hidden;
}
.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px;
}
.branch-title{
  font-weight:600;
  font-size:13px;
  white-space:normal;
  word-break:break-word;
  overflow:visible;
}
.card-actions{
  display:flex;
  gap:6px;
  align-items:center;
}
.btn-icon{
  width:32px;
  height:32px;
  border-radius:8px;
  border:1px solid rgba(0,0,0,0.08);
  background:var(--danger);
  color:white;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:12px;
}
/* ensure the inline SVG icon becomes visible on the red background */
.btn-icon svg { width:16px; height:16px; }
.btn-icon svg path,
.btn-icon svg line,
.btn-icon svg rect { stroke: #fff !important; fill: none; }
.btn{
  padding:8px 10px;
  border-radius:8px;
  border:none;
  cursor:pointer;
  font-weight:600;
  font-size:12px;
}
.btn.primary{background:var(--accent);color:white}
.btn.secondary{background:#f3f4f6;border:1px solid #e6e9ee}
.btn.danger{background:var(--danger);color:white;font-size:12px}

/* employees sub-cards */
.employees{
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow:auto;
}
.emp{
  display:flex;
  flex-direction:column; /* stack meta + actions */
  align-items:flex-start;
  gap:8px;
  padding:10px;
  border-radius:8px;
  background:#f8fafc;
  font-size:13px;
  box-shadow: inset 0 -1px 0 rgba(15,23,42,0.03);
}
.emp .meta{display:flex;flex-direction:column;min-width:0}
.emp .name{
  font-weight:600;
  word-break:break-word; /* allow wrapping instead of truncation */
  white-space:normal;
  overflow:visible;
}
.emp .sub{
  font-size:12px;
  color:var(--muted);
  white-space:normal;
  overflow:visible;
}

/* action row placed under the meta block */
.emp-actions{
  display:flex;
  gap:8px;
  align-items:center;
  margin-top:4px;
}

/* edit button: blue circular icon */
.btn-edit{
  background:var(--accent);
  border-color:rgba(15,99,255,0.15);
}
/* ensure svg colors show correctly on colored backgrounds */
.btn-icon svg { width:16px; height:16px; }
.btn-icon svg path,
.btn-icon svg line,
.btn-icon svg rect { stroke: #fff !important; fill: #fff !important; }

/* drawer */
.drawer{
  position:fixed;
  right:12px;
  top:50%;
  transform:translateY(-50%) translateX(110%);
  width:320px;
  background:var(--card);
  border-radius:12px;
  box-shadow:0 10px 30px rgba(2,6,23,0.2);
  padding:14px;
  transition:transform .22s ease;
  z-index:40;
}
.drawer[aria-hidden="false"]{transform:translateY(-50%) translateX(0)}
.form label{display:block;font-size:13px;color:var(--muted);margin-bottom:8px}
.form input{width:100%;padding:8px 10px;border-radius:8px;border:1px solid #e6e9ee;margin-top:6px}
.form-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}

/* modal */
.modal{
  position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(2,6,23,0.35);opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:50;
}
.modal[aria-hidden="false"]{opacity:1;pointer-events:auto}
.modal-content{background:var(--card);padding:16px;border-radius:12px;max-width:92%;width:380px;text-align:left}
.modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}

/* move button styling (blue double-arrow) */
.btn-move{
  background:var(--accent);
  border-radius:8px;
  width:32px;
  height:32px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(15,99,255,0.12);
  color:#fff;
  cursor:pointer;
}

/* responsive: keep the 6-column layout but adapt for small screens by scaling card content */
@media (max-width:900px){
  .grid{grid-template-columns:repeat(4,1fr)}
  .drawer{width:280px}
}
@media (max-width:600px){
  .grid{grid-template-columns:repeat(3,1fr)}
  body{padding:12px}
}
@media (max-width:420px){
  .grid{grid-template-columns:repeat(2,1fr)}
  .drawer{display:none}
  header h1{font-size:16px}
}

/* loading overlay */
.loading{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(2,6,23,0.18);
  z-index:60;
  opacity:0;
  pointer-events:none;
  transition:opacity .15s ease;
}
.loading[aria-hidden="false"]{
  opacity:1;
  pointer-events:auto;
}
.loading-inner{
  display:flex;
  gap:10px;
  align-items:center;
  background:var(--card);
  padding:12px 16px;
  border-radius:12px;
  box-shadow:0 8px 24px rgba(2,6,23,0.12);
}
.spinner{width:28px;height:28px}
.spinner circle{stroke:var(--accent);stroke-linecap:round;stroke-dasharray:90;stroke-dashoffset:60;animation:spin 1s linear infinite}
.loading-text{font-size:13px;color:var(--muted)}
@keyframes spin{100%{transform:rotate(360deg)}}