/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #dbeafe; --primary-50: #eff6ff;
  --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb; --gray-300: #d1d5db;
  --gray-400: #9ca3af; --gray-500: #6b7280; --gray-600: #4b5563; --gray-700: #374151;
  --gray-800: #1f2937; --gray-900: #111827;
  --red-500: #ef4444; --red-50: #fef2f2; --red-700: #b91c1c;
  --green-500: #22c55e; --green-50: #f0fdf4; --green-700: #15803d;
  --amber-400: #fbbf24; --amber-50: #fffbeb; --amber-500: #f59e0b; --amber-600: #d97706; --amber-800: #92400e;
  --sidebar-w: 260px; --radius: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem;
  --shadow: 0 1px 3px rgba(0,0,0,.1); --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
}
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--gray-50); color: var(--gray-900); line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

/* ── Login ── */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary-50), #e0e7ff); }
.login-card { background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 2.5rem; max-width: 400px; width: 100%; text-align: center; }
.login-logo { width: 64px; height: 64px; background: var(--primary); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; margin: 0 auto 1.5rem; color: #fff; font-size: 1.75rem; font-weight: 700; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.login-card p { color: var(--gray-500); margin-bottom: 2rem; font-size: .875rem; }

/* ── Loading ── */
.loading-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; }
.loading-screen p { color: var(--gray-500); }
.spinner { width: 48px; height: 48px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App Shell ── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--gray-200); display: flex; flex-direction: column; z-index: 30; }
.sidebar-logo { display: flex; align-items: center; gap: .75rem; padding: 1.25rem; border-bottom: 1px solid var(--gray-100); }
.logo-icon { width: 36px; height: 36px; background: var(--primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .875rem; }
.logo-title { font-weight: 600; font-size: .875rem; }
.logo-sub { color: var(--gray-500); font-size: .75rem; }
.sidebar-school { padding: .75rem 1.25rem; border-bottom: 1px solid var(--gray-100); }
.sidebar-school .label { font-size: .625rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); }
.sidebar-school .value { font-size: .875rem; font-weight: 500; color: var(--gray-700); margin-top: .125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { flex: 1; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; overflow-y: auto; }
.nav-link { display: flex; align-items: center; gap: .75rem; padding: .625rem .75rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; color: var(--gray-600); text-decoration: none; cursor: pointer; transition: all .15s; }
.nav-link:hover { background: var(--gray-50); color: var(--gray-900); }
.nav-link.active { background: var(--primary-light); color: var(--primary-dark); }
.nav-link .icon { font-size: 1.125rem; width: 1.5rem; text-align: center; }
.sidebar-user { padding: 1rem; border-top: 1px solid var(--gray-100); display: flex; align-items: center; gap: .75rem; }
.user-avatar { width: 32px; height: 32px; background: var(--gray-200); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 600; color: var(--gray-600); flex-shrink: 0; }
.user-name { flex: 1; font-size: .875rem; font-weight: 500; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Main ── */
.main-content { margin-left: var(--sidebar-w); padding: 1.5rem; flex: 1; min-height: 100vh; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; border: none; cursor: pointer; transition: all .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; } .btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); } .btn-secondary:hover:not(:disabled) { background: var(--gray-200); }
.btn-danger { color: var(--red-500); background: none; padding: .25rem .5rem; } .btn-danger:hover { color: var(--red-700); }
.btn-amber { background: var(--amber-500); color: #fff; } .btn-amber:hover:not(:disabled) { background: var(--amber-600); }
.btn-block { width: 100%; justify-content: center; padding: .75rem; }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--gray-400); font-size: 1rem; padding: .25rem; transition: color .15s; }
.btn-icon:hover { color: var(--red-500); }

/* ── Page Header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* ── Cards & Panels ── */
.card { background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow); border: 1px solid var(--gray-100); }
.card-body { padding: 1.5rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; }
.stat-card { padding: 1.5rem; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.25rem; margin-bottom: .75rem; }
.stat-card .stat-label { font-size: .875rem; color: var(--gray-500); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; margin-top: .25rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: .75rem 1.5rem; text-align: left; font-size: .75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; background: var(--gray-50); }
tbody td { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-100); font-size: .875rem; }
tbody tr { cursor: pointer; transition: background .1s; } tbody tr:hover { background: var(--gray-50); }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }

/* ── Tags / Badges ── */
.badge { display: inline-block; padding: .125rem .5rem; border-radius: 9999px; font-size: .75rem; font-weight: 500; }
.badge-green { background: var(--green-50); color: var(--green-700); }
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.dept-tag { display: inline-block; padding: .125rem .375rem; border-radius: .25rem; font-size: .6875rem; font-weight: 500; color: #fff; margin: .125rem; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .col-span-2 { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: .25rem; }
.form-group label { font-size: .8125rem; font-weight: 500; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
  padding: .5rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: .875rem; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--gray-100); }
fieldset { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
fieldset legend { font-size: .8125rem; font-weight: 600; color: var(--gray-700); padding: 0 .5rem; }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: .75rem; margin-bottom: 1rem; background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: .75rem; }
.filter-bar select { border: 1px solid var(--gray-300); border-radius: var(--radius); padding: .5rem .75rem; font-size: .875rem; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); max-width: 48rem; width: calc(100% - 2rem); max-height: 90vh; overflow-y: auto; }
.modal.narrow { max-width: 32rem; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; border-bottom: 1px solid var(--gray-100); position: sticky; top: 0; background: #fff; border-radius: var(--radius-xl) var(--radius-xl) 0 0; z-index: 1; }
.modal-header h2 { font-size: 1.125rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }

/* ── Alert ── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; }
.alert-error { background: var(--red-50); color: var(--red-700); }

/* ── Quick Links ── */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-top: 1rem; }
.quick-link { display: block; padding: 1rem; border: 1px solid var(--gray-200); border-radius: var(--radius); cursor: pointer; transition: all .15s; text-decoration: none; color: inherit; }
.quick-link:hover { border-color: var(--primary); background: var(--primary-50); }
.quick-link .ql-title { font-weight: 500; }
.quick-link .ql-desc { font-size: .8125rem; color: var(--gray-500); margin-top: .25rem; }

/* ── Planning Grid ── */
.planning-wrapper { background: #fff; border-radius: var(--radius-xl); border: 1px solid var(--gray-200); overflow: auto; max-height: calc(100vh - 220px); }
.planning-wrapper table { border-collapse: collapse; min-width: 100%; }
.planning-wrapper thead { position: sticky; top: 0; z-index: 20; }
.planning-wrapper thead th { background: var(--gray-50); border-bottom: 2px solid var(--gray-200); border-right: 1px solid var(--gray-200); padding: .75rem; text-align: left; white-space: nowrap; }
.planning-wrapper thead th:first-child { position: sticky; left: 0; z-index: 25; min-width: 120px; }
.planning-wrapper tbody td { border-bottom: 1px solid var(--gray-200); border-right: 1px solid var(--gray-200); padding: .25rem; vertical-align: top; min-width: 180px; height: 64px; position: relative; }
.planning-wrapper tbody td:first-child { position: sticky; left: 0; z-index: 10; background: var(--gray-50); min-width: 120px; padding: .5rem; }
.student-header { font-size: .8125rem; font-weight: 600; }
.student-sub { font-size: .6875rem; color: var(--gray-400); }
.kw-label { font-size: .8125rem; font-weight: 600; color: var(--gray-700); }
.kw-dates { font-size: .625rem; color: var(--gray-400); }

.cell-empty { cursor: pointer; transition: background .1s; }
.cell-empty:hover { background: var(--primary-50); }
.cell-dragover { background: var(--primary-light) !important; }

.assignment-block {
  position: absolute; left: 4px; right: 4px; top: 4px;
  border-radius: .375rem; color: #fff; font-size: .6875rem; font-weight: 500;
  padding: .25rem .5rem; cursor: pointer; z-index: 5; box-shadow: var(--shadow);
  overflow: hidden; transition: box-shadow .15s;
}
.assignment-block:hover { box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 10; }
.assignment-block .ab-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignment-block .ab-meta { opacity: .85; }
.assignment-block .ab-close { position: absolute; top: 2px; right: 4px; opacity: .6; cursor: pointer; font-size: .75rem; }
.assignment-block .ab-close:hover { opacity: 1; }

.vacation-block {
  position: absolute; left: 4px; right: 4px; top: 4px;
  border-radius: .375rem; border: 2px solid var(--amber-400); background: var(--amber-50); color: var(--amber-800);
  font-size: .6875rem; font-weight: 500; padding: .25rem .5rem; cursor: pointer; z-index: 4;
}

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--gray-400); }
.empty-state p { margin-bottom: 1rem; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Admin code tags ── */
code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .8125em; }

/* ── API Docs ── */
.api-search-bar { margin-bottom: 1rem; }
.api-search-bar input { width: 100%; padding: .75rem 1rem; border: 1px solid var(--gray-300); border-radius: var(--radius-lg); font-size: .9375rem; font-family: inherit; background: #fff; transition: border-color .15s, box-shadow .15s; }
.api-search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.api-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; font-size: .8125rem; color: var(--gray-500); align-items: center; }
.api-legend span { display: inline-flex; align-items: center; gap: .375rem; }
.api-group { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-xl); margin-bottom: 1.25rem; overflow: hidden; }
.api-group-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; background: var(--gray-50); border-bottom: 1px solid var(--gray-100); }
.api-group-title { font-size: 1rem; font-weight: 700; color: var(--gray-900); }
.api-group-desc { font-size: .8125rem; color: var(--gray-500); margin-top: .125rem; }
.api-endpoints { }
.api-endpoint { border-bottom: 1px solid var(--gray-100); }
.api-endpoint:last-child { border-bottom: none; }
.api-endpoint-summary { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; cursor: pointer; list-style: none; transition: background .1s; }
.api-endpoint-summary::-webkit-details-marker { display: none; }
.api-endpoint-summary:hover { background: var(--gray-50); }
.api-endpoint[open] > .api-endpoint-summary { background: var(--primary-50); }
.api-method { display: inline-block; min-width: 56px; padding: .125rem .5rem; border-radius: .25rem; font-size: .6875rem; font-weight: 700; color: #fff; text-align: center; letter-spacing: .03em; font-family: 'SF Mono', 'Fira Code', monospace; flex-shrink: 0; }
.api-path { font-size: .875rem; font-weight: 500; color: var(--gray-800); background: none; padding: 0; white-space: nowrap; }
.api-desc { font-size: .8125rem; color: var(--gray-500); margin-left: auto; text-align: right; flex-shrink: 1; }
.api-endpoint-detail { padding: .75rem 1.25rem 1rem; background: var(--gray-50); border-top: 1px solid var(--gray-100); }
.api-detail-table { width: 100%; border-collapse: collapse; }
.api-detail-table td { padding: .375rem 0; vertical-align: top; font-size: .8125rem; border: none; }
.api-detail-table tr { cursor: default; }
.api-detail-table tr:hover { background: transparent; }
.api-detail-label { font-weight: 600; color: var(--gray-600); width: 140px; white-space: nowrap; padding-right: 1rem; }
.api-code-block { display: inline-block; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: .25rem; padding: .25rem .5rem; font-size: .75rem; line-height: 1.5; color: var(--gray-700); word-break: break-all; max-width: 100%; }
.api-auth-badge { display: inline-block; padding: .125rem .5rem; border-radius: 9999px; font-size: .6875rem; font-weight: 500; }
.api-auth-none { background: var(--green-50); color: var(--green-700); }
.api-auth-tenant { background: var(--primary-light); color: var(--primary-dark); }
.api-auth-admin { background: #fef3c7; color: #92400e; }

/* ── Map Page ── */
.map-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; padding: .75rem 1rem; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); margin-bottom: .75rem; }
.map-toolbar-section { display: flex; flex-direction: column; gap: .25rem; }
.map-toolbar-section > label { font-size: .6875rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; }
.map-toolbar-section > input,
.map-toolbar-section > .input-row > input { padding: .375rem .5rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .8125rem; font-family: inherit; }
.map-toolbar-section > input:focus,
.map-toolbar-section > .input-row > input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.map-toolbar-section .input-row { display: flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--gray-600); }
.map-toolbar-buttons { flex-direction: row; gap: .375rem; align-self: flex-end; }
.map-toolbar-divider { width: 1px; height: 32px; background: var(--gray-200); align-self: flex-end; margin-bottom: 2px; }
.map-toolbar .dropdown-check-btn { font-size: .8125rem; padding: .375rem 1.5rem .375rem .5rem; }

.map-body { display: flex; gap: .75rem; height: calc(100vh - 220px); }
.map-container { flex: 1; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--gray-200); min-height: 300px; }
.map-container .leaflet-container { height: 100%; width: 100%; }
.map-sidebar { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; }
.map-list-header { padding: .625rem .75rem; font-size: .8125rem; font-weight: 600; color: var(--gray-700); background: var(--gray-50); border-bottom: 1px solid var(--gray-100); }
.map-practice-list { flex: 1; overflow-y: auto; }
.map-list-item { padding: .625rem .75rem; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background .1s; }
.map-list-item:hover { background: var(--gray-50); }
.map-list-item.in-range { background: var(--green-50); }
.map-list-item.in-range:hover { background: #dcfce7; }
.map-list-item.highlighted { border-left: 3px solid var(--primary); }
.map-list-item-header { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.map-list-item-header strong { font-size: .8125rem; }
.map-list-distance { font-size: .75rem; color: var(--gray-500); white-space: nowrap; }
.map-list-item-meta { font-size: .75rem; color: var(--gray-500); margin-top: .125rem; }
.map-list-item-tags { margin-top: .25rem; }
.map-list-separator { padding: .5rem .75rem; font-size: .75rem; font-weight: 600; color: var(--gray-400); background: var(--gray-100); text-transform: uppercase; letter-spacing: .04em; }
.map-list-item.no-geo { opacity: .55; }
.map-list-item.no-geo:hover { opacity: .75; }
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table td { padding: .375rem .75rem; font-size: .875rem; border-bottom: 1px solid var(--gray-100); }

/* ── Dropdown Checkbox ── */
.dropdown-check { position: relative; display: inline-block; }
.dropdown-check-btn { position: relative; text-align: left; padding: .5rem 1.75rem .5rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .875rem; font-family: inherit; background: #fff; cursor: pointer; color: var(--gray-700); white-space: nowrap; transition: border-color .15s; }
.dropdown-check-btn::after { content: ""; position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); border: 4px solid transparent; border-top: 5px solid var(--gray-400); }
.dropdown-check-btn:hover { border-color: var(--gray-400); }
.dropdown-check.open .dropdown-check-btn { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.dropdown-check-panel { display: none; position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 1000; max-height: 200px; overflow-y: auto; }
.dropdown-check.open .dropdown-check-panel { display: block; }
.dropdown-check-item { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; font-size: .8125rem; cursor: pointer; transition: background .1s; }
.dropdown-check-item:hover { background: var(--gray-50); }
.dropdown-check-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }

