/*
 * ============================================================
 * SISTEMA VISUAL
 * ============================================================
 *
 * Personalización de marca:
 * cambia únicamente --brand-* en :root.
 *
 * Los componentes consumen tokens semánticos como
 * --primary, --surface y --text, no colores directos.
 */

:root {
    /* Marca */
    --brand-50: #eff6ff;
    --brand-100: #dbeafe;
    --brand-200: #bfdbfe;
    --brand-500: #2563eb;
    --brand-600: #1d4ed8;
    --brand-700: #1e40af;

    /* Superficies */
    --canvas: #eef2f7;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-hover: #f1f5f9;

    /* Texto */
    --text: #334155;
    --text-strong: #0f172a;
    --text-muted: #64748b;
    --text-disabled: #94a3b8;

    /* Bordes y foco */
    --border: #cbd5e1;
    --border-subtle: #e2e8f0;
    --focus: #2563eb;

    /* Acciones */
    --primary: var(--brand-600);
    --primary-hover: var(--brand-700);
    --primary-soft: var(--brand-50);
    --on-primary: #ffffff;

    /* Estados */
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fef2f2;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --warning: #b45309;
    --warning-soft: #fffbeb;

    /* Geometría */
    --radius-control: 0.5rem;
    --radius-panel: 0.75rem;

    /* Sombras */
    --shadow-panel:
        0 1px 2px rgb(15 23 42 / 0.04),
        0 1px 3px rgb(15 23 42 / 0.06);
    --shadow-modal: 0 24px 64px rgb(15 23 42 / 0.22);

    /* Compatibilidad con clases existentes */
    --color-surface: var(--surface);
    --color-surface-alt: var(--surface-subtle);
    --color-on-surface: var(--text);
    --color-on-surface-strong: var(--text-strong);
    --color-primary: var(--primary);
    --color-on-primary: var(--on-primary);
    --color-outline: var(--border);
    --color-outline-strong: var(--text-strong);
    --color-danger: var(--danger);
    --radius-radius: var(--radius-control);
    --font-body: "Inter", ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/*
 * ============================================================
 * BASE
 * ============================================================
 */

 .material-symbols-outlined {
     display: inline-block;
     overflow: hidden;
     font-family: "Material Symbols Outlined";
     font-size: 1.25rem;
     font-style: normal;
     font-weight: normal;
     font-feature-settings: "liga";
     line-height: 1;
     letter-spacing: normal;
     text-transform: none;
     white-space: nowrap;
     word-wrap: normal;
     direction: ltr;
     -webkit-font-feature-settings: "liga";
     -webkit-font-smoothing: antialiased;
     font-variation-settings:
         "FILL" 0,
         "wght" 400,
         "GRAD" 0,
         "opsz" 20;
 }

 .icon-sm {
     font-size: 1rem;
 }

 .icon-lg {
     font-size: 1.5rem;
 }

[x-cloak] {
    display: none !important;
}

html {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    color-scheme: light;
    background: var(--canvas);
}

body {
    min-width: 20rem;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    overflow-y: visible;
    background: var(--canvas);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.875rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    color: var(--text-strong);
    line-height: 1.25;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button,
[role="button"] {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid rgb(37 99 235 / 0.25);
    outline-offset: 2px;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--primary);
}

::selection {
    background: var(--brand-100);
    color: var(--text-strong);
}

/*
 * ============================================================
 * SUPERFICIES
 * ============================================================
 */

.card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-panel);
    background: var(--surface);
    padding: 1rem;
    box-shadow: var(--shadow-panel);
}

.panel-muted {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-panel);
    background: var(--surface-subtle);
    padding: 1rem;
}

/*
 * ============================================================
 * FORMULARIOS
 * ============================================================
 */

.input {
    box-sizing: border-box;
    min-height: 2.625rem;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--text-strong);
    padding: 0.5rem 0.75rem;
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease,
        background-color 150ms ease;
}

.input:hover:not(:disabled) {
    border-color: var(--text-disabled);
}

.input:focus {
    border-color: var(--focus);
    outline: none;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.14);
}

.input::placeholder {
    color: var(--text-muted);
}

.input:disabled {
    cursor: not-allowed;
    background: var(--surface-subtle);
    color: var(--text-disabled);
}

textarea.input {
    min-height: 6rem;
    resize: vertical;
}

/*
 * ============================================================
 * BOTONES
 * ============================================================
 */

.btn-primary,
.btn-outline,
.btn-secondary,
.btn-danger,
.btn-ghost,
.btn-icon {
    box-sizing: border-box;
    display: inline-flex;
    min-height: 2.625rem;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: var(--radius-control);
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    transition:
        background-color 150ms ease,
        border-color 150ms ease,
        color 150ms ease,
        box-shadow 150ms ease;
}

.btn-primary,
.btn-outline,
.btn-secondary,
.btn-danger,
.btn-ghost {
    padding: 0.625rem 0.875rem;
}

.btn-primary {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.08);
}

.btn-primary:hover:not(:disabled) {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.btn-outline {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-strong);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--text-disabled);
    background: var(--surface-subtle);
}

.btn-secondary {
    border: 1px solid var(--brand-100);
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--brand-200);
    background: var(--brand-100);
}

.btn-danger {
    border: 1px solid var(--danger);
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-ghost {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-subtle);
    color: var(--text-strong);
}

.btn-icon {
    width: 2.625rem;
    flex: 0 0 2.625rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0;
}

.btn-icon:hover:not(:disabled) {
    background: var(--surface-subtle);
    color: var(--text-strong);
}

.btn-primary:disabled,
.btn-outline:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-ghost:disabled,
.btn-icon:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    box-shadow: none;
}

/*
 * ============================================================
 * SHELL
 * ============================================================
 */

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    box-sizing: border-box;
    display: flex;
    min-height: 4rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    background: rgb(255 255 255 / 0.94);
    padding: 0.75rem 1rem;
    backdrop-filter: blur(12px);
}

.app-sidebar {
    box-sizing: border-box;
    width: 16rem;
    flex: 0 0 16rem;
    border-right: 1px solid var(--border-subtle);
    background: var(--surface);
    padding: 1rem;
}

.menu-item {
    box-sizing: border-box;
    display: flex;
    min-height: 2.625rem;
    width: 100%;
    cursor: pointer;
    align-items: center;
    gap: 0.75rem;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    padding: 0.625rem 0.75rem;
    color: var(--text);
    font-weight: 500;
    text-align: left;
    transition:
        background-color 150ms ease,
        color 150ms ease;
}

.menu-item:hover {
    background: var(--surface-subtle);
    color: var(--text-strong);
}

.menu-item-active {
    background: var(--primary-soft);
    color: var(--primary-hover);
    font-weight: 700;
}

/*
 * ============================================================
 * PESTAÑAS
 * ============================================================
 */

.tab-list {
    box-sizing: border-box;
    display: flex;
    max-width: 100%;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0.25rem;
    border-radius: calc(var(--radius-control) + 0.125rem);
    background: var(--surface-subtle);
}

.tab {
    box-sizing: border-box;
    display: inline-flex;
    min-height: 2.375rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-strong);
}

.tab-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 3px rgb(15 23 42 / 0.1);
}

/*
 * Algunos componentes de cámara crean internamente video/canvas
 * con z-index propio. Este aislamiento evita que escapen de su panel.
 */
.camera-frame {
    position: relative;
    z-index: 0;
    isolation: isolate;
    overflow: hidden;
    background: #0f172a;
}

.camera-frame js-camera,
.camera-frame video,
.camera-frame canvas,
.camera-frame img {
    position: relative !important;
    z-index: 0 !important;
    display: block;
    width: 100% !important;
    max-width: 100%;
    height: 100% !important;
    object-fit: cover;
}

.modal-backdrop {
    isolation: isolate;
}

/*
 * ============================================================
 * MODALES
 * ============================================================
 */

 .modal-backdrop {
     position: fixed;
     inset: 0;
     z-index: 100;
     display: flex;
     align-items: center;
     justify-content: center;
     overflow: hidden;
     background: rgb(15 23 42 / 0.58);
     padding: clamp(1rem, 3vw, 2rem);
 }

 .modal-panel {
     box-sizing: border-box;
     display: flex;
     width: 100%;
     max-height: calc(100dvh - clamp(2rem, 6vw, 4rem));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-panel);
    background: var(--surface);
    box-shadow: var(--shadow-modal);
}

.modal-header,
.modal-footer {
    box-sizing: border-box;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.75rem;
    padding: 1.125rem 1.5rem;
}

.modal-header {
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    margin: 0;
}

.modal-body {
    box-sizing: border-box;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.5rem;
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-subtle);
}

/*
 * ============================================================
 * LISTAS
 * ============================================================
 */

.list-shell {
    min-width: 0;
}

.list-toolbar {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.list-toolbar-primary,
.list-toolbar-secondary {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 0.5rem;
}

.list-search {
    position: relative;
    width: min(100%, 20rem);
}

.list-search .input {
    padding-left: 2.5rem;
}

.list-search-icon {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
    transform: translateY(-50%);
}

.filter-panel {
    margin-bottom: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-panel);
    background: var(--surface-subtle);
    padding: 1rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.filter-field {
    min-width: 0;
}

.field-label {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 600;
}

.filter-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.table-panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-panel);
    background: var(--surface);
    box-shadow: var(--shadow-panel);
}

.data-table-select-column {
    width: 3rem;
}

.data-table-actions-column {
    width: 5rem;
}

.data-table {
    table-layout: fixed;
}

.data-table th:not(.table-select-cell):not(.table-actions-cell),
.data-table td:not(.table-select-cell):not(.table-actions-cell) {
    min-width: 0;
}

.data-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table th,
.data-table td {
    white-space: nowrap;
}

.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
}

.modal-panel .table-panel {
    box-shadow: none;
}

.modal-panel .data-table th,
.modal-panel .data-table td {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.modal-panel .table-scroll {
    max-height: min(22rem, 45dvh);
    overflow-y: auto;
}

.data-table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    color: var(--text);
    font-size: 0.8125rem;
}

.data-table th {
    position: relative;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-subtle);
    padding: 0.75rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 120ms ease;
}

.data-table tbody tr:hover {
    background: var(--surface-subtle);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-select-cell {
    box-sizing: border-box;
    width: 3rem;
    min-width: 3rem;
    max-width: 3rem;
    padding-right: 0.5rem !important;
    padding-left: 0.5rem !important;
    text-align: center !important;
}

.data-table-cell-content {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table-sortable-heading {
    padding: 0 !important;
}

.data-table-sort-button {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 2.75rem;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border: 0;
    background: transparent;
    padding: 0.75rem;
    color: inherit;
    font: inherit;
    font-weight: 700;
    letter-spacing: inherit;
    text-align: left;
    text-transform: inherit;
    cursor: pointer;
    transition:
        background-color 120ms ease,
        color 120ms ease;
}

.data-table-sort-button:hover {
    background: var(--surface-hover);
    color: var(--primary);
}

.data-table-sort-button:focus-visible {
    z-index: 1;
    outline: 3px solid rgb(37 99 235 / 0.25);
    outline-offset: -3px;
}

.data-table-heading-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table-sort-icon {
    flex: 0 0 auto;
    color: var(--text-disabled);
    font-size: 1rem;
    opacity: 0.55;
    transition:
        color 120ms ease,
        opacity 120ms ease,
        transform 120ms ease;
}

.data-table-sort-button:hover .data-table-sort-icon {
    color: var(--primary);
    opacity: 1;
}

.data-table-sort-icon-active {
    color: var(--primary);
    opacity: 1;
}

.data-table-sorted-heading {
    background: var(--primary-soft) !important;
    color: var(--primary) !important;
}

.data-table-sorted-heading .data-table-sort-button {
    color: var(--primary);
}

.data-table-sorted-heading::after {
    position: absolute;
    right: 0.75rem;
    bottom: 0;
    left: 0.75rem;
    height: 2px;
    border-radius: 999px 999px 0 0;
    background: var(--primary);
    content: "";
}

.data-table th,
.data-table td {
    box-sizing: border-box;
}

.data-table th:first-child,
.data-table td:first-child {
    border-left: 0;
}

.data-table th:last-child,
.data-table td:last-child {
    border-right: 0;
}

.table-panel .data-table {
    margin: 0;
}

.table-actions-cell {
    position: sticky;
    right: 0;
    width: 1%;
    background: inherit;
    white-space: nowrap;
}

.data-table-row-selected {
    background: var(--primary-soft) !important;
}

.data-table-row-selected td {
    color: var(--text-strong);
}

.mobile-record-selected {
    border-color: var(--brand-500);
    box-shadow:
        0 0 0 2px
        rgb(37 99 235 / 0.12);
}

.data-table input[type="radio"],
.mobile-record input[type="radio"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    cursor: pointer;
}


.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.row-action {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-muted);
}

.row-action:hover {
    background: var(--surface-hover);
    color: var(--text-strong);
}

.row-action-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    color: var(--text-muted);
}

.entity-trigger {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-record {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-panel);
    background: var(--surface);
    padding: 1rem;
    box-shadow: var(--shadow-panel);
}

.mobile-record-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
}

.mobile-record-grid {
    display: grid;
    gap: 0.75rem;
}

.mobile-record-field {
    min-width: 0;
}

.mobile-record-label {
    display: block;
    margin-bottom: 0.125rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mobile-record-value {
    overflow-wrap: anywhere;
    color: var(--text-strong);
}

.mobile-record-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.mobile-record-image {
    display: block;
    width: 100%;
    height: 10rem;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: 0.625rem;
    background: var(--surface-subtle);
}

.mobile-record-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-state {
    padding: 3rem 1rem;
    color: var(--text-muted);
    text-align: center;
}

/*
 * ============================================================
 * CONTROL HORARIO
 * ============================================================
 */

.clock-shell {
    display: grid;
    gap: 1rem;
}

.clock-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.5rem;
    padding: clamp(1.25rem, 3vw, 2rem);
}

.clock-date {
    margin: 0 0 0.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: capitalize;
}

.clock-time {
    margin: 0;
    color: var(--text-strong);
    font-size: clamp(2.5rem, 7vw, 4.75rem);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 1;
}

.clock-status {
    display: inline-flex;
    min-height: 2.25rem;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
}

.clock-status::before {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: currentColor;
    content: "";
}

.clock-status-success {
    border-color: #bbf7d0;
    background: var(--success-soft);
    color: var(--success);
}

.clock-status-warning {
    border-color: #fde68a;
    background: var(--warning-soft);
    color: var(--warning);
}

.clock-status-neutral {
    border-color: var(--border-subtle);
    background: var(--surface-subtle);
    color: var(--text-muted);
}

.clock-layout {
    display: grid;
    grid-template-columns: minmax(18rem, 0.9fr) minmax(20rem, 1.1fr);
    gap: 1rem;
    align-items: start;
}

.clock-section {
    min-width: 0;
}

.clock-section-header {
    margin-bottom: 1rem;
}

.clock-section-title {
    margin: 0;
    color: var(--text-strong);
    font-size: 1rem;
    font-weight: 700;
}

.clock-section-description {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.clock-field {
    display: grid;
    gap: 0.375rem;
}

.clock-field + .clock-field {
    margin-top: 1rem;
}

.clock-entity {
    display: flex;
    min-width: 0;
    gap: 0.5rem;
}

.clock-entity-value {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clock-permissions {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.clock-permission {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-radius: var(--radius-control);
    background: var(--surface-subtle);
    padding: 0.625rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.clock-permission-ready {
    color: var(--success);
}

.clock-permission-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.clock-pauses {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.clock-pause {
    display: inline-flex;
    min-height: 2.625rem;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--surface);
    padding: 0.5rem 0.75rem;
    color: var(--text-strong);
    font-weight: 600;
}

.clock-pause:hover {
    border-color: var(--brand-200);
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.clock-pause-image {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    object-fit: cover;
}

.clock-primary-action {
    width: 100%;
    min-height: 3.25rem;
    margin-top: 1.25rem;
    font-size: 1rem;
}

.clock-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.clock-progress {
    height: 0.5rem;
    overflow: hidden;
    border-radius: 999px;
    background: var(--border-subtle);
}

.clock-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

/*
 * ============================================================
 * CHAT Y NOTIFICACIONES
 * ============================================================
 */

.chat-launcher {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 40;
    display: inline-flex;
    width: 3rem;
    height: 3rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--primary);
    border-radius: 999px;
    background: var(--primary);
    color: var(--on-primary);
    box-shadow:
        0 8px 24px rgb(15 23 42 / 0.18),
        0 2px 6px rgb(15 23 42 / 0.12);
}

.chat-launcher:hover {
    background: var(--primary-hover);
}

.chat-launcher-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.chat-launcher-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    display: inline-flex;
    min-width: 1.25rem;
    height: 1.25rem;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    padding: 0 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
}

.chat-popover {
    position: fixed;
    bottom: 4.75rem;
    left: 1rem;
    z-index: 50;
    display: flex;
    width: min(24rem, calc(100vw - 2rem));
    max-height: min(32rem, calc(100dvh - 7rem));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-panel);
    background: var(--surface);
    box-shadow: var(--shadow-modal);
}

.chat-popover-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.875rem 1rem;
}

.chat-popover-title {
    margin: 0;
    color: var(--text-strong);
    font-size: 0.9375rem;
    font-weight: 700;
}

.chat-conversations {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.chat-conversation {
    display: grid;
    width: 100%;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    border: 0;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface);
    padding: 0.875rem 1rem;
    color: var(--text);
    text-align: left;
}

.chat-conversation:last-child {
    border-bottom: 0;
}

.chat-conversation:hover {
    background: var(--surface-subtle);
}

.chat-conversation-unread {
    background: var(--primary-soft);
}

.chat-conversation-icon {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--surface-hover);
    color: var(--primary);
    font-weight: 700;
}

.chat-conversation-content {
    min-width: 0;
}

.chat-conversation-title,
.chat-conversation-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-conversation-title {
    color: var(--text-strong);
    font-size: 0.875rem;
    font-weight: 600;
}

.chat-conversation-preview {
    margin-top: 0.125rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.chat-conversation-date {
    align-self: start;
    color: var(--text-muted);
    font-size: 0.6875rem;
    white-space: nowrap;
}

.chat-empty {
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    text-align: center;
}

.chat-dialog {
    height: min(42rem, calc(100dvh - 2rem));
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--surface-subtle);
}

.chat-message {
    width: fit-content;
    max-width: min(85%, 36rem);
    border: 1px solid var(--border-subtle);
    border-radius: 0.875rem;
    background: var(--surface);
    padding: 0.625rem 0.75rem;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.chat-message-own {
    align-self: flex-end;
    border-color: var(--brand-100);
    background: var(--primary-soft);
}

.chat-message-content {
    color: var(--text-strong);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.chat-message-date {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
}

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-composer .input {
    min-height: 2.625rem;
    max-height: 8rem;
}

/*
 * Toasts
 */

.toast-region {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 130;
    display: grid;
    width: min(24rem, calc(100vw - 2rem));
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.75rem;
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-panel);
    background: var(--surface);
    padding: 0.875rem;
    box-shadow: var(--shadow-modal);
    pointer-events: auto;
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-warning {
    border-left-color: var(--warning);
}

.toast-icon {
    display: inline-flex;
    width: 1.5rem;
    height: 1.5rem;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
}

.toast-success .toast-icon {
    background: var(--success-soft);
    color: var(--success);
}

.toast-error .toast-icon {
    background: var(--danger-soft);
    color: var(--danger);
}

.toast-warning .toast-icon {
    background: var(--warning-soft);
    color: var(--warning);
}

.toast-content {
    min-width: 0;
    padding-top: 0.125rem;
    color: var(--text-strong);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

.toast-close {
    display: inline-flex;
    width: 1.75rem;
    height: 1.75rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-muted);
}

.toast-close:hover {
    background: var(--surface-hover);
    color: var(--text-strong);
}

/*
 * ============================================================
 * LOGIN
 * ============================================================
 */

.login-page {
    position: relative;
    display: grid;
    min-height: 100dvh;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(
            circle at 15% 10%,
            rgb(37 99 235 / 0.12),
            transparent 32rem
        ),
        radial-gradient(
            circle at 90% 90%,
            rgb(29 78 216 / 0.08),
            transparent 28rem
        ),
        var(--canvas);
    padding: clamp(1rem, 4vw, 3rem);
}

.login-page::before {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgb(148 163 184 / 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgb(148 163 184 / 0.07) 1px, transparent 1px);
    background-size: 2rem 2rem;
    content: "";
    pointer-events: none;
    mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.login-shell {
    position: relative;
    z-index: 1;
    width: min(100%, 27rem);
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.login-brand-mark {
    display: inline-flex;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0.875rem;
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 8px 20px rgb(37 99 235 / 0.2);
    font-size: 0.875rem;
    font-weight: 800;
}

.login-brand-name {
    color: var(--text-strong);
    font-size: 1rem;
    font-weight: 700;
}

.login-card {
    border: 1px solid rgb(226 232 240 / 0.9);
    border-radius: 1rem;
    background: rgb(255 255 255 / 0.96);
    padding: clamp(1.25rem, 5vw, 2rem);
    box-shadow:
        0 24px 60px rgb(15 23 42 / 0.12),
        0 2px 8px rgb(15 23 42 / 0.06);
    backdrop-filter: blur(16px);
}

.login-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-title {
    margin: 0;
    color: var(--text-strong);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-subtitle {
    margin: 0.375rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.login-form {
    display: grid;
    gap: 1rem;
}

.login-field {
    display: grid;
    gap: 0.375rem;
}

.login-password {
    position: relative;
}

.login-password .input {
    padding-right: 3rem;
}

.login-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.375rem;
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-muted);
    transform: translateY(-50%);
}

.login-password-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-strong);
}

.login-error {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    border: 1px solid #fecaca;
    border-radius: var(--radius-control);
    background: var(--danger-soft);
    padding: 0.75rem;
    color: var(--danger);
    font-size: 0.8125rem;
}

.login-submit {
    width: 100%;
    min-height: 2.875rem;
    margin-top: 0.25rem;
}

.login-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.login-footer a {
    color: inherit;
    text-decoration: none;
}

.login-footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.login-security {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
}

/*
 * ============================================================
 * RESPONSIVE
 * ============================================================
 */

@media (max-width: 47.999rem) {
    .login-page {
        place-items: start center;
        overflow-y: auto;
        padding: 1.25rem 1rem;
    }

    .login-shell {
        margin: auto 0;
    }

    .login-card {
        padding: 1.25rem;
    }

    .chat-launcher {
        bottom: 1rem;
        left: 1rem;
    }

    .chat-popover {
        right: 1rem;
        left: 1rem;
        width: auto;
    }

    .chat-dialog {
        height: 94dvh;
    }

    .chat-composer {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-composer > button {
        width: 100%;
    }

    .toast-region {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        width: auto;
    }

    .clock-hero {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .clock-layout {
        grid-template-columns: 1fr;
    }

    .clock-summary-grid {
        grid-template-columns: 1fr;
    }

    .clock-entity {
        align-items: stretch;
    }

    .clock-time {
        font-size: clamp(2.5rem, 15vw, 4rem);
    }

    .card {
        padding: 0.875rem;
    }

    .app-header {
        gap: 0.75rem;
        padding: 0.625rem 1rem;
    }

    .app-sidebar {
        width: min(19rem, 84vw);
    }

    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .modal-panel {
        max-height: 94dvh;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 1rem 1rem 0 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .modal-footer > button {
        flex: 1 1 0;
    }

    /*
     * Bloquea el contenido del documento mientras hay un diálogo abierto.
     * Se activa desde Alpine en cada modal.
     */
    body:has(.modal-backdrop[style*="display: flex"]),
    body:has(.modal-backdrop[style*="display: block"]) {
        overflow: hidden;
    }

    /*
     * Fallback para modales antiguos que aún usan .card directamente.
     */
    .modal-scroll-panel {
        box-sizing: border-box;
        display: flex;
        width: 100%;
        max-height: calc(100dvh - clamp(2rem, 6vw, 4rem));
        flex-direction: column;
        overflow: hidden;
        background: var(--surface);
    }

    .modal-scroll-content {
        min-height: 0;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
    }

    .list-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .list-toolbar-primary,
    .list-toolbar-secondary {
        width: 100%;
        flex-wrap: wrap;
    }

    .list-search {
        width: 100%;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column-reverse;
    }

    .filter-actions > button {
        width: 100%;
    }

    .list-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .list-footer-pagination {
        display: flex;
        width: 100%;
    }

    .list-footer-pagination > button {
        flex: 1 1 0;
    }
}

@media (min-width: 48rem) and (max-width: 63.999rem) {
    .clock-layout {
        grid-template-columns: 1fr;
    }

    .clock-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

[data-list-layout="desktop"] {
    display: block !important;
}

[data-list-layout="mobile"] {
    display: none !important;
}

@media screen and (max-width: 1023px) {
    [data-list-layout="desktop"] {
        display: none !important;
    }

    [data-list-layout="mobile"] {
        display: block !important;
        width: 100%;
        min-width: 0;
    }
}
