:root {
  --bg: #f7fafc;
  --text: #1a202c;
  --muted: #718096;
  --primary: #2b6cb0;
  --primary-dark: #1a365d;
  --card: #ffffff;
  --border: #e2e8f0;
  --danger: #c53030;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(26, 32, 44, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--primary); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 1.25rem; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--primary-dark); }
.brand-logo { display: block; height: 38px; width: auto; }
a.brand { text-decoration: none; }
.topbar nav a {
  margin-left: 1rem;
  text-decoration: none;
  color: var(--muted);
}

.hero { padding: 4.5rem 1.25rem 3rem; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 700;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.15;
  margin: 0.5rem 0 1rem;
  color: var(--primary-dark);
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; }
.hero-actions { margin-top: 1.75rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding: 2rem 1.25rem 3rem;
}
.features article, .schools {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.schools { margin-bottom: 3rem; }
.footer { padding: 2rem 1.25rem 3rem; color: var(--muted); font-size: 0.95rem; }

.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tenant-primary, #2b6cb0) 12%, white), #edf2f7);
}
.login-card {
  width: min(420px, calc(100vw - 2rem));
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  border: 1px solid var(--border);
}
.school-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tenant-primary, #2b6cb0) 15%, white);
  color: var(--tenant-accent, var(--primary-dark));
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
  color: var(--tenant-accent, var(--primary-dark));
}
.login-card .subtitle { color: var(--muted); margin: 0 0 1.5rem; }
.login-logo {
  display: block;
  width: min(200px, 100%);
  height: auto;
  margin: 0 0 1rem;
}
label { display: block; font-weight: 600; margin-top: 1rem; }
input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
button[type="submit"] {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem;
  border: 0;
  border-radius: 8px;
  background: var(--tenant-primary, var(--primary));
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.error {
  margin-top: 1rem;
  color: var(--danger);
  font-size: 0.95rem;
  min-height: 1.2rem;
}
.dashboard {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.25rem 3rem;
}
.dashboard-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.dashboard h1 { margin-top: 0; color: var(--tenant-accent, var(--primary-dark)); }
.meta { color: var(--muted); }
.logout {
  margin-top: 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.page-admin .login-card { border-top: 4px solid #1a202c; }
.page-admin .school-badge { background: #edf2f7; color: #1a202c; }

/* School console layout */
.page-console {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--tenant-accent, var(--primary-dark));
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
}

.sidebar-head {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: #f8fafc;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.85rem;
}

.sidebar-brand img {
  flex-shrink: 0;
  border-radius: 8px;
}

.sidebar .school-badge {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  margin-bottom: 0.5rem;
}

.sidebar-user {
  font-size: 0.9rem;
  opacity: 0.85;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: block;
  padding: 0.75rem 1.25rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: #fff;
  color: #fff;
  font-weight: 600;
}

.sidebar-logout {
  margin: 1rem;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.sidebar-logout:hover {
  background: rgba(255, 255, 255, 0.1);
}

.console-main {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2rem 3rem;
}

.console-header {
  margin-bottom: 1.5rem;
}

.console-header h1 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--tenant-accent, var(--primary-dark));
}

.panel { display: none; }
.panel.active { display: block; }

.panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.panel-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.empty-state {
  padding: 2rem 1.5rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  background: #fafafa;
}

.empty-state strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.panel-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.panel-toolbar .panel-lead { margin: 0; }

.section-title {
  font-size: 1rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--tenant-accent, var(--primary-dark));
}

.hint { margin-bottom: 0.75rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-skipped_offline { background: #fee2e2; color: #991b1b; }
.badge-failed { background: #fee2e2; color: #991b1b; }

.device-apps-group {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.device-apps-group h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.device-apps-group ul { margin: 0; padding-left: 1.25rem; }

.online-dot {
  color: #059669;
  font-size: 0.8rem;
  font-weight: 600;
}

.modal {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  max-width: 480px;
  width: calc(100vw - 2rem);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,0.4); }
.modal form { padding: 1.5rem; }
.modal h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.deploy-target { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; margin: 1rem 0; }
.deploy-target legend { font-weight: 600; padding: 0 0.25rem; }
.checkbox { display: block; margin: 0.35rem 0; font-weight: normal; }
.device-pick { margin-top: 0.5rem; max-height: 160px; overflow-y: auto; }
.hidden { display: none !important; }

button.btn-primary {
  width: auto;
  margin-top: 0;
  background: var(--tenant-primary, var(--primary));
}

.branding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.branding-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: #fafafa;
}
.preview-box {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.75rem 0;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.5rem;
}
.preview-box img, .preview-icon img {
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
}
.preview-slides {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.slide-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}
.preview-video video {
  max-width: 100%;
  max-height: 200px;
}
.file-label {
  display: block;
  margin: 0.5rem 0;
  font-weight: 600;
  font-size: 0.9rem;
}
.file-label input { margin-top: 0.35rem; font-weight: normal; }
textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  box-sizing: border-box;
}
.media-mode { margin: 0.75rem 0 1rem; }
.success-msg { color: #059669; font-size: 0.95rem; min-height: 1.2rem; }

.subscription-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--tenant-primary, #2b6cb0) 8%, white), #fff);
}
.sub-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}
.sub-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sub-value { font-size: 1.1rem; font-weight: 600; margin-top: 0.25rem; }

.invoice-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.badge-type-monthly { background: #dbeafe; color: #1e40af; }
.badge-type-yearly { background: #e0e7ff; color: #3730a3; }
.badge-type-one_time { background: #f3e8ff; color: #6b21a8; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }

@media (max-width: 768px) {
  .page-console { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
  }
  .nav-item {
    border-left: 0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
  .nav-item.active { border-left: 0; background: rgba(255,255,255,0.2); }
  .sidebar-logout { display: none; }
  .console-main { padding: 1rem; }
}

@media (max-width: 600px) {
  .hero { padding-top: 3rem; }
}
