/* SchoolCare Config Manager: white page, blue sidebar and buttons, yellow (the "S" of the logo) as highlight. */
:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --text: #16213a;
  --muted: #5f6b85;
  --line: #e1e6f0;
  --line-strong: #cbd3e3;
  --blue: #1f5fbf;
  --blue-hover: #184d9c;
  --blue-soft: #eaf1fc;
  --blue-text: #ffffff;
  --navy: #0f3c78;
  --navy-2: #0b2f60;
  --yellow: #f6c624;
  --yellow-soft: #fff7d6;
  --yellow-line: #f0d77a;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #8a5d00;
  --shadow: 0 1px 2px rgba(16, 33, 70, .06), 0 4px 14px rgba(16, 33, 70, .06);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 22px; }
h3 { font-size: 15px; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 10px 0 0; font-size: 13px; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- form controls ---- */
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 95, 191, .18); }
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.45; }
label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 13px; }
label > input, label > textarea, label > select { margin-top: 5px; font-weight: 400; font-size: 14px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); margin: 0; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
button:disabled { opacity: .45; cursor: default; }
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button.primary { background: var(--blue); color: var(--blue-text); }
button.primary:hover:not(:disabled) { background: var(--blue-hover); }
button.secondary { background: #fff; border-color: var(--line-strong); color: var(--text); }
button.secondary:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
button.block { width: 100%; padding: 10px; font-size: 14px; }
button.small { padding: 5px 10px; font-size: 12px; }
button.danger { background: transparent; color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); }
.icon-btn { padding: 6px; background: transparent; color: var(--muted); border-radius: 7px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* white plate behind the logo, for the blue sidebar */
.logo-plate { display: inline-flex; padding: 6px 10px; border-radius: 10px; background: #fff; }
.logo-plate img { display: block; height: auto; max-width: 100%; }
.logo-plate.small { padding: 4px 8px; border-radius: 8px; }

/* ---- login ---- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 520px at 10% -10%, #fff3c4, transparent 60%),
    radial-gradient(900px 520px at 110% 110%, #d9e6fb, transparent 60%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  border-radius: 14px;
  padding: 30px 30px 26px;
  box-shadow: 0 10px 40px rgba(16, 33, 70, .10);
}
.login-card .logo-plate { display: flex; justify-content: center; margin: 0 auto 18px; padding: 0; }
.login-logo { width: 200px; }
.login-card h1 { text-align: center; color: var(--navy); }
.login-card > p.muted { text-align: center; margin: 6px 0 24px; font-size: 13px; }
.login-card button { margin-top: 6px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.brand-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--yellow);
  border-left: 1px solid rgba(255, 255, 255, .25);
  padding-left: 10px;
  line-height: 1.25;
}
.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 6px 18px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #b8c7e3;
}
.count-badge { margin-left: 4px; padding: 1px 7px; border-radius: 10px; background: rgba(255, 255, 255, .12); font-size: 11px; letter-spacing: 0; color: #fff; }
.sidebar .icon-btn { color: #b8c7e3; }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.search { position: relative; }
.sidebar .search { margin: 0 14px 8px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 33px; }
.sidebar .search input { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.sidebar .search input::placeholder { color: #9fb2d6; }
.sidebar .search input:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(246, 198, 36, .25); }
.sidebar .search svg { color: #9fb2d6; }

.db-list { list-style: none; margin: 0; padding: 4px 8px 10px; overflow-y: auto; flex: 1; }
.db-list li button {
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  text-align: left;
  font-weight: 400;
  white-space: normal;
  border-left: 3px solid transparent;
}
.db-list li button:hover { background: rgba(255, 255, 255, .08); }
.db-list li button.active { background: rgba(255, 255, 255, .14); border-left-color: var(--yellow); }
.db-list .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .25); flex: none; }
.db-list .dot.on { background: var(--yellow); box-shadow: 0 0 0 3px rgba(246, 198, 36, .2); }
.db-list .names { min-width: 0; }
.db-list .school { display: block; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.db-list .db { display: block; font: 11.5px var(--mono); color: #9fb2d6; overflow-wrap: anywhere; }
.db-list .note { padding: 10px; color: #b8c7e3; font-size: 13px; }

.side-foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; border-top: 1px solid rgba(255, 255, 255, .12); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); color: #1c1c1c; font-weight: 700; font-size: 14px; text-transform: uppercase; }
.who { flex: 1; min-width: 0; line-height: 1.25; }
.who strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.who span { font-size: 12px; color: #b8c7e3; }

/* ---- page ---- */
.content { padding: 28px 32px 90px; min-width: 0; }
.empty-state { display: grid; place-items: center; text-align: center; gap: 8px; min-height: 60vh; color: var(--muted); }
.empty-state .empty-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: var(--blue-soft); color: var(--blue); margin: 0 auto 6px; }
.empty-state .empty-icon svg { width: 26px; height: 26px; }
.empty-state strong { color: var(--text); font-size: 16px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head h2 { color: var(--navy); }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.chip { padding: 1px 8px; border-radius: 6px; background: #fff; border: 1px solid var(--line); font-size: 12px; color: var(--text); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--blue-soft); color: var(--blue); }
.pill.warn { background: var(--yellow-soft); color: var(--warn); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.tabs { display: flex; gap: 2px; margin: 4px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab { gap: 8px; padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-size: 13.5px; }
.tab:hover { color: var(--blue); }
.tab.active { color: var(--navy); border-bottom-color: var(--yellow); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.tab .dot.on { background: var(--blue); }
.tab-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tab-bar .meta-row { margin-top: 0; }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--yellow-soft);
  border: 1px solid var(--yellow-line);
  font-size: 13px;
}
.notice svg { color: var(--warn); margin-top: 1px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card h3 { margin-bottom: 8px; }
.card p { margin: 0 0 16px; color: var(--muted); }
.card pre { margin: 10px 0 0; padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; font: 12px/1.55 var(--mono); }
details summary { cursor: pointer; color: var(--muted); margin-top: 18px; font-size: 13px; }

/* ---- settings form (app_config) ---- */
.form-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.form-toolbar .search { flex: 1; max-width: 380px; }
.show-select { width: auto; min-width: 150px; }
.groups { display: flex; flex-direction: column; gap: 16px; }
.group { padding: 0; overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.group-head h3 { margin: 0; color: var(--navy); }
.group-count { font-size: 12px; color: var(--muted); margin-right: auto; }
.group .group-note { margin: 14px 20px 0; font-size: 13px; color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px 22px; padding: 18px 20px 20px; }
.setting { min-width: 0; padding: 2px 0 0; border-radius: 8px; }
.setting.wide { grid-column: 1 / -1; }
.setting-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 26px; margin-bottom: 4px; }
.setting-head label { margin: 0; font-size: 13px; }
.setting .clear { padding: 3px; visibility: hidden; }
.setting .clear svg { width: 14px; height: 14px; }
.setting.is-set .clear { visibility: visible; }
.setting select:not(:focus) { cursor: pointer; }
.setting:not(.is-set) input, .setting:not(.is-set) select, .setting:not(.is-set) textarea { background: var(--panel-2); color: var(--muted); }
.setting.changed { box-shadow: 0 0 0 6px var(--yellow-soft); background: var(--yellow-soft); }
.setting.changed input, .setting.changed select, .setting.changed textarea { border-color: var(--yellow); }
.setting textarea { min-height: 38px; overflow: hidden; resize: none; }
.setting-foot { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.setting-foot code { color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip-btn { padding: 2px 8px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; font: 500 11.5px var(--mono); color: var(--muted); }
.chip-btn:hover { border-color: var(--blue); color: var(--blue); }
.chip-btn.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.with-btn { position: relative; }
.with-btn input { padding-right: 40px; }
.with-btn .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.masked { -webkit-text-security: disc; }

.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 16px 12px 20px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 30px rgba(11, 47, 96, .35);
  border-left: 5px solid var(--yellow);
}
.save-bar #save-count { font-weight: 600; }
.save-bar button.secondary { background: transparent; border-color: rgba(255, 255, 255, .35); color: #fff; }
.save-bar button.secondary:hover:not(:disabled) { border-color: #fff; color: #fff; }
.save-bar button.primary { background: var(--yellow); color: #1c1c1c; }
.save-bar button.primary:hover:not(:disabled) { background: #ffd54a; }

/* ---- row cards of the other tables (WhatsApp) ---- */
.record-list { display: flex; flex-direction: column; gap: 14px; }
.record { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.record.dirty { box-shadow: inset 4px 0 0 var(--yellow), var(--shadow); }
.record.dirty .record-head { background: var(--yellow-soft); }
.record.new { border-color: var(--blue); }
.record-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.record-head strong { font-family: var(--mono); font-size: 13px; color: var(--navy); }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px 18px; padding: 16px; }
.field.wide { grid-column: 1 / -1; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 5px; font-size: 12.5px; }
.field-type { font: 11px var(--mono); color: var(--muted); font-weight: 400; }
.field input, .field textarea { font-family: var(--mono); font-size: 13px; }
.field textarea { min-height: 36px; overflow: hidden; resize: none; }
.field input:disabled, .field textarea:disabled { background: var(--panel-2); color: var(--muted); }

/* ---- dialogs ---- */
dialog { width: min(540px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 14px; padding: 0; background: #fff; color: var(--text); box-shadow: 0 20px 60px rgba(11, 30, 60, .3); }
dialog::backdrop { background: rgba(11, 30, 60, .5); }
.dialog-body { padding: 20px 22px 22px; }
.dialog-body > p.muted { margin: 0 0 16px; font-size: 13px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dialog-head h3 { color: var(--navy); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

.toast {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 9px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast.bad { background: var(--danger); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .db-list { max-height: 34vh; }
  .content { padding: 20px 16px 80px; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .form-toolbar .search { max-width: none; }
}
