* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

html {
    --rk-dialog-accent: #c4a574;
    accent-color: #c4a574;
    color-scheme: dark;
}

@supports (scrollbar-width: thin) {
    html {
        scrollbar-width: thin;
        scrollbar-color: rgba(196, 165, 116, 0.14) transparent;
    }
}

@supports selector(::-webkit-scrollbar) {
    html::-webkit-scrollbar,
    body::-webkit-scrollbar,
    *:not(.hours-scroll)::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    html::-webkit-scrollbar-thumb,
    body::-webkit-scrollbar-thumb,
    *:not(.hours-scroll)::-webkit-scrollbar-thumb {
        background: rgba(196, 165, 116, 0.12);
        border-radius: 999px;
    }

    html::-webkit-scrollbar-track,
    body::-webkit-scrollbar-track,
    *:not(.hours-scroll)::-webkit-scrollbar-track {
        background: transparent;
    }
}

@supports (scrollbar-width: thin) {
    *:not(.hours-scroll) {
        scrollbar-width: thin;
        scrollbar-color: rgba(196, 165, 116, 0.14) transparent;
    }
}

html,
body {
    height: 100%;
    height: 100dvh;
    background: #070707;
    color: #f3efe6;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-touch-callout: none;
    overscroll-behavior: none;
    touch-action: manipulation;
    accent-color: #c4a574;
    color-scheme: dark;
}

button,
a,
input,
textarea,
select {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    outline: none;
}

button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: none;
    box-shadow: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #c4a574;
}

input:-webkit-autofill,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: #f3efe6;
    caret-color: #f3efe6;
    box-shadow: 0 0 0 1000px #111 inset;
    transition: background-color 99999s;
}

html.app-shell,
html.is-app {
    height: 100%;
}

.chave-shell {
    min-height: 100dvh;
    min-height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.chave-gate {
    min-height: 100dvh;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: calc(24px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left, 0px));
    text-align: center;
}

body:not(.chave-in) .chave-gate {
    display: flex;
}

html.chave-resume .chave-gate {
    display: none !important;
}

html.chave-resume .chave-desk {
    display: flex !important;
}

.chave-desk {
    min-height: 100dvh;
    display: none;
    flex-direction: column;
}

body.chave-in .chave-desk {
    display: flex;
}

body.chave-in .chave-gate {
    display: none !important;
}

.chave-gate img,
.chave-gate .chave-logo {
    width: min(280px, 72vw);
    height: auto;
    max-height: 320px;
    object-fit: contain;
    margin-bottom: 18px;
    background: none;
    border: none;
    border-radius: 0;
}

.chave-gate h1 {
    font-size: 1.35rem;
    letter-spacing: .28em;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 8px;
}

.chave-gate .k-sub {
    color: #c4a574;
    font-size: .85rem;
    margin-bottom: 28px;
}

.chave-gate form {
    width: min(100%, 360px);
    max-width: 360px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    text-align: left;
}

.chave-gate .password-field {
    width: 100%;
    margin-bottom: 10px;
}

.chave-gate input,
.k-form input,
.k-in {
    width: 100%;
    background: #111;
    border: 1px solid #3a3428;
    color: #f3efe6;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    font-size: 1rem;
}

.k-open,
.k-go,
.k-save {
    width: 100%;
    border: none;
    border-radius: 14px;
    background: #c4a574;
    color: #111;
    font-weight: 800;
    padding: 16px;
    font-size: 1rem;
    cursor: pointer;
}

.k-err {
    color: #ff8a80;
    font-size: .88rem;
    margin-top: 12px;
    min-height: 1.2em;
}

.k-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    border-bottom: 1px solid #2a261c;
    background: #0c0c0c;
}

.k-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.k-brand img,
.k-brand .chave-logo-sm {
    width: auto;
    height: 52px;
    max-width: 120px;
    object-fit: contain;
    background: none;
    border-radius: 0;
}

.k-brand h1 {
    font-size: 1rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.k-brand p {
    color: #c4a574;
    font-size: .75rem;
}

.k-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.k-top button,
.k-update {
    background: transparent;
    border: 1px solid #3a3428;
    color: #f3efe6;
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
}

.k-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.k-icon-btn.is-updating,
.k-update.is-updating {
    pointer-events: none;
    opacity: .65;
}

.k-icon-btn.is-updating i,
.k-update.is-updating i {
    animation: k-spin .8s linear infinite;
}

@keyframes k-spin {
    to { transform: rotate(360deg); }
}

.k-update {
    margin-top: 20px;
    font-size: .85rem;
    color: #c4a574;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.k-update i {
    font-size: .9rem;
}

.k-body {
    flex: 1;
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.k-block {
    margin-bottom: 36px;
}

.k-block h2 {
    font-size: 1.4rem;
    margin-bottom: 6px;
}

.k-block .k-help {
    color: #b7b09f;
    font-size: .9rem;
    line-height: 1.45;
    margin-bottom: 16px;
}

.k-card {
    background: #12100c;
    border: 1px solid #3a3428;
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 12px;
}

.k-card h3 {
    margin: 0 0 6px;
}

.k-card p {
    color: #b7b09f;
    font-size: .88rem;
    margin: 0 0 4px;
}

.k-tag {
    display: inline-block;
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #c4a574;
    border: 1px solid #3a3428;
    border-radius: 999px;
    padding: 4px 8px;
    margin-bottom: 8px;
}

.k-tag.ok {
    color: #7dffa8;
}

.k-tag.off {
    color: #ff8a80;
}

.k-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.k-card-head small {
    color: #888;
    font-size: .75rem;
    margin-bottom: 8px;
}

.k-card[class*="k-t-"] {
    border-left: 4px solid var(--k-cor);
}

.k-card[class*="k-t-"] .k-tag,
.k-chip {
    color: var(--k-cor);
    border-color: var(--k-cor);
}

.k-t-empresa { --k-cor: #c4a574; }
.k-t-funcionario { --k-cor: #6fb7ff; }
.k-t-chave_total { --k-cor: #ff6fae; }
.k-t-banner { --k-cor: #b98bff; }
.k-t-trabalho { --k-cor: #7dffa8; }

.k-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.k-chip {
    font-size: .75rem;
    font-weight: 700;
    border: 1px solid;
    border-radius: 999px;
    padding: 4px 10px;
}

.k-media {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 10px;
    background: #000;
}

.k-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
}

.k-note {
    margin-top: 12px;
    color: #888;
    font-size: .85rem;
}

.k-row {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.k-go {
    width: auto;
    flex: 1;
    min-height: 52px;
    font-size: 1.05rem;
}

.k-no {
    border: 1px solid #5a2a2a;
    background: transparent;
    color: #ff8a80;
    border-radius: 14px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 700;
}

.k-empty {
    color: #888;
    text-align: center;
    padding: 28px 8px;
}

.k-form {
    margin-top: 8px;
}

.k-save {
    margin-top: 6px;
}

.k-msg {
    color: #c4a574;
    font-size: .85rem;
    margin-top: 10px;
}

#btn-avisos {
    width: 100%;
    margin-bottom: 18px;
    border: 1px solid #c4a574;
    background: transparent;
    color: #c4a574;
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    font-weight: 700;
}

#chave-toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    background: #3a2a2a;
    color: #ffb4ae;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    z-index: 4000;
    text-align: center;
}

#chave-toast.ok {
    background: #c4a574;
    color: #111;
}

#chave-toast:not([hidden]) {
    display: block !important;
}

.pwa-install {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #161616;
    border: 1px solid #3a3428;
    border-radius: 16px;
    padding: 12px 12px 12px 16px;
}

.pwa-install-text {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.pwa-install-text strong {
    display: block;
    font-size: 0.92rem;
}

.pwa-install-text span {
    display: block;
    font-size: 0.75rem;
    color: #b7b09f;
    margin-top: 2px;
}

.pwa-install-go {
    border: none;
    border-radius: 999px;
    background: #c4a574;
    color: #111;
    font-weight: 800;
    padding: 8px 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.pwa-install-x {
    border: none;
    background: transparent;
    color: #aaa;
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-shrink: 0;
}

html.is-app .pwa-install#pwa-install {
    display: none !important;
}