/* TIEMPOCONSERJE.COM — mobile-first */
:root {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --text: #1a2b3c;
    --text-muted: #5a6d7e;
    --primary: #1e5a8a;
    --primary-dark: #16466d;
    --success: #1a7a4a;
    --success-bg: #e8f5ee;
    --warning: #c45c1a;
    --warning-bg: #fef3eb;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --border: #d8e2ec;
    --radius: 14px;
    --shadow: 0 2px 12px rgba(30, 58, 95, 0.08);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    min-height: 100dvh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1e3a5f 0%, #1e5a8a 100%);
    color: #fff;
    box-shadow: var(--shadow);
}

.brand-name {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
}

.header-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.header-nav-spacer {
    pointer-events: none;
}

.back-link {
    color: #fff;
    text-decoration: none;
    font-size: 1.4rem;
    line-height: 1;
}

.header-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: #fff;
    text-decoration: none;
    border-radius: 10px;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.header-logout:active {
    background: rgba(255, 255, 255, 0.15);
}

.header-logout-icon {
    display: block;
}

.app-main {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 16px calc(24px + var(--safe-bottom));
}

.install-page {
    display: flex;
    align-items: center;
    min-height: 100dvh;
    padding-top: 48px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.login-card {
    margin-top: 24px;
}

.page-title {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 700;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 16px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 10px;
    color: var(--text-muted);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-size: 1rem;
    color: var(--text);
}

.input {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    margin-bottom: 4px;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 90, 138, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-secondary {
    background: #e8eef4;
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-sm {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-clock {
    width: 100%;
    min-height: 72px;
    font-size: 1.1rem;
    margin-bottom: 12px;
    border-radius: 16px;
}

.btn-inicio {
    background: var(--success);
    color: #fff;
}

.btn-fin {
    background: var(--warning);
    color: #fff;
}

.btn-icon {
    font-size: 1.2rem;
}

.alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.35s ease, margin 0.35s ease;
    max-height: 120px;
    overflow: hidden;
}

.alert-message {
    flex: 1;
    line-height: 1.4;
}

.alert-close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    font-size: 1.35rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: 0.55;
    color: inherit;
}

.alert-close:hover {
    opacity: 1;
}

.alert--hiding {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.alert-info {
    background: #e8f0fa;
    color: var(--primary);
}

.user-banner {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.user-banner.compact {
    padding: 14px 16px;
}

.user-name {
    margin: 0;
    font-size: 1.2rem;
}

.user-meta {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.clock-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.clock-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}

.clock-svg {
    width: 180px;
    height: 180px;
    margin-bottom: 12px;
    display: block;
}

.clock-svg-num {
    font-size: 11px;
    font-weight: 700;
    fill: #5a6d7e;
    font-family: var(--font);
}

.clock-svg-hand {
    stroke-linecap: round;
}

.clock-svg-hand-hour {
    stroke: #1e5a8a;
    stroke-width: 5;
}

.clock-svg-hand-minute {
    stroke: #2d6a9f;
    stroke-width: 4;
}

.clock-svg-hand-second {
    stroke: #c45c1a;
    stroke-width: 2;
}

.fichaje-form {
    margin: 0 0 12px;
}

.fichaje-time-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.fichaje-time-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.fichaje-time-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
    color: var(--primary);
}

.fichaje-time-display--inicio .fichaje-time-label {
    color: var(--success);
}

.fichaje-time-display--inicio .fichaje-time-value {
    color: var(--success);
}

.fichaje-time-display--fin .fichaje-time-label {
    color: var(--warning);
}

.fichaje-time-display--fin .fichaje-time-value {
    color: var(--warning);
}

.week-nav {
    margin-bottom: 16px;
}

.week-nav-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.week-nav-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
}

.week-nav-range {
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    color: var(--primary);
    line-height: 1.3;
}

.week-nav-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 8px;
    font-size: 1.15rem;
    line-height: 1;
}

.week-nav-btn[aria-disabled="true"] {
    opacity: 0.35;
    pointer-events: none;
}

.week-nav-today {
    display: block;
    margin-top: 12px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.log-filter-advanced {
    margin-bottom: 12px;
}

.log-filter-summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
    list-style: none;
}

.log-filter-summary::-webkit-details-marker {
    display: none;
}

.shift-timer {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 14px 16px;
    margin-bottom: 16px;
    border-radius: 12px;
    background: var(--success-bg);
    border: 1px solid rgba(26, 122, 74, 0.2);
}

.shift-timer--active {
    display: flex;
}

.shift-timer-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--success);
    margin-bottom: 4px;
}

.shift-timer-value {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--success);
    line-height: 1.1;
}

.clock-actions {
    margin-bottom: 0;
}

.btn-clock:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-clock:disabled:active {
    transform: none;
}

.clock-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.section-block {
    margin-bottom: 20px;
}

.section-title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.toggle-icon {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.collapse-panel {
    margin-top: 12px;
}

.day-group {
    margin-bottom: 16px;
}

.day-label {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.fichaje-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fichaje-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}

.fichaje-inicio {
    border-left: 4px solid var(--success);
}

.fichaje-fin {
    border-left: 4px solid var(--warning);
}

.fichaje-time {
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.fichaje-date {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.fichaje-type {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.empty-item {
    color: var(--text-muted);
    padding: 16px;
    text-align: center;
}

.action-bar {
    margin-bottom: 16px;
}

.action-bar .btn {
    width: 100%;
}

.entity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.entity-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.entity-card.inactive {
    opacity: 0.65;
}

.entity-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.entity-meta {
    margin: 2px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.entity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-muted {
    background: #eef2f6;
    color: var(--text-muted);
}

.inline-form {
    display: inline;
}

.page-footer {
    margin-top: 24px;
}

.mt-sm {
    margin-top: 12px;
}

code {
    font-size: 0.85em;
    background: #eef2f6;
    padding: 2px 6px;
    border-radius: 4px;
}
