﻿:root {
      color-scheme: light;
      --bg: #f4f6f8;
      --surface: #ffffff;
      --surface-soft: #eef2f6;
      --border: #d7dee7;
      --text: #17212b;
      --muted: #607080;
      --primary: #146c94;
      --primary-dark: #0f5676;
      --danger: #b42318;
      --success: #16784f;
      --warning: #946200;
      --shadow: 0 10px 28px rgba(23, 33, 43, 0.08);
    }

    * {
      box-sizing: border-box;
    }

    [hidden] {
      display: none !important;
    }

    body.scan-only [data-admin-only] {
      display: none !important;
    }

    body:not(.super-user) [data-super-only] {
      display: none !important;
    }

    body.consulta-only [data-write-only],
    body.consulta-only [data-export-only] {
      display: none !important;
    }

    body {
      margin: 0;
      min-height: 100vh;
      background: var(--bg);
      color: var(--text);
      font-family: Arial, Helvetica, sans-serif;
      font-size: 15px;
      letter-spacing: 0;
    }

    button,
    input,
    select {
      font: inherit;
    }

    button {
      min-height: 38px;
      border: 0;
      border-radius: 6px;
      padding: 0 14px;
      background: var(--primary);
      color: #fff;
      cursor: pointer;
      font-weight: 700;
    }

    button:hover {
      background: var(--primary-dark);
    }

    button.secondary {
      background: var(--surface-soft);
      color: var(--text);
      border: 1px solid var(--border);
    }

    button.secondary:hover {
      background: #e1e7ee;
    }

    button.danger {
      background: #fbe9e7;
      color: var(--danger);
      border: 1px solid #fac7c0;
    }

    button.danger:hover {
      background: #f7d6d0;
    }

    .small-button {
      min-height: 32px;
      padding: 0 10px;
      font-size: 13px;
    }

    input,
    select {
      width: 100%;
      min-height: 40px;
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 8px 10px;
      background: #fff;
      color: var(--text);
    }

    input:focus,
    select:focus {
      outline: 2px solid rgba(20, 108, 148, 0.18);
      border-color: var(--primary);
    }

    label {
      display: grid;
      gap: 6px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .app-shell {
      width: min(1200px, calc(100% - 28px));
      margin: 0 auto;
      padding: 22px 0 36px;
    }

    .login-view {
      min-height: calc(100vh - 120px);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .login-panel {
      width: min(430px, 100%);
    }

    .login-hero {
      display: grid;
      justify-items: center;
      gap: 8px;
      padding: 26px 24px 8px;
      text-align: center;
    }

    .login-logo {
      width: min(300px, 86%);
      height: auto;
      max-height: 116px;
      object-fit: contain;
    }

    .login-hero h2 {
      margin: 6px 0 0;
      font-size: 25px;
      line-height: 1.2;
    }

    .login-hero span {
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .login-panel .panel-body {
      padding: 24px;
    }

    .topbar {
      display: grid;
      gap: 12px;
      margin-bottom: 18px;
    }

    .brand {
      display: grid;
    }

    .brand h1 {
      margin: 0;
      font-size: 28px;
      line-height: 1.2;
    }

    .app-footer {
      margin-top: 28px;
      padding: 18px 0 4px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
      text-align: center;
    }

    .tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      justify-content: flex-start;
      padding: 0;
      background: transparent;
      border: 0;
      border-radius: 0;
    }

    .nav-group,
    .nav-session {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 6px;
      padding: 5px;
      background: var(--surface-soft);
      border: 1px solid var(--border);
      border-radius: 8px;
    }

    .nav-group > span {
      padding: 0 6px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
    }

    .nav-session {
      background: var(--surface);
      margin-left: auto;
    }

    .tab {
      background: transparent;
      color: var(--muted);
      border: 0;
      min-height: 34px;
      white-space: nowrap;
    }

    .tab.active {
      background: var(--surface);
      color: var(--text);
      box-shadow: 0 2px 8px rgba(23, 33, 43, 0.08);
    }

    .nav-session .tab.active,
    #logoutButton {
      background: var(--surface-soft);
      box-shadow: none;
    }

    #logoutButton:hover {
      background: #e1e7ee;
    }

    .session-user {
      display: inline-flex;
      align-items: center;
      min-height: 34px;
      padding: 0 10px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
      white-space: nowrap;
    }

    .dashboard-panel .panel-body {
      display: grid;
      gap: 16px;
    }

    .dashboard-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 12px;
    }

    .dashboard-item {
      min-height: 96px;
      background: #fff;
    }

    .dashboard-item strong {
      font-size: 30px;
    }

    .dashboard-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
    }

    .view {
      display: none;
    }

    .view.active {
      display: block;
    }

    .layout {
      display: grid;
      grid-template-columns: minmax(320px, 420px) 1fr;
      gap: 18px;
      align-items: start;
    }

    .panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      box-shadow: var(--shadow);
    }

    .panel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 16px 18px;
      border-bottom: 1px solid var(--border);
    }

    .panel-header h2 {
      margin: 0;
      font-size: 18px;
      line-height: 1.2;
    }

    .panel-body {
      padding: 18px;
    }

    .form-grid {
      display: grid;
      gap: 14px;
    }

    .two-cols {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }

    .actions {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .photo-row {
      display: grid;
      grid-template-columns: 76px 1fr;
      gap: 12px;
      align-items: center;
    }

    .photo-preview,
    .avatar {
      width: 64px;
      height: 64px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface-soft);
      object-fit: cover;
      display: grid;
      place-items: center;
      color: var(--muted);
      font-weight: 700;
      overflow: hidden;
    }

    .photo-preview img,
    .avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .group-tools {
      display: grid;
      gap: 10px;
      padding-top: 4px;
      border-top: 1px solid var(--border);
    }

    .toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 18px;
      border-bottom: 1px solid var(--border);
    }

    .toolbar input {
      max-width: 320px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
    }

    .table-wrap {
      overflow: auto;
      max-height: min(640px, calc(100vh - 270px));
      border-top: 1px solid var(--border);
    }

    .table-wrap table {
      min-width: 760px;
    }

    .table-wrap th {
      position: sticky;
      top: 0;
      z-index: 2;
      box-shadow: 0 1px 0 var(--border);
    }

    .table-wrap tr:hover td {
      background: #f7fafc;
    }

    .compact-table th,
    .compact-table td {
      padding: 9px 12px;
    }

    .compact-table .student-cell {
      grid-template-columns: 40px 1fr;
      min-width: 220px;
    }

    .compact-table .avatar {
      width: 40px;
      height: 40px;
    }

    .compact-table .student-name {
      gap: 2px;
    }

    .compact-table .student-name span {
      font-size: 12px;
    }

    .compact-table .row-actions button {
      min-height: 30px;
      padding: 0 10px;
      font-size: 12px;
    }

    .compact-table .message-cell {
      min-width: 320px;
      max-width: 520px;
    }

    .import-errors {
      margin-top: 12px;
      max-height: 320px;
    }

    th,
    td {
      padding: 12px 14px;
      border-bottom: 1px solid var(--border);
      text-align: left;
      vertical-align: middle;
    }

    th {
      color: var(--muted);
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 0;
      background: #fafbfc;
    }

    tr:last-child td {
      border-bottom: 0;
    }

    .student-cell {
      display: grid;
      grid-template-columns: 48px 1fr;
      gap: 10px;
      align-items: center;
      min-width: 230px;
    }

    .avatar {
      width: 48px;
      height: 48px;
    }

    .student-name {
      display: grid;
      gap: 3px;
    }

    .student-name strong {
      line-height: 1.25;
    }

    .student-name span,
    .muted {
      color: var(--muted);
      font-size: 13px;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      min-height: 26px;
      border-radius: 999px;
      padding: 0 10px;
      font-size: 12px;
      font-weight: 700;
      background: #e8f5ef;
      color: var(--success);
    }

    .badge.off {
      background: #fbe9e7;
      color: var(--danger);
    }

    .row-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .message {
      min-height: 22px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .message.error {
      color: var(--danger);
    }

    .message.ok {
      color: var(--success);
    }

    .inline-summary {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      width: fit-content;
      min-height: 34px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .inline-summary strong {
      color: var(--text);
      font-size: 16px;
    }

    .whatsapp-body {
      display: grid;
      gap: 18px;
    }

    .whatsapp-summary {
      max-width: 520px;
    }

    .whatsapp-qr {
      display: grid;
      justify-items: start;
    }

    .whatsapp-qr img {
      width: min(320px, 100%);
      aspect-ratio: 1;
      object-fit: contain;
      padding: 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #fff;
    }

    .scanner {
      width: min(980px, 100%);
      margin: 0 auto;
    }

    .kiosk-hint {
      display: inline-flex;
      align-items: center;
      min-height: 28px;
      padding: 0 10px;
      border-radius: 999px;
      background: #e8f5ef;
      color: var(--success);
      font-size: 12px;
      font-weight: 700;
    }

    .kiosk-scanner .panel-header {
      padding: 20px 24px;
    }

    .kiosk-scanner .panel-body {
      padding: 26px;
      display: grid;
      gap: 18px;
    }

    .kiosk-scanner #qr {
      min-height: 76px;
      text-align: center;
      font-size: 34px;
      font-weight: 700;
    }

    .kiosk-scanner .actions {
      justify-content: center;
    }

    .kiosk-scanner button {
      min-height: 44px;
      padding: 0 20px;
    }

    .kiosk-scanner .message {
      text-align: center;
    }

    .kiosk-scanner .scan-status {
      min-height: 48px;
      width: 100%;
      justify-content: center;
      font-size: 17px;
    }

    .kiosk-scanner .queue-status {
      width: 100%;
      justify-content: center;
      text-align: center;
    }

    .kiosk-scanner .attendance-result {
      margin-top: 0;
    }

    .kiosk-scanner .scan-card {
      grid-template-columns: 156px 1fr;
      gap: 22px;
      min-height: 194px;
      padding: 22px;
    }

    .kiosk-scanner .scan-card .avatar {
      width: 156px;
      height: 156px;
    }

    .kiosk-scanner .scan-info h3 {
      font-size: 34px;
    }

    .kiosk-scanner .scan-meta {
      font-size: 16px;
      gap: 10px;
    }

    .scan-status {
      display: inline-flex;
      align-items: center;
      min-height: 32px;
      width: fit-content;
      border-radius: 6px;
      padding: 0 10px;
      background: var(--surface-soft);
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .scan-status.ready {
      background: #e8f5ef;
      color: var(--success);
    }

    .scan-status.busy {
      background: #fff4d6;
      color: #755100;
    }

    .scan-status.error {
      background: #fbe9e7;
      color: var(--danger);
    }

    .queue-status {
      display: inline-flex;
      align-items: center;
      width: fit-content;
      min-height: 32px;
      border-radius: 6px;
      padding: 0 10px;
      background: var(--surface-soft);
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .queue-status.ready {
      background: #eef7f2;
      color: var(--success);
    }

    .queue-status.busy {
      background: #fff4d6;
      color: #755100;
    }

    .queue-status.error {
      background: #fbe9e7;
      color: var(--danger);
    }

    .attendance-config {
      display: grid;
      gap: 10px;
      padding-top: 14px;
      border-top: 1px solid var(--border);
    }

    .attendance-config strong {
      font-size: 14px;
      line-height: 1.2;
    }

    .form-panel {
      width: min(720px, 100%);
    }

    .toolbar-actions {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .toolbar-actions input,
    .toolbar-actions select {
      width: auto;
      min-width: 160px;
    }

    .toolbar-actions button {
      width: auto;
    }

    .toolbar-actions #historyStudent,
    .toolbar-actions #historyStudentSearch,
    .toolbar-actions #bitacoraSearch {
      min-width: 260px;
    }

    .cycle-tables {
      display: grid;
      gap: 16px;
    }

    .message-cell {
      min-width: 260px;
      max-width: 420px;
      white-space: normal;
      line-height: 1.35;
    }

    .summary-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
      gap: 12px;
    }

    .summary-item {
      display: grid;
      gap: 4px;
      min-height: 78px;
      padding: 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #fafbfc;
    }

    .summary-item strong {
      font-size: 24px;
      line-height: 1;
    }

    .summary-item span {
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .status-text {
      display: inline-flex;
      align-items: center;
      min-height: 26px;
      border-radius: 999px;
      padding: 0 9px;
      background: var(--surface-soft);
      font-size: 12px;
      font-weight: 700;
    }

    .status-text.entrada,
    .status-text.salida,
    .status-text.puntual {
      background: #e8f5ef;
      color: var(--success);
    }

    .status-text.retardo {
      background: #fff4d6;
      color: var(--warning);
    }

    .status-text.sin_entrada,
    .status-text.inasistencia {
      background: #fbe9e7;
      color: var(--danger);
    }

    .weekly-table th,
    .weekly-table td {
      text-align: center;
      min-width: 92px;
    }

    .weekly-table th:first-child,
    .weekly-table td:first-child {
      min-width: 260px;
      text-align: left;
      position: sticky;
      left: 0;
      z-index: 1;
      background: #fff;
    }

    .weekly-day {
      display: grid;
      gap: 3px;
      justify-items: center;
    }

    .weekly-day strong {
      text-transform: capitalize;
    }

    .attendance-mark {
      display: grid;
      gap: 4px;
      justify-items: center;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
      min-height: 44px;
      align-content: center;
    }

    .attendance-icon {
      display: inline-grid;
      place-items: center;
      width: 24px;
      height: 24px;
      border-radius: 999px;
      background: var(--surface-soft);
      color: var(--muted);
      font-size: 15px;
      line-height: 1;
    }

    .attendance-mark.entrada .attendance-icon,
    .attendance-mark.salida .attendance-icon {
      background: #e8f5ef;
      color: var(--success);
    }

    .attendance-mark.inasistencia .attendance-icon,
    .attendance-mark.sin_entrada .attendance-icon {
      background: #fbe9e7;
      color: var(--danger);
    }

    .attendance-result {
      margin-top: 16px;
    }

    .scan-card {
      display: grid;
      grid-template-columns: 72px 1fr;
      gap: 12px;
      align-items: center;
      padding: 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #fafbfc;
    }

    .scan-card .avatar {
      width: 72px;
      height: 72px;
    }

    .scan-info {
      display: grid;
      gap: 5px;
    }

    .scan-info h3 {
      margin: 0;
      font-size: 18px;
      line-height: 1.2;
    }

    .scan-meta {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .scan-meta span {
      display: inline-flex;
      align-items: center;
      min-height: 28px;
      padding: 0 9px;
      border-radius: 999px;
      background: var(--surface-soft);
    }

    @media (max-width: 900px) {
      .app-shell {
        width: min(100% - 20px, 1200px);
        padding-top: 14px;
      }

      .layout {
        grid-template-columns: 1fr;
      }

      .toolbar {
        align-items: stretch;
        flex-direction: column;
      }

      .brand h1 {
        font-size: 24px;
      }

      .tabs,
      .toolbar input {
        width: 100%;
      }

      .tabs {
        justify-content: flex-start;
      }

      .nav-group,
      .nav-session {
        width: 100%;
        flex-wrap: wrap;
      }

      .nav-session {
        margin-left: 0;
      }

      .nav-group > span {
        flex-basis: 100%;
        padding-top: 2px;
      }

      .nav-session {
        justify-content: space-between;
      }

      .toolbar-actions,
      .toolbar-actions input,
      .toolbar-actions select,
      .toolbar-actions button {
        width: 100%;
      }

      .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    @media (max-width: 620px) {
      body {
        font-size: 14px;
      }

      button {
        width: 100%;
      }

      .tab,
      #logoutButton {
        width: auto;
        flex: 1 1 96px;
        justify-content: center;
      }

      .nav-session .tab,
      .nav-session #logoutButton {
        flex: 0 0 auto;
      }

      .brand h1 {
        font-size: 22px;
      }

      .two-cols,
      .photo-row {
        grid-template-columns: 1fr;
      }

      .kiosk-scanner #qr {
        min-height: 56px;
        font-size: 22px;
      }

      .kiosk-scanner .scan-card {
        grid-template-columns: 1fr;
        justify-items: center;
        min-height: 0;
        padding: 12px;
        text-align: center;
      }

      .kiosk-scanner .scan-card .avatar {
        width: 112px;
        height: 112px;
      }

      .kiosk-scanner .scan-info h3 {
        font-size: 22px;
      }

      .panel-body,
      .panel-header,
      .toolbar {
        padding: 14px;
      }

      .dashboard-grid,
      .summary-grid {
        grid-template-columns: 1fr;
      }

      .summary-item {
        min-height: 66px;
      }

      .table-wrap {
        max-height: calc(100vh - 260px);
      }

      .table-wrap table {
        min-width: 700px;
      }

      .student-cell {
        min-width: 210px;
      }

      .toolbar-actions #historyStudent,
      .toolbar-actions #historyStudentSearch,
      .toolbar-actions #bitacoraSearch {
        min-width: 0;
      }
    }

