:root {
  --bg: #f8fafc;
  --card: #fff;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --danger: #dc2626;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --header-h: 56px;
}

* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body { margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
.admin-body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.admin-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: 1rem;
}
.logo { font-weight: 700; color: var(--text); }
.logo:hover { text-decoration: none; }
.admin-nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.admin-nav a {
  padding: .4rem .75rem;
  border-radius: 8px;
  color: var(--muted);
}
.admin-nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--primary); color: #fff; }
.admin-nav .nav-logout { margin-left: auto; color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; }
.admin-nav .nav-logout svg { flex-shrink: 0; }

.login-page { align-items: center; justify-content: center; }
.login-box { width: 100%; max-width: 360px; padding: 2rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-box h1 { margin: 0 0 .25rem; text-align: center; }
.login-sub { color: var(--muted); text-align: center; margin: 0 0 1.5rem; }

.admin-main { flex: 1; padding: 1rem; max-width: 1400px; margin: 0 auto; width: 100%; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* Page head */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; font-size: 1.25rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font: inherit; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: .35rem .6rem; font-size: .875rem; }

/* Card & list */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-item:last-child { border-bottom: 0; }
.list-avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; flex-shrink: 0; }
.list-title { flex: 1; min-width: 0; }
.list-meta { color: var(--muted); font-size: .9rem; }
.list-actions { display: flex; gap: .5rem; }
.empty-hint { color: var(--muted); margin: 0; padding: 1rem 0; }

.ios-install-hint {
  display: flex; align-items: center; gap: .5rem; justify-content: space-between;
  padding: .6rem .85rem; margin-bottom: 1rem; font-size: .85rem;
  background: #ede9fe; color: #5b21b6; border-radius: 8px; border: 1px solid #c4b5fd;
}
.ios-install-hint[hidden] { display: none; }
.ios-hint-close { background: none; border: none; font-size: 1.25rem; line-height: 1; color: inherit; cursor: pointer; padding: 0 .2rem; opacity: .8; }
.ios-hint-close:hover { opacity: 1; }

/* Form */
.form { max-width: 400px; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .35rem; font-weight: 500; }
.form-group input, .form-group select { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.form-group small { display: block; margin-top: .25rem; color: var(--muted); font-size: .8rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; }
.form-actions { margin-top: 1.25rem; }

/* Schedule */
.schedule-wrap { position: relative; }
.schedule-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.nav-arrow {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.5rem;
  color: var(--text);
  text-decoration: none;
}
.nav-arrow:hover { background: var(--bg); text-decoration: none; }
.schedule-date { font-weight: 600; }
.date-text { font-size: 1rem; }

.schedule-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.schedule-grid {
  display: flex;
  min-width: min-content;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}
.schedule-times {
  flex-shrink: 0;
  width: 56px;
  border-left: 1px solid var(--border);
}
.time-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.time-cell:last-child { border-bottom: 0; }

.schedule-column {
  flex: 0 0 140px;
  min-width: 120px;
  border-right: 1px solid var(--border);
}
.schedule-column:last-child { border-right: 0; }
.staff-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.staff-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .25rem;
}
.staff-name { font-size: .8rem; font-weight: 500; text-align: center; }
.staff-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.staff-slots { position: relative; }
.slot-cell {
  border-bottom: 1px solid var(--border);
}
.slot-cell:last-child { border-bottom: 0; }

.app-block {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 6px;
  padding: 4px 6px;
  color: #fff;
  font-size: .7rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.app-block:hover { opacity: .95; text-decoration: none; color: #fff; }
.app-client { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-time { opacity: .9; }
.app-note { font-size: .65rem; opacity: .85; margin-top: 2px; }

.fab {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 300;
  box-shadow: 0 4px 12px rgba(124,58,237,.4);
  z-index: 50;
  text-decoration: none;
}
.fab:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }

@media (max-width: 640px) {
  .admin-nav a { padding: .35rem .5rem; font-size: .9rem; }
  .schedule-column { flex: 0 0 110px; min-width: 100px; }
  .staff-name { font-size: .75rem; }
  .app-block { font-size: .65rem; padding: 2px 4px; }
}
