:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #e8eaee;
  --text: #1f2937;
  --muted: #6b7280;
  --mint: #7ee2b8;
  --mint-2: #5ad49a;
  --mint-soft: #e8faf1;
  --blue-soft: #e8f3ff;
  --blue: #5b9dff;
  --pink-soft: #ffe8f0;
  --pink: #f472b6;
  --yellow-soft: #fff6d9;
  --ink: #111827;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  --shadow-soft: 0 10px 30px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Manrope, "Plus Jakarta Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(126, 226, 184, .35), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(91, 157, 255, .22), transparent 42%),
    var(--bg);
}
.auth-card {
  width: min(420px, 92vw);
  padding: 36px 34px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 34px;
  color: var(--ink);
  font-weight: 800;
}
.auth-sub, .hint { color: var(--muted); margin: 0 0 18px; }
.auth-card label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.auth-card input,
.view input,
.view select,
.view textarea,
.modal input,
.modal select,
.modal textarea,
.toolbar input,
.toolbar select,
.search-box input {
  width: 100%;
  background: #f8f9fb;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  transition: .15s ease;
}
.auth-card input:focus,
.view input:focus,
.view select:focus,
.view textarea:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus,
.search-box input:focus {
  outline: none;
  background: #fff;
  border-color: #c7f0db;
  box-shadow: 0 0 0 4px rgba(126, 226, 184, .25);
}
.form-error { color: var(--bad); min-height: 18px; font-size: 13px; }
.btn-gold, .btn, .btn-ghost, .btn-danger, .btn-dark {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: .15s ease;
}
.btn-gold, .btn {
  width: 100%;
  margin-top: 10px;
  background: var(--mint);
  color: #065f46;
}
.btn-gold:hover, .btn:hover { background: var(--mint-2); }
.btn.w-auto, .btn-ghost, .btn-danger, .btn-dark { width: auto; }
.btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-ghost:hover { background: #f8f9fb; }
.btn-dark {
  background: #1f2937;
  color: #fff;
}
.btn-danger { background: #fee2e2; color: #b91c1c; }
.hint { font-size: 13px; margin-top: 16px; }

/* Shell */
.app-body {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.sidebar {
  background: #f7f8fa;
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin: 4px 8px 18px;
}
.brand-logo {
  height: 48px;
  width: auto;
  border-radius: 12px;
  display: block;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #9af0c8, #5ad49a);
  color: #065f46;
  font-weight: 800;
  box-shadow: 0 8px 16px rgba(90, 212, 154, .28);
}
.brand strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.nav-section {
  margin: 12px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9ca3af;
}
#side-nav a,
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  text-decoration: none;
  color: #4b5563;
  background: transparent;
  border: 0;
  padding: 10px 12px;
  border-radius: 14px;
  margin-bottom: 3px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
#side-nav a:hover,
.nav-group-toggle:hover {
  background: #eef0f3;
  color: var(--ink);
}
#side-nav a.active,
.nav-group-toggle.active {
  background: var(--mint);
  color: #065f46;
  box-shadow: 0 8px 18px rgba(90, 212, 154, .22);
}
.nav-ico {
  width: 18px;
  text-align: center;
  opacity: .85;
  font-size: 13px;
}
.nav-children { padding-left: 12px; }
.nav-children a { font-size: 13px; font-weight: 600; }
.logout {
  margin-top: auto;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 14px;
  padding: 11px;
  cursor: pointer;
  font-weight: 700;
}
.logout:hover { color: var(--ink); }

.main {
  padding: 18px 24px 40px;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar-left h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.02em;
}
.topbar-logo {
  display: block;
  height: 44px;
  width: auto;
  border-radius: 12px;
  margin-top: 2px;
}
.topbar-logo-dash {
  margin-top: 0;
}
.crumb {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.search-box {
  position: relative;
  min-width: 220px;
}
.search-box input {
  padding-right: 54px;
  background: #fff;
}
.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 3px 7px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  box-shadow: var(--shadow);
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #c7ebff, #9ad0ff);
  color: #1e40af;
  font-weight: 800;
  font-size: 13px;
}
.user-chip span { font-weight: 700; font-size: 13px; }
.user-chip small { display: block; color: var(--muted); font-size: 11px; }

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid rgba(232, 234, 238, .9);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card h4, .card-title {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}
.card .label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.card .num {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.03em;
  line-height: 1.1;
}
.kpi {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 104px;
}
.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.delta {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}
.delta.up { background: var(--mint-soft); color: #047857; }
.delta.down { background: var(--pink-soft); color: #be185d; }
.delta.flat { background: #eef2ff; color: #4338ca; }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input, .toolbar select {
  max-width: 240px;
  width: auto;
  min-width: 150px;
  background: #fff;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafbfc; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-ok { background: var(--mint-soft); color: #047857; }
.badge-warn { background: var(--yellow-soft); color: #b45309; }
.badge-off { background: #f3f4f6; color: #6b7280; }
.badge-info { background: var(--blue-soft); color: #1d4ed8; }

.list-row {
  display: grid;
  grid-template-columns: 40px 1.2fr 1fr .9fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  background: #eef2ff;
  color: #4338ca;
}
.list-title { font-weight: 750; color: var(--ink); }
.list-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  margin-top: 8px;
  padding: 12px;
  background: #f8f9fb;
  border-radius: 16px;
}
.chart-bar {
  flex: 1;
  border-radius: 10px 10px 4px 4px;
  background: #e5e7eb;
  min-height: 8px;
  transition: .2s ease;
}
.chart-bar.on {
  background: var(--mint-2);
  box-shadow: 0 8px 16px rgba(90, 212, 154, .28);
}
.chart-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.chart-meta .mini {
  background: #f8f9fb;
  border-radius: 14px;
  padding: 10px 12px;
}
.chart-meta .mini span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.chart-meta .mini strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  color: var(--ink);
}

.pager { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pager .pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0; }
.pager .page-link, .pager a, .pager span {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  background: #fff;
  font-weight: 700;
}
.pager .active .page-link, .pager .active span {
  background: var(--mint);
  color: #065f46;
  border-color: transparent;
}

.cal { overflow: auto; }
.cal table { min-width: 720px; }
.cal td { vertical-align: top; min-width: 140px; }
.slot {
  display: block;
  padding: 10px;
  border-radius: 14px;
  background: #f8f9fb;
  border: 1px dashed #d7dbe3;
  color: var(--muted);
  cursor: pointer;
  min-height: 72px;
}
.slot:hover { border-color: var(--mint-2); color: #065f46; background: var(--mint-soft); }
.slot.filled {
  border-style: solid;
  border-color: #d7f5e6;
  color: var(--text);
  background: linear-gradient(180deg, #f2fcf7, #ffffff);
}
.slot small { display: block; color: var(--muted); margin-top: 4px; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, .35);
  display: grid; place-items: start center;
  padding: 28px 12px;
  overflow: auto;
  z-index: 20;
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden], .toast[hidden] { display: none !important; }
.modal {
  width: min(920px, 94vw);
  margin: auto 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 20px 24px;
  box-shadow: var(--shadow-soft);
  overflow: visible;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 800; color: var(--ink); }
.icon-btn { background: #f3f4f6; border: 0; width: 36px; height: 36px; border-radius: 12px; color: var(--muted); font-size: 22px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.check-wrap label {
  display: flex; gap: 6px; align-items: center;
  background: #f8f9fb;
  border: 1px solid var(--line);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.check-wrap input { width: auto; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  z-index: 30;
  box-shadow: var(--shadow-soft);
}

.res-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.res-tabs a {
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  font-weight: 700;
  font-size: 13px;
}
.res-tabs a.active {
  color: #065f46;
  background: var(--mint);
  border-color: transparent;
}

.month-cal { overflow: auto; }
.month-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  table-layout: fixed;
}
.month-table th, .month-table td {
  border: 1px solid var(--line);
  vertical-align: top;
  padding: 8px;
  width: 14.28%;
  background: #fff;
}
.month-table th {
  background: #f8f9fb;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  height: auto;
}
.month-table td {
  height: 128px;
}
.month-table td .day-cell {
  min-height: 112px;
}
.month-table td.past-day { background: #fafafa; }
.month-table td.past-day .day-num { color: #9ca3af; }
.month-table td.empty {
  background: #fafafa;
  height: 128px;
}
.day-num { font-weight: 800; margin-bottom: 6px; color: var(--ink); }
.booking-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 6px;
  width: 100%;
}
.booking-row .cal-chip.booked,
.booking-row .slot.filled {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  text-align: left;
  font: inherit;
  height: auto;
  min-height: 44px;
}
.booking-row .slot.filled {
  display: block;
  width: auto;
  min-height: 56px;
}
.cal-chip {
  display: block;
  border-radius: 10px;
  padding: 6px 8px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  border: 0;
  width: 100%;
  box-sizing: border-box;
}
.cal-chip small { display: block; opacity: .95; font-weight: 600; }
.cal-chip.booked { color: #fff; }
.cal-chip.free {
  background: #f8f9fb;
  border: 1px dashed #d7dbe3;
  color: var(--muted);
}
.cal-chip.free:hover {
  border-color: var(--mint-2);
  color: #065f46;
  background: var(--mint-soft);
}
.cal-edit-btn {
  flex: 0 0 36px;
  width: 36px;
  min-width: 36px;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  color: #4b5563;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.cal-edit-btn svg {
  display: block;
  pointer-events: none;
}
.cal-edit-btn:hover {
  background: #111827;
  border-color: #111827;
  color: #fff;
}
.res-view-mode input:disabled,
.res-view-mode select:disabled,
.res-view-mode textarea:disabled {
  opacity: 1;
  color: #111827;
  background: #f3f4f6 !important;
}

.muted { color: var(--muted); }
.two { grid-template-columns: 1.35fr .85fr; }
.dash-bottom { grid-template-columns: 1.2fr .9fr .9fr; margin-top: 14px; }
.task-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.task-row:last-child { border-bottom: 0; }
.bubble-board {
  display: grid;
  place-items: center;
  min-height: 180px;
  background: #f8f9fb;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
}
.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px;
}

@media (max-width: 1100px) {
  .stats, .two, .dash-bottom { grid-template-columns: 1fr 1fr; }
  .list-row { grid-template-columns: 40px 1fr auto; }
  .list-row > :nth-child(3),
  .list-row > :nth-child(4) { display: none; }
}
@media (max-width: 900px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .stats, .two, .dash-bottom, .form-grid { grid-template-columns: 1fr; }
  #side-nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  .logout { width: 100%; }
}
