/* ==========================================================================
   PONTO VIP — painel administrativo
   Identidade: sala de controle. Cromo azul-tinta, conteúdo em papel frio,
   e todo dado de tempo em fonte monoespaçada — porque um espelho de ponto é,
   antes de tudo, uma coluna de horários alinhados.
   ========================================================================== */

:root {
    /* Cromo (navegação, cabeçalhos) */
    --ink-900: #0C1524;
    --ink-800: #101C2E;
    --ink-700: #18263C;
    --ink-600: #23344E;
    --ink-fade: #8095B0;

    /* Conteúdo */
    --paper:     #EDF1F6;
    --surface:   #FFFFFF;
    --surface-2: #F6F9FC;
    --line:      #DBE3ED;
    --line-2:    #EAEFF6;

    --text:   #101B2B;
    --text-2: #48586D;
    --text-3: #7A8AA0;

    /* A cor da marca é a cor do "agora" — o que está acontecendo neste
       instante aparece em ciano no painel inteiro. */
    --brand:    #0C9FB8;
    --brand-dk: #077A8D;
    --brand-bg: #E1F5F8;

    --ok:    #12A150;  --ok-bg:    #E5F6EC;
    --warn:  #BF6E06;  --warn-bg:  #FCF1DE;
    --bad:   #D02B39;  --bad-bg:   #FCE8EA;
    --extra: #6244EE;  --extra-bg: #EDE9FE;
    --muted: #8494A8;  --muted-bg: #EFF3F8;

    --radius:    10px;
    --radius-sm: 6px;
    --shadow:    0 1px 2px rgba(16, 27, 43, .05), 0 8px 20px -14px rgba(16, 27, 43, .28);
    --shadow-lg: 0 12px 40px -18px rgba(16, 27, 43, .45);

    --sans: "Archivo", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;

    --sidebar: 250px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dk); text-underline-offset: 2px; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -.015em; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }

/* Todo número que representa tempo usa a monoespaçada. */
.num, .time, td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   ESTRUTURA
   ========================================================================== */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex: 0 0 var(--sidebar);
    background: var(--ink-900);
    color: #C8D6E8;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar__mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(150deg, var(--brand) 0%, var(--brand-dk) 100%);
    display: grid; place-items: center;
    color: #fff; font-size: 16px; flex: none;
}
.sidebar__name { font-weight: 600; color: #fff; font-size: 14.5px; line-height: 1.15; }
.sidebar__sub  { font-size: 11px; color: var(--ink-fade); letter-spacing: .06em; text-transform: uppercase; }

.sidebar__nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar__label {
    font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
    color: #62789A; padding: 14px 8px 6px; font-weight: 500;
}
.sidebar__link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: #B9C9DC; text-decoration: none; font-size: 14px;
    transition: background .12s, color .12s;
}
.sidebar__link i { font-size: 15px; width: 18px; text-align: center; opacity: .85; }
.sidebar__link:hover { background: var(--ink-700); color: #fff; }
.sidebar__link.is-active { background: var(--ink-600); color: #fff; font-weight: 500; }
.sidebar__link.is-active i { color: var(--brand); opacity: 1; }

.sidebar__foot {
    padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .07);
    font-size: 12.5px; color: var(--ink-fade);
    display: flex; align-items: center; gap: 10px;
}
.sidebar__avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    background: var(--ink-600); color: #DCE7F3;
    display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
}
.sidebar__foot a { color: #93A6BE; text-decoration: none; }
.sidebar__foot a:hover { color: #fff; }

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 14px 26px;
    display: flex; align-items: center; gap: 18px;
    position: sticky; top: 0; z-index: 20;
}
.topbar__title h1 { font-size: 19px; }
.topbar__title p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-3); }
.topbar__spacer { flex: 1; }
.topbar__clock {
    font-family: var(--mono); font-size: 20px; font-weight: 500;
    letter-spacing: -.02em; color: var(--text);
}
.topbar__date { font-size: 11.5px; color: var(--text-3); text-align: right; text-transform: capitalize; }

.content { padding: 22px 26px 60px; }

.menu-toggle { display: none; }

/* ==========================================================================
   CARTÕES E BLOCOS
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card__head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-2);
    display: flex; align-items: center; gap: 12px;
}
.card__head h2 { font-size: 14.5px; font-weight: 600; }
.card__head p  { margin: 0; font-size: 12px; color: var(--text-3); }
.card__head .spacer { flex: 1; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar-right { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ==========================================================================
   FAIXA DE INDICADORES
   ========================================================================== */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.stat {
    padding: 15px 18px;
    border-right: 1px solid var(--line-2);
    min-width: 0;
}
.stat:last-child { border-right: 0; }
.stat__label {
    font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-3); font-weight: 500;
    display: flex; align-items: center; gap: 6px;
}
.stat__value {
    font-family: var(--mono); font-variant-numeric: tabular-nums;
    font-size: 25px; font-weight: 500; letter-spacing: -.03em;
    margin-top: 4px; line-height: 1.1;
}
.stat__foot { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.stat--ok    .stat__value { color: var(--ok); }
.stat--warn  .stat__value { color: var(--warn); }
.stat--bad   .stat__value { color: var(--bad); }
.stat--extra .stat__value { color: var(--extra); }
.stat--live  .stat__value { color: var(--brand); }

/* ==========================================================================
   RÉGUA DO DIA — o espelho de ponto ao vivo (elemento-assinatura)
   Cada linha é um funcionário; a trilha clara é a jornada prevista e as
   barras sólidas são o tempo realmente trabalhado, carimbado por cima.
   ========================================================================== */

.rail { --rail-left: 190px; }

.rail__scale {
    display: grid;
    grid-template-columns: var(--rail-left) 1fr;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.rail__scale-ticks { position: relative; height: 26px; }
.rail__tick {
    position: absolute; top: 0; bottom: 0;
    border-left: 1px solid var(--line-2);
    font-family: var(--mono); font-size: 10.5px; color: var(--text-3);
    padding-left: 4px; padding-top: 5px;
}

.rail__row {
    display: grid;
    grid-template-columns: var(--rail-left) 1fr;
    align-items: center;
    border-bottom: 1px solid var(--line-2);
    min-height: 44px;
}
.rail__row:last-child { border-bottom: 0; }
.rail__row:hover { background: var(--surface-2); }

.rail__who {
    padding: 6px 14px 6px 18px;
    display: flex; align-items: center; gap: 9px;
    min-width: 0;
}
.rail__name {
    font-size: 13px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-decoration: none; color: var(--text);
}
.rail__name:hover { color: var(--brand-dk); }
.rail__meta { font-size: 11px; color: var(--text-3); }

.rail__track {
    position: relative; height: 44px;
    border-left: 1px solid var(--line-2);
}
/* trilha da jornada prevista */
.rail__plan {
    position: absolute; top: 50%; transform: translateY(-50%);
    height: 16px; border-radius: 3px;
    background: repeating-linear-gradient(
        -45deg, var(--line-2) 0 5px, #F3F6FA 5px 10px);
    border: 1px solid var(--line);
}
/* tempo efetivamente trabalhado */
.rail__worked {
    position: absolute; top: 50%; transform: translateY(-50%);
    height: 16px; border-radius: 3px;
    background: var(--ok);
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .12);
}
.rail__worked--open {
    background: linear-gradient(90deg, var(--brand) 65%, rgba(12, 159, 184, .25) 100%);
}
.rail__worked--extra { background: var(--extra); }
/* atraso: o vão entre o início previsto e a chegada */
.rail__late {
    position: absolute; top: 50%; transform: translateY(-50%);
    height: 16px; border-radius: 3px;
    background: repeating-linear-gradient(
        -45deg, var(--warn) 0 3px, #D98B26 3px 6px);
    opacity: .85;
}
.rail__now {
    position: absolute; top: 0; bottom: 0; width: 1px;
    background: var(--bad);
}
.rail__now::after {
    content: ''; position: absolute; top: -1px; left: -2.5px;
    width: 6px; height: 6px; border-radius: 50%; background: var(--bad);
}
.rail__flag {
    position: absolute; top: 50%; transform: translate(-50%, -50%);
    font-family: var(--mono); font-size: 10px; color: var(--text-3);
    white-space: nowrap;
}
.rail__empty {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    font-size: 12px; color: var(--text-3);
}

.rail__legend {
    display: flex; flex-wrap: wrap; gap: 14px;
    padding: 10px 18px; border-top: 1px solid var(--line-2);
    font-size: 11.5px; color: var(--text-3);
}
.rail__legend span { display: inline-flex; align-items: center; gap: 6px; }
.rail__legend i {
    width: 18px; height: 9px; border-radius: 2px; display: inline-block;
}

/* ==========================================================================
   TABELAS
   ========================================================================== */

.table-wrap { overflow-x: auto; }

table.tbl {
    width: 100%; border-collapse: collapse; font-size: 13.5px;
}
table.tbl th {
    text-align: left; font-weight: 500; font-size: 11px;
    letter-spacing: .07em; text-transform: uppercase; color: var(--text-3);
    padding: 10px 14px; border-bottom: 1px solid var(--line);
    white-space: nowrap; background: var(--surface-2);
}
table.tbl td {
    padding: 10px 14px; border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl .right { text-align: right; }
table.tbl .center { text-align: center; }
.tbl--compact td, .tbl--compact th { padding: 7px 12px; }

.row-muted td { color: var(--text-3); }

.empty {
    padding: 34px 18px; text-align: center; color: var(--text-3); font-size: 13px;
}
.empty i { display: block; font-size: 26px; margin-bottom: 8px; opacity: .4; }

/* ==========================================================================
   ELEMENTOS
   ========================================================================== */

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    background: var(--ink-700); color: #DCE7F3;
    display: grid; place-items: center;
    font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
    object-fit: cover; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 62px; height: 62px; font-size: 20px; }
.person__name { font-weight: 500; }
.person__meta { font-size: 11.5px; color: var(--text-3); }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 500; line-height: 1.6;
    background: var(--muted-bg); color: var(--text-2);
    white-space: nowrap;
}
.badge--ok    { background: var(--ok-bg);    color: var(--ok); }
.badge--warn  { background: var(--warn-bg);  color: var(--warn); }
.badge--bad   { background: var(--bad-bg);   color: var(--bad); }
.badge--info  { background: var(--brand-bg); color: var(--brand-dk); }
.badge--extra { background: var(--extra-bg); color: var(--extra); }
.badge--live  { background: var(--brand-bg); color: var(--brand-dk); }
.badge--live::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--brand); animation: blink 1.6s ease-in-out infinite;
}
.badge--muted { background: var(--muted-bg); color: var(--muted); }
@keyframes blink { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }

.dot-status {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block;
    background: var(--muted);
}
.dot-status--ok { background: var(--ok); }
.dot-status--bad { background: var(--bad); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 13.5px; font-weight: 500;
    cursor: pointer; text-decoration: none;
    transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #C6D2E0; }
.btn--primary {
    background: var(--ink-800); border-color: var(--ink-800); color: #fff;
}
.btn--primary:hover { background: var(--ink-700); border-color: var(--ink-700); }
.btn--brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--brand:hover { background: var(--brand-dk); border-color: var(--brand-dk); }
.btn--danger { color: var(--bad); border-color: #F0C9CD; background: #FEF6F7; }
.btn--danger:hover { background: var(--bad-bg); }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--icon { padding: 6px 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Formulários */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > label {
    font-size: 11.5px; font-weight: 500; color: var(--text-2);
    letter-spacing: .02em;
}
.field .hint { font-size: 11.5px; color: var(--text-3); }
.input, .select, textarea.input {
    width: 100%; padding: 8px 11px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 13.5px;
}
.input:focus, .select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-bg); }
.input[type="time"], .input[type="date"] { font-family: var(--mono); }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 150px; margin-bottom: 13px; }

.filters {
    display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
}
.filters .field { margin-bottom: 0; }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkline input { width: 16px; height: 16px; accent-color: var(--brand); }

/* Avisos */
.alert {
    padding: 11px 15px; border-radius: var(--radius-sm);
    font-size: 13.5px; margin-bottom: 16px;
    border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start;
}
.alert--ok   { background: var(--ok-bg);   color: #0B6E37; border-color: #BFE6CE; }
.alert--bad  { background: var(--bad-bg);  color: #96202B; border-color: #F3C6CB; }
.alert--warn { background: var(--warn-bg); color: #8A5006; border-color: #EFD9AE; }
.alert--info { background: var(--brand-bg); color: var(--brand-dk); border-color: #B8E4EC; }

/* Barra de progresso fina, usada em rankings */
.meter { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.meter--warn > span { background: var(--warn); }
.meter--bad  > span { background: var(--bad); }
.meter--ok   > span { background: var(--ok); }

/* Calendário do espelho de ponto individual */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.calendar__dow {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-3); text-align: center; padding-bottom: 4px; font-weight: 500;
}
.calendar__day {
    aspect-ratio: 1 / .82;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-2);
    background: var(--surface-2);
    padding: 5px 6px;
    display: flex; flex-direction: column; justify-content: space-between;
    text-decoration: none; color: inherit;
    min-height: 52px;
}
.calendar__day span.d { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.calendar__day b { font-family: var(--mono); font-size: 11.5px; font-weight: 500; }
.calendar__day--ok      { background: var(--ok-bg);    border-color: #C9E9D6; }
.calendar__day--ok b    { color: var(--ok); }
.calendar__day--atraso  { background: var(--warn-bg);  border-color: #EFDCB4; }
.calendar__day--atraso b{ color: var(--warn); }
.calendar__day--falta   { background: var(--bad-bg);   border-color: #F2CDD1; }
.calendar__day--falta b { color: var(--bad); }
.calendar__day--abonado { background: var(--extra-bg); border-color: #D6CDFB; }
.calendar__day--abonado b { color: var(--extra); }
.calendar__day--feriado { background: var(--brand-bg); border-color: #BCE3EB; }
.calendar__day--feriado b { color: var(--brand-dk); }
.calendar__day--incompleto { background: var(--warn-bg); border-color: #EFDCB4; }
.calendar__day--em_curso   { background: var(--brand-bg); border-color: #BCE3EB; }
.calendar__day--em_curso b { color: var(--brand-dk); }
.calendar__day--out { opacity: .32; }

/* Mini régua dentro da tabela do espelho */
.minirail {
    position: relative; height: 14px; min-width: 150px;
    background: var(--line-2); border-radius: 3px; overflow: hidden;
}
.minirail__plan   { position: absolute; top: 0; bottom: 0; background: #E3E9F1; }
.minirail__worked { position: absolute; top: 0; bottom: 0; background: var(--ok); }
.minirail__worked--open { background: var(--brand); }
.minirail__late   { position: absolute; top: 0; bottom: 0; background: var(--warn); opacity: .8; }

/* Janela modal simples */
dialog.modal {
    border: 0; border-radius: var(--radius); padding: 0;
    box-shadow: var(--shadow-lg); width: min(680px, calc(100vw - 32px));
    color: var(--text); background: var(--surface);
}
dialog.modal::backdrop { background: rgba(12, 21, 36, .5); backdrop-filter: blur(2px); }
dialog.modal .card__head { border-radius: var(--radius) var(--radius) 0 0; }
dialog.modal .modal__foot {
    padding: 14px 18px; border-top: 1px solid var(--line-2);
    display: flex; justify-content: flex-end; gap: 8px;
    background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius);
}

/* Grade de horários da jornada */
.week { display: grid; gap: 6px; }
.week__row {
    display: grid;
    grid-template-columns: 92px 62px repeat(4, minmax(0, 1fr));
    gap: 8px; align-items: center;
}
.week__row--head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
.week__day { font-size: 13px; font-weight: 500; }

.chart-box { position: relative; height: 240px; }
.chart-box--sm { height: 180px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a {
    padding: 9px 14px; font-size: 13.5px; text-decoration: none;
    color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.is-active { color: var(--text); border-bottom-color: var(--brand); font-weight: 500; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

.text-muted { color: var(--text-3); }
.text-ok    { color: var(--ok); }
.text-warn  { color: var(--warn); }
.text-bad   { color: var(--bad); }
.text-extra { color: var(--extra); }
.text-brand { color: var(--brand-dk); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 } .mt-2 { margin-top: 8px } .mt-3 { margin-top: 16px }
.mb-0 { margin-bottom: 0 } .mb-2 { margin-bottom: 8px } .mb-3 { margin-bottom: 16px }

/* ==========================================================================
   RESPONSIVO
   ========================================================================== */

@media (max-width: 1100px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--sidebar-right { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed; z-index: 60; left: 0; top: 0;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
    body.nav-open::after {
        content: ''; position: fixed; inset: 0; background: rgba(12, 21, 36, .45); z-index: 55;
    }
    .menu-toggle { display: inline-flex; }
    .content { padding: 16px 14px 50px; }
    .topbar { padding: 12px 14px; }
    .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
    .rail { --rail-left: 128px; }
    .topbar__clock { font-size: 16px; }
}

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    .content { padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
