/* Estilos gerais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f3f5f7;
    color: #24313d;
}

/* Layout principal */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    background: #1f2d3a;
    color: white;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand {
    padding: 8px 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.brand strong {
    display: block;
    font-size: 1.05rem;
}

.brand span {
    display: block;
    margin-top: 3px;
    color: #a9b7c4;
    font-size: 0.82rem;
}

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

.nav-title {
    color: #8fa2b3;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 10px 5px;
}

.nav-link {
    width: 100%;
    color: #e9eef2;
    background: transparent;
    border: 0;
    text-decoration: none;
    padding: 9px 10px;
    border-radius: 6px;
    font: inherit;
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.nav-link:hover,
.nav-link.active {
    background: #2f80ed;
    color: white;
}

.nav-button {
    appearance: none;
}

.badge-menu {
    display: inline-block;
    min-width: 20px;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #e74c3c;
    color: white;
    font-size: 0.75em;
    font-weight: 700;
    text-align: center;
}

.aviso-solicitacoes {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.acoes-solicitacao {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
}

.form-recusa {
    display: flex;
    gap: 6px;
}

.form-recusa input {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
}

.ponto-link-acao {
    font-size: 0.85em;
    white-space: nowrap;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.12);
    padding: 14px 10px 0;
    color: #a9b7c4;
    font-size: 0.85rem;
}

.sidebar-footer span {
    display: block;
}

.sidebar-footer a {
    display: inline-block;
    margin-top: 8px;
    color: white;
    text-decoration: none;
}

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 58px;
    background: white;
    border-bottom: 1px solid #dde3ea;
    padding: 0 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar h1 {
    font-size: 1.1rem;
    font-weight: 650;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #5d6b78;
    font-size: 0.9rem;
}

.standalone-page {
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.nav-brand {
    font-size: 1.1em;
    font-weight: bold;
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.3s;
    font-size: 0.85em;
    white-space: nowrap;
}

.nav-links a:hover {
    background-color: #34495e;
}

.nav-user {
    color: #95a5a6;
    font-size: 0.85em;
}

.btn-logout {
    background-color: #e74c3c !important;
    padding: 5px 10px !important;
    font-size: 0.85em !important;
}

.btn-logout:hover {
    background-color: #c0392b !important;
}

.btn-nav {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    text-decoration: none;
}

.btn-nav:hover {
    background-color: #219a52;
}

/* Container */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 26px;
}

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: white;
    padding: 18px;
    border-radius: 8px;
    text-align: left;
    border: 1px solid #dde3ea;
    box-shadow: none;
}

.cards .card h3 {
    font-size: 2em;
    margin-bottom: 8px;
}

/* Cards de conteudo soltos na pagina (empresa, AFD, registros abertos) */
.container > .card {
    margin-bottom: 20px;
}

.container > .card h2 {
    font-size: 1.25rem;
    margin-bottom: 14px;
}

.container > .card h3 {
    margin: 18px 0 10px;
}

.card p {
    color: #7f8c8d;
}

.card-success { border-left: 4px solid #27ae60; }
.card-info { border-left: 4px solid #3498db; }
.card-warning { border-left: 4px solid #f39c12; }
.card-danger { border-left: 4px solid #e74c3c; }

.dashboard-card-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.dashboard-card-link:hover,
.dashboard-card-link.active {
    border-color: #9fb1c3;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.dashboard-card-link.active h3,
.dashboard-card-link:hover h3 {
    color: #0f2438;
}

/* Tabela */
.table {
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dde3ea;
    box-shadow: none;
    border-collapse: collapse;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
}

.table th {
    background-color: #f8fafc;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #53616e;
}

.table td {
    padding: 12px 15px;
    border-bottom: 1px solid #edf1f4;
}

.table tr.entrada td { color: #27ae60; }
.table tr.saida td { color: #e74c3c; }

.time-grid-table {
    table-layout: fixed;
    min-width: 640px;
}

/* Com funcionario + observacao: 110 + 180 + 220 + entrada/saida/aberto */
.time-grid-table.grade-com-obs {
    min-width: 760px;
}

/* Com botoes Editar/Excluir: 110 + 180 + 56 (obs. em icone) + entrada/saida/aberto */
.time-grid-table.grade-com-acoes {
    min-width: 760px;
}

.time-grid-table.grade-com-acoes th,
.time-grid-table.grade-com-acoes td {
    padding-left: 10px;
    padding-right: 10px;
}

.time-grid-table col.col-data { width: 110px; }
.time-grid-table col.col-funcionario { width: 180px; }
.time-grid-table col.col-observacao { width: 220px; }
.time-grid-table col.col-observacao-icone { width: 56px; }
.time-grid-table col.col-hora { width: 150px; }
.time-grid-table.grade-com-acoes col.col-hora { width: 210px; }
.time-grid-table col.col-aberto { width: 130px; }

/* Um par entrada/saida por linha: separacao mais forte so quando o dia muda */
.table tr.dia-continua td { border-top: none; }
.table tbody tr.dia-inicio:not(:first-child) td { border-top: 2px solid #d5dde5; }

/* Observacao em icone: o texto aparece num balao ao passar o mouse ou tocar */
.obs-icone {
    position: relative;
    display: inline-flex;
    color: #2f526d;
    cursor: help;
    outline: none;
}
.obs-icone::after {
    content: attr(data-texto);
    position: absolute;
    right: calc(100% + 8px);
    top: -6px;
    z-index: 20;
    width: max-content;
    max-width: min(280px, calc(100vw - 40px));
    padding: 8px 10px;
    border-radius: 6px;
    background: #24313d;
    color: white;
    font-size: 0.85rem;
    line-height: 1.35;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s;
}
.obs-icone:hover::after,
.obs-icone:focus::after {
    opacity: 1;
    visibility: visible;
}
.obs-icone:focus-visible { box-shadow: 0 0 0 2px #3498db; border-radius: 4px; }

.time-grid-table th,
.time-grid-table td {
    vertical-align: top;
}

.time-grid-table td {
    overflow-wrap: anywhere;
}

.time-grid-table th,
.time-grid-table td {
    padding-left: 12px;
    padding-right: 12px;
}

.time-grid-table .date-cell {
    color: #53616e;
    font-weight: 600;
    white-space: nowrap;
}

.mark-cell {
    font-variant-numeric: tabular-nums;
    color: #24313d;
}

.mark-entry .time-value {
    color: #15803d;
}

.mark-exit .time-value,
.mark-open .time-value {
    color: #b42318;
}

.marca-ajuste {
    display: inline-block;
    padding: 0 5px;
    border-radius: 8px;
    background: #fff4e5;
    color: #b54708;
    font-size: 0.75em;
    font-weight: 600;
    cursor: help;
}

.time-cell-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.time-cell-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px 8px;
    min-height: 24px;
}

.time-value {
    white-space: nowrap;
    font-weight: 600;
}

.time-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.time-actions form {
    display: inline;
}

.btn-icon {
    border: 1px solid #d8e0e8;
    background: #f8fafc;
    color: #2f526d;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-icon:hover {
    background: #e9f2fb;
}

.btn-icon-danger {
    color: #b42318;
}

.btn-icon-danger:hover {
    background: #fde7e7;
}

.muted {
    color: #9aa7b2;
}

.nowrap {
    white-space: nowrap;
}

/* Relatorio diario: cada horario/total fica inteiro; lista de horarios quebra na virgula */
.report-table th,
.report-table td {
    padding-left: 10px;
    padding-right: 10px;
}

.report-table td {
    white-space: nowrap;
}

.report-table td.col-horarios {
    white-space: normal;
    min-width: 90px;
}

.report-table .col-nome {
    white-space: normal;
    min-width: 180px;
}

/* Nome de arquivo longo nao alarga a coluna */
.file-link {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Badges */
.badge {
    display: inline-block;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Formularios */
.filter-form {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #dde3ea;
    box-shadow: none;
}

.form-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row + .form-row {
    margin-top: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-wide {
    min-width: 280px;
    flex: 1;
}

.form-actions-inline {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: max-content;
}

.form-group label {
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #555;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
}

/* Botoes */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1em;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
}

.btn-primary { background-color: #3498db; color: white; }
.btn-primary:hover { background-color: #2980b9; }

.btn-block { width: 100%; }

/* Alertas */
.alert {
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-success { background: #d4edda; color: #155724; }
.alert-danger { background: #f8d7da; color: #721c24; }
.alert-warning { background: #fff3cd; color: #856404; }
.alert-info { background: #d1ecf1; color: #0c5460; }

/* Login */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
}

.login-card h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.login-card .subtitle {
    color: #7f8c8d;
    margin-bottom: 30px;
}

.login-card .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-card .form-group input {
    width: 100%;
}

/* Utilitarios */
.text-center { text-align: center; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 8px 0 12px;
}

.section-header span {
    color: #6b7b88;
    font-size: 0.86rem;
}

.dashboard-cards {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.subtitle {
    color: #6b7b88;
    margin-bottom: 16px;
}

/* Formularios em grade (empresa, AFD) */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.form-grid .small input {
    max-width: 90px;
}

.form-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 20px;
    margin-bottom: 10px;
}

/* Card Formulario */
.card-form {
    background: white;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #dde3ea;
    box-shadow: none;
}

.card-form h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.form-buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.btn-success { background-color: #27ae60; color: white; }
.btn-success:hover { background-color: #219a52; }
.btn-secondary { background-color: #95a5a6; color: white; }
.btn-secondary:hover { background-color: #7f8c8d; }
.btn-sm { padding: 5px 10px; font-size: 0.85em; }

.actions { white-space: nowrap; }
.actions form { display: inline; }
.actions.actions-wrap { white-space: normal; min-width: 150px; }
.actions-wrap .btn { margin: 2px 0; }

.schedule-table input[type="time"],
.schedule-table input[type="text"] {
    width: 100%;
}

.schedule-table th:first-child,
.schedule-table th:nth-child(4),
.schedule-table td:first-child,
.schedule-table td:nth-child(4) {
    text-align: center;
    width: 90px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    position: relative;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.close:hover { color: #333; }

/* Botao bloquear */
.btn-danger { background-color: #e74c3c; color: white; }
.btn-danger:hover { background-color: #c0392b; }
.btn-warning { background-color: #f39c12; color: white; }
.btn-warning:hover { background-color: #d68910; }

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        position: static;
        gap: 10px;
    }

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

    .nav-title {
        grid-column: 1 / -1;
    }

    .sidebar-footer {
        margin-top: 0;
    }

    .topbar {
        padding: 12px 16px;
        align-items: flex-start;
        flex-direction: column;
    }

    .container {
        padding: 16px;
    }

    .form-row {
        align-items: stretch;
    }

    .form-group,
    .form-group input,
    .form-group select,
    .form-row .btn,
    .form-grid .btn {
        width: 100%;
    }

    .form-group input[type="checkbox"] {
        width: auto;
    }

    .form-actions-inline {
        width: 100%;
        min-width: 0;
        flex-wrap: wrap;
    }

    .table th,
    .table td {
        padding: 10px;
    }
}

/* Painel do funcionario */
.ponto-container { max-width: 440px; width: 100%; padding: 0 16px; }
.ponto-container .login-card { padding: 32px 24px; border-radius: 12px; }
.ponto-nome { font-size: 1.2em; font-weight: 600; text-align: center; margin-bottom: 8px; }
.ponto-relogio { font-size: 3em; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.ponto-data { text-align: center; color: #7f8c8d; margin-bottom: 20px; }
.ponto-data::first-letter { text-transform: uppercase; }
.btn-ponto {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 1.25em; font-weight: 600; padding: 18px; margin-bottom: 24px;
    border-radius: 10px; color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: filter 0.15s, transform 0.1s;
}
.btn-ponto:hover { filter: brightness(0.92); }
.btn-ponto:active { transform: scale(0.98); }
.btn-ponto:disabled { opacity: 0.7; cursor: wait; }
.btn-ponto .ponto-icone { width: 26px; height: 26px; }
.btn-ponto-entrada { background-color: #27ae60; }
.btn-ponto-saida { background-color: #e74c3c; }
.ponto-subtitulo { margin: 10px 0 12px; font-size: 1em; color: #5d6d7e; }

/* Linha do tempo do dia */
.ponto-linha { list-style: none; position: relative; margin-bottom: 8px; text-align: left; }
.ponto-linha::before {
    content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px;
    width: 2px; background: #dfe4ea;
}
.ponto-etapa { position: relative; display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.ponto-marcador {
    --cor: #95a5a6; --cor-halo: rgba(149, 165, 166, 0.2);
    flex: none; width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: white; border: 2px solid #dfe4ea; color: #b2bec3;
}
.ponto-marcador .ponto-icone { width: 18px; height: 18px; }
.tipo-entrada .ponto-marcador { --cor: #27ae60; --cor-halo: rgba(39, 174, 96, 0.2); }
.tipo-saida .ponto-marcador { --cor: #e74c3c; --cor-halo: rgba(231, 76, 60, 0.2); }
.ponto-etapa.feita .ponto-marcador { background: var(--cor); border-color: var(--cor); color: white; }
.ponto-etapa.proxima .ponto-marcador { border-color: var(--cor); color: var(--cor); box-shadow: 0 0 0 4px var(--cor-halo); }
.ponto-etapa-rotulo { flex: 1; }
.ponto-etapa.feita .ponto-etapa-rotulo,
.ponto-etapa.proxima .ponto-etapa-rotulo { font-weight: 600; }
.ponto-etapa.pendente .ponto-etapa-rotulo,
.ponto-etapa.pendente .ponto-etapa-hora { color: #aab4be; }
.ponto-etapa-hora { font-variant-numeric: tabular-nums; }
.ponto-etapa.proxima .ponto-etapa-hora { color: #7f8c8d; font-style: italic; }
.ponto-concluida { text-align: center; color: #27ae60; font-weight: 600; margin: 8px 0; }

/* Confirmacao da batida */
.ponto-confirmacao {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 16px; margin-bottom: 20px; border-radius: 10px; text-align: center;
    background: #e8f8ef; border: 1px solid #a9dfbf; color: #1e8449;
    animation: ponto-surgir 0.3s ease-out;
}
.ponto-confirmacao-check {
    width: 40px; height: 40px; border-radius: 50%; background: #27ae60; color: white;
    display: flex; align-items: center; justify-content: center; font-size: 1.4em;
}
.ponto-confirmacao strong { font-size: 1.1em; }
.ponto-confirmacao small { color: #52796f; }
@keyframes ponto-surgir { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.ponto-links { display: flex; gap: 8px; margin-top: 20px; }
.ponto-link {
    flex: 1; text-align: center; padding: 10px 6px; border-radius: 8px;
    border: 1px solid #dfe4ea; color: #34495e; text-decoration: none; font-size: 0.9em;
}
.ponto-link:hover { background: #f3f5f7; }

/* Telas de lista do funcionario (meus registros, solicitacoes): cartao largo no PC */
.ponto-container.ponto-container-largo { max-width: 920px; }
.ponto-container-largo .login-card { text-align: left; }
.ponto-container-largo .login-card h1,
.ponto-container-largo .login-card .subtitle { text-align: center; }
.ponto-lista-topo {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.ponto-lista-topo .ponto-nome { margin: 0 0 6px; text-align: left; }
.ponto-lista-topo .ponto-filtro-mes { margin: 0; min-width: 220px; }
.ponto-tabela { font-variant-numeric: tabular-nums; }
.ponto-tabela td { vertical-align: middle; }
.ponto-tabela-acao { text-align: right; white-space: nowrap; }
.ponto-btn-corrigir {
    background: white; color: #2471a3; border: 1px solid #aed6f1; text-decoration: none;
}
.ponto-btn-corrigir:hover { background: #ebf5fb; }
.ponto-vazio { color: #7f8c8d; text-align: center; padding: 24px 0; }
.ponto-links-lista .ponto-link-destaque {
    background: #95a5a6; border-color: #95a5a6; color: white; font-weight: 600;
}
.ponto-links-lista .ponto-link-destaque:hover { background: #7f8c8d; }

@media (max-width: 600px) {
    .ponto-container-largo .login-card { padding: 24px 14px; }
    .ponto-lista-topo { flex-direction: column; align-items: stretch; }
    .ponto-lista-topo .ponto-nome { text-align: center; }
    .ponto-links-lista { flex-direction: column; }
    .ponto-tabela th, .ponto-tabela td { padding: 8px 6px; font-size: 0.9em; }
    .ponto-tabela td:first-child { white-space: nowrap; }
    .ponto-tabela-acao { white-space: normal; }
    .ponto-btn-corrigir { white-space: normal; line-height: 1.2; padding: 4px 6px; text-align: center; }
}
.ponto-link-sair { color: #c0392b; }
