button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  touch-action: manipulation;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease, transform .08s ease;
  user-select: none;
}
button:hover,
.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}
button:not(:disabled):active,
.btn:not(:disabled):active {
  transform: translateY(1px);
}
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 0;
  box-shadow: var(--shadow-focus), var(--shadow-soft);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.hamburger { min-height: 40px; box-shadow: none; }

.actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.actions button,
.toolbar button {
  white-space: nowrap;
}
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.action-menu {
  position: relative;
}
.action-menu summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.action-menu summary::-webkit-details-marker {
  display: none;
}
.action-menu summary::after {
  content: "...";
  margin-left: 5px;
  color: var(--muted);
}
.action-menu[open] summary {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}
.action-menu > div {
  position: absolute;
  right: 0;
  z-index: 12;
  display: grid;
  gap: 6px;
  min-width: 150px;
  margin-top: 5px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.action-menu > div button {
  justify-content: flex-start;
  width: 100%;
  box-shadow: none;
}
.table-wrap .action-menu > div {
  position: static;
}
.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.card,
.panel,
.status-card,
.activity-item,
.attention-item,
.folder-card,
.suggested-card,
.reminder-card,
.profile-item,
.student-picker,
.student-item,
.class-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.card,
.panel {
  background: var(--surface);
}
.card { padding: 12px; }
.panel {
  margin-top: 0;
  padding: 16px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-head h3,
.panel h3 {
  margin: 0;
  color: var(--heading);
  font-size: 16px;
  line-height: 1.2;
}
.panel-head .muted { margin-top: 4px; }

.title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.metric {
  color: var(--heading);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.metric-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.metric-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  padding: 14px;
  background: linear-gradient(180deg, #fff, var(--surface-raised));
  border-left: 4px solid var(--border-strong);
}
.metric-card.good { border-left-color: var(--ok); }
.metric-card.attention { border-left-color: var(--danger); }
.metric-card.info { border-left-color: var(--primary); }
.metric-card.money { border-left-color: var(--accent); }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: #485867;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 9px;
  text-align: left;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdff; }
.mini-table td,
.mini-table th { padding: 9px 8px; }

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
}
input::placeholder,
textarea::placeholder { color: #7f8d99; }
textarea {
  min-height: 90px;
  resize: vertical;
}
.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.full { grid-column: 1 / -1; }

.lookup-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}
.lookup-count,
.muted {
  color: var(--muted);
  font-size: 12px;
}
.lookup-count { white-space: nowrap; }
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.filter-chips button {
  min-height: 38px;
  padding: 7px 12px;
  box-shadow: none;
}
.filter-chips button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.badge {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}
.badge.ok {
  background: var(--ok-soft);
  border-color: #bfe5cc;
  color: var(--ok);
}
.badge.warn {
  background: var(--danger-soft);
  border-color: #ffd3ce;
  color: var(--danger);
}
.badge.off {
  background: #eef2f5;
  border-color: #dbe4ea;
  color: #586776;
}

.switch {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}
.switch input {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
}
.switch span {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #c5d2dc;
  position: relative;
  flex: 0 0 auto;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
  box-shadow: 0 1px 3px rgba(15,23,42,.25);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

.dropzone {
  border: 2px dashed #aebfcb;
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-soft);
  text-align: center;
}
.empty-state {
  border: 1px dashed #c7d4dc;
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}
.notice {
  border: 1px solid #f5d580;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--warm-soft);
  color: #7a4a05;
  font-size: 13px;
  line-height: 1.45;
}
.sync-note {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  border: 1px solid #c5dceb;
  border-radius: var(--radius);
  padding: 12px;
  background: var(--primary-soft);
}
.sync-note h4 {
  margin: 0;
  color: var(--primary);
}
.sync-note ul {
  margin: 0;
  padding-left: 18px;
  color: #425d70;
  font-size: 13px;
  line-height: 1.5;
}
.reminder-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.reminder-card {
  display: grid;
  gap: 6px;
  padding: 12px;
}
.reminder-card strong { font-size: 15px; }
.reminder-message {
  max-height: 320px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.reminder-status {
  display: grid;
  gap: 4px;
}
.reminder-status .muted { line-height: 1.35; }

.value-positive {
  color: var(--ok);
  font-weight: 600;
}
.value-negative {
  color: var(--danger);
  font-weight: 600;
}
.value-neutral { color: var(--heading); }

.directory-path {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 12px;
}
.directory-path button,
.directory-path span,
.student-chip,
.class-pill,
.rate-pill {
  border-radius: 999px;
  font-weight: 800;
}
.directory-path button,
.directory-path span {
  border: 0;
  padding: 4px 9px;
  background: var(--primary-soft);
  color: var(--primary);
}
.folder-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.folder-card,
.suggested-card {
  display: grid;
  gap: 6px;
  min-height: 100px;
  padding: 12px;
  background: #fff;
  text-align: left;
}
.folder-card strong,
.suggested-card strong {
  color: var(--heading);
  font-size: 16px;
}
.folder-card .muted { line-height: 1.4; }
.suggested-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 8px 0 12px;
}
.suggested-card {
  border-color: #c5dceb;
  background: linear-gradient(180deg, #fff, var(--primary-soft));
}
.directory-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.profile-item {
  padding: 9px;
  background: var(--surface-soft);
}
.profile-item .title { margin-bottom: 4px; }
.split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.student-picker {
  padding: 10px;
  background: var(--surface-soft);
}
.student-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
.student-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}
.student-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  background: #fff;
}
.student-item input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.student-item span {
  color: var(--heading);
  font-size: 14px;
  line-height: 1.2;
}
.student-chip {
  border: 1px solid #d3e2ea;
  padding: 3px 8px;
  background: #eef5f8;
  color: #355263;
  font-size: 12px;
}
.student-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.class-pill {
  padding: 3px 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
}
.rate-pill {
  padding: 3px 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
  background: rgba(13, 27, 42, 0.56);
  backdrop-filter: blur(4px);
}
.modal {
  width: min(940px, 100%);
  max-height: min(92vh, 900px);
  max-height: min(92dvh, 900px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(13, 27, 42, 0.28);
  scrollbar-gutter: stable;
}
.modal h3 {
  margin: 0 0 12px;
  color: var(--heading);
  font-size: 18px;
  line-height: 1.2;
}
.modal-actions,
.modal form > .full.actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.modal form > .full.actions {
  position: sticky;
  bottom: -18px;
  margin-right: -18px;
  margin-bottom: -18px;
  margin-left: -18px;
  padding: 12px 18px 18px;
  justify-content: flex-end;
}

.notification-stack {
  position: fixed;
  top: 14px;
  right: 14px;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 28px));
  z-index: 60;
  pointer-events: none;
}
.notification-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  overflow: hidden;
  padding: 11px 10px 11px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 55px rgba(13, 27, 42, 0.18);
  animation: notify-slide-in .22s ease both;
}
.notification-toast.closing { animation: notify-slide-out .18s ease both; }
.notification-bar {
  width: 4px;
  align-self: stretch;
  background: var(--primary);
}
.notification-toast.success .notification-bar { background: var(--ok); }
.notification-toast.warning .notification-bar { background: var(--warm); }
.notification-toast.danger .notification-bar { background: var(--danger); }
.notification-toast strong {
  display: block;
  margin-bottom: 2px;
  color: var(--heading);
}
.notification-toast p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.notification-close {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--muted);
  line-height: 1;
}
.notification-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 70;
  background: rgba(13, 27, 42, 0.38);
  backdrop-filter: blur(3px);
}
.notification-backdrop.open { display: flex; }
.notification-dialog {
  width: min(460px, 100%);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(13, 27, 42, 0.28);
  animation: notify-pop-in .2s ease both;
}
.notification-dialog h3 {
  margin: 0 0 8px;
  color: var(--heading);
  font-size: 18px;
}
.notification-dialog-message {
  display: grid;
  gap: 8px;
  color: var(--muted);
  line-height: 1.45;
}
.notification-dialog-message p { margin: 0; }
.notification-dialog.info { border-top: 4px solid var(--primary); }
.notification-dialog.warning { border-top: 4px solid var(--warm); }
.notification-dialog.success { border-top: 4px solid var(--ok); }
.notification-dialog.danger { border-top: 4px solid var(--danger); }
.notification-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
@keyframes notify-slide-in {
  from { transform: translateY(-8px) translateX(18px); opacity: 0; }
  to { transform: translateY(0) translateX(0); opacity: 1; }
}
@keyframes notify-slide-out {
  to { transform: translateY(-6px) translateX(18px); opacity: 0; }
}
@keyframes notify-pop-in {
  from { transform: scale(.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.attendance-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.attendance-title {
  margin: 0 0 4px;
  color: var(--heading);
  font-size: 21px;
}
.attendance-meta {
  color: var(--muted);
  font-size: 13px;
}
.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
.attendance-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.attendance-counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.attendance-list {
  display: grid;
  gap: 8px;
  padding: 2px 0;
  margin-bottom: 10px;
}
.attendance-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  align-items: center;
  padding: 13px;
  background: #fff;
}
.attendance-student-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.student-name {
  color: var(--heading);
  font-weight: 700;
}
.status-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #edf2f5;
}
.status-toggle label { display: block; }
.status-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.status-toggle span {
  display: block;
  min-height: 36px;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: #475569;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.status-toggle input:checked + span.present-choice {
  background: var(--ok-soft);
  color: var(--ok);
  box-shadow: 0 1px 3px rgba(22,101,52,0.18);
}
.status-toggle input:checked + span.absent-choice {
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: 0 1px 3px rgba(185,28,28,0.18);
}
.attendance-modal .notes-label {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.attendance-modal textarea { min-height: 74px; }

@media (max-width: 980px) {
  .split,
  .dashboard-hero,
  .dashboard-status,
  .filter-row,
  .lookup-bar,
  .profile-grid,
  .form-grid,
  .student-picker-grid,
  .attendance-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  button,
  .btn { min-height: 44px; }
  .panel { padding: 12px; }
  .card-grid { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
  .quick-actions,
  .folder-grid,
  .suggested-strip { grid-template-columns: 1fr; }
  .class-card,
  .attention-item,
  .activity-item { grid-template-columns: 1fr; }
  .table-wrap table { min-width: 640px; }
  .directory-head { align-items: stretch; }
  .directory-head .lookup-bar { width: 100%; }
  .modal-backdrop {
    align-items: stretch;
    padding: 8px;
  }
  .modal {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 12px;
  }
  .modal form > .full.actions {
    bottom: -12px;
    margin-right: -12px;
    margin-bottom: -12px;
    margin-left: -12px;
    padding: 10px 12px 12px;
  }
  .attendance-header { flex-direction: column; }
  .status-toggle span { padding: 10px 8px; }
}
