:root {
  --navy: #1e3a8a;
  --navy-dark: #172554;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --grey-bg: #f1f5f9;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }

.navbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; margin-right: auto; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { display: block; opacity: 0.8; font-size: 0.78rem; }
.logo { width: 44px; height: 44px; border-radius: 10px; background: #fff; padding: 3px; flex: none; }
nav { display: flex; flex-wrap: wrap; gap: 0.4rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; }

.card { background: var(--card); border-radius: 10px; padding: 1rem; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); }
.card.narrow { max-width: 440px; margin: 2rem auto; }
.card.narrow h2 { margin-top: 0; }

label { display: block; font-size: 0.85rem; color: #334155; margin-bottom: 0.7rem; }
label input, label textarea, label select {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem 0.6rem; font: inherit;
  border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: var(--text);
}
label.check { display: flex; align-items: center; gap: 0.5rem; }
label.check input { width: auto; margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

.btn {
  font: inherit; font-size: 0.88rem; font-weight: 600; border: 0; border-radius: 6px;
  padding: 0.5rem 0.9rem; background: var(--navy); color: #fff; cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.light { background: #fff; color: var(--navy); }
.btn.ghost { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.45); }
.btn.ghost-dark { background: transparent; color: var(--navy); border: 1px solid #cbd5e1; }
.btn.danger { background: var(--bad); }
.btn.small { font-size: 0.8rem; padding: 0.35rem 0.65rem; }
.actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.spacer { flex: 1; }

.alert { border-radius: 8px; padding: 0.7rem 0.9rem; margin: 0.75rem 0; font-size: 0.9rem; }
.alert.error { background: var(--bad-bg); color: var(--bad); border: 1px solid #fecaca; }
.alert.success { background: var(--ok-bg); color: var(--ok); border: 1px solid #a7f3d0; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 0.75rem; }
.tile { background: var(--card); border-radius: 10px; padding: 0.8rem 0.9rem; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); }
.tile .value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tile .label { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.tile.bad .value { color: var(--bad); }
.tile.warn .value { color: var(--warn); }
.tile.ok .value { color: var(--ok); }

.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; justify-content: space-between; }
.filters { display: flex; gap: 0.35rem; }
.chip { font: inherit; font-size: 0.8rem; border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; padding: 0.25rem 0.75rem; cursor: pointer; color: #334155; }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0.85rem; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }
.school { background: var(--card); border-radius: 10px; padding: 0.9rem; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); border-top: 4px solid var(--line); display: flex; flex-direction: column; gap: 0.55rem; }
.school.ok { border-top-color: var(--ok); }
.school.attention { border-top-color: #d97706; }
.school.offline, .school.db_down { border-top-color: var(--bad); }
.school.key_problem { border-top-color: var(--info); }
.school-head { display: flex; align-items: flex-start; gap: 0.5rem; }
.school-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.school-head a { display: block; font-size: 0.78rem; color: var(--muted); text-decoration: none; word-break: break-all; font-weight: 400; }
.pill { font-size: 0.74rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.attention { background: var(--warn-bg); color: var(--warn); }
.pill.offline, .pill.db_down { background: var(--bad-bg); color: var(--bad); }
.pill.key_problem { background: var(--info-bg); color: var(--info); }
.pill.unknown, .pill.paused { background: var(--grey-bg); color: var(--muted); }
.pill.update { background: var(--info-bg); color: var(--info); font-weight: 600; }
.detail { font-size: 0.83rem; color: #334155; background: var(--grey-bg); border-radius: 6px; padding: 0.4rem 0.55rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem 0.6rem; }
.stat .v { font-weight: 700; font-size: 0.98rem; }
.stat .v.bad { color: var(--bad); }
.stat .v.warn { color: var(--warn); }
.stat .l { font-size: 0.72rem; color: var(--muted); }
.school-foot { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.76rem; color: var(--muted); }
.school-foot .spacer { min-width: 0.5rem; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--line); font-size: 0.86rem; display: flex; gap: 0.6rem; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list time { color: var(--muted); white-space: nowrap; font-size: 0.78rem; min-width: 7.5rem; }
.alert-list .st { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) {
  .alert-list li { flex-wrap: wrap; gap: 0.15rem 0.6rem; }
  .alert-list li .msg { order: 3; flex-basis: 100%; }
  .alert-list time { min-width: 0; }
}

dialog { border: 0; border-radius: 12px; padding: 0; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3); }
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog form, .dialog-body { padding: 1.1rem 1.2rem; }
dialog h2 { margin-top: 0; }
#passwordForm { border-top: 1px solid var(--line); }
.detail-head { display: flex; align-items: center; gap: 0.5rem; }
.detail-head h2 { flex: 1; margin: 0; }
.kv { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-bottom: 0.4rem; }
.kv td { padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 48%; }
.kv td:last-child { font-weight: 600; word-break: break-word; }

.bos-brand { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 1.25rem 1rem 1.5rem; letter-spacing: 0.02em; }
.bos-brand-logo { width: 18px; height: 18px; vertical-align: -4px; margin-right: 0.4rem; }

/* support requests in the school detail */
.tickets tr.urgent td { color: var(--bad); font-weight: 600; }
.tickets .ticket-detail { margin-top: 0.6rem; }
.tickets .notes { list-style: none; padding: 0; margin: 0.4rem 0; }
.tickets .notes li { border-left: 3px solid var(--line); padding: 0.3rem 0.6rem; margin-bottom: 0.4rem; font-size: 0.86rem; white-space: pre-wrap; }
.tickets .notes li.tabitech { border-left-color: var(--navy); }
.tickets .row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.4rem; }

/* Package and modules (school details) and the Prices screen */
.package-box { margin-bottom: 0.6rem; }
.package-form { padding: 0; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 0.75rem; margin-bottom: 0.6rem; font-size: 0.88rem; }
@media (max-width: 560px) { .checks { grid-template-columns: 1fr; } }
.quote { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.7rem; margin: 0.6rem 0; }
.quote .kv td:first-child { width: 70%; }
.quote .kv tr.total td { font-weight: 700; color: inherit; border-top: 2px solid var(--line); }
.quote p { margin: 0.35rem 0; }
dialog.wide { width: min(820px, calc(100vw - 32px)); }
.table-wrap { overflow-x: auto; }
table.prices { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.prices th, table.prices td { padding: 0.3rem 0.35rem; border-bottom: 1px solid var(--line); text-align: left; }
table.prices td:first-child { white-space: nowrap; }
table.prices input { width: 100%; min-width: 6.5rem; margin: 0; }
