/**
 * SMARTER Gest — theme (dark/light) + sidebar
 */

[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="light"] {
    color-scheme: light;
}

/* Ensure native controls (select, date, multi) inherit dark chrome */
html[data-theme="dark"],
html[data-theme="dark"] body {
    color-scheme: dark;
    background: var(--color-bg);
    color: var(--color-text);
}
html[data-theme="light"],
html[data-theme="light"] body {
    color-scheme: light;
}

:root,
[data-theme="dark"] {
    --color-bg: #0a0c10;
    --color-bg-elevated: #141820;
    --color-bg-card: #1a2030;
    --color-bg-input: #2a3348;
    --color-bg-hover: #343f56;
    --sidebar-bg-from: #0a1628;
    --sidebar-bg-to: #060d18;
    --color-sidebar-border: rgba(255, 255, 255, 0.14);
    --color-sidebar-text: rgba(255, 255, 255, 0.92);
    --color-sidebar-text-muted: rgba(255, 255, 255, 0.72);

    --color-text: #f4f7fc;
    --color-text-muted: #c5d0e0;
    --color-text-label: #dce4f0;

    --color-border: #5a6578;
    --color-primary: #6b9fd4;
    --color-primary-hover: #5a8fc4;
    --color-btn-insert-bg: rgba(255, 255, 255, 0.05);
    --color-btn-insert-border: rgba(255, 255, 255, 0.18);
    --color-btn-insert-text: #dce4f0;
    --color-btn-insert-hover-bg: #1976d2;
    --color-btn-insert-hover-text: #ffffff;
    --color-btn-delete-bg: rgba(229, 57, 53, 0.1);
    --color-btn-delete-border: rgba(229, 57, 53, 0.38);
    --color-btn-delete-text: #ef9a9a;
    --color-btn-delete-hover-bg: #c62828;
    --color-btn-delete-hover-text: #ffffff;
    --color-success: #4ade80;
    --color-warning: #fbbf24;
    --color-danger: #ef4444;

    --radius-md: 8px;
    --sidebar-width: 260px;
    --header-height: 77px;
    --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
    --color-bg: #eef1f6;
    --color-bg-elevated: #ffffff;
    --color-bg-card: #ffffff;
    --color-bg-input: #ffffff;
    --color-bg-hover: #e8ecf3;
    --sidebar-bg-from: #0a66c2;
    --sidebar-bg-to: #084c8c;
    --color-sidebar-border: rgba(255, 255, 255, 0.14);
    --color-sidebar-text: rgba(255, 255, 255, 0.92);
    --color-sidebar-text-muted: rgba(255, 255, 255, 0.68);
    --color-text: #1a1f2e;
    --color-text-muted: #4a5568;
    --color-text-label: #374151;
    --color-border: #c5cdd8;
    --color-primary: #1565c0;
    --color-primary-hover: #0d47a1;
    --color-btn-insert-bg: rgba(0, 0, 0, 0.03);
    --color-btn-insert-border: #c5cdd8;
    --color-btn-insert-text: #374151;
    --color-btn-insert-hover-bg: #1565c0;
    --color-btn-insert-hover-text: #ffffff;
    --color-btn-delete-bg: rgba(182, 2, 14, 0.09);
    --color-btn-delete-border: rgba(182, 2, 14, 0.42);
    --color-btn-delete-text: #9f1d1d;
    --color-btn-delete-hover-bg: #b6020e;
    --color-btn-delete-hover-text: #ffffff;
    --color-danger: #dc2626;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: none; }

.app-layout {
    display: flex;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    align-items: stretch;
}

.app-layout.sg-app--with-sidebar {
    flex-direction: row;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg-from), var(--sidebar-bg-to));
    border-right: 1px solid var(--color-sidebar-border);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar__brand {
    min-height: var(--header-height);
    padding: 0.65rem 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--color-sidebar-text);
    box-sizing: border-box;
}

.sidebar__brand--lm {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    text-align: center;
    padding: 0 0.75rem 0.35rem;
    min-height: var(--header-height);
    margin-bottom: 10px;
}

.sidebar__brand-link {
    display: block;
    line-height: 0;
    text-decoration: none;
    color: inherit;
    border-radius: 6px;
}
.sidebar__brand-link:focus-visible {
    outline: 2px solid var(--sidebar-accent, #6b9fd4);
    outline-offset: 2px;
}
.sidebar__brand-logo {
    display: block;
    width: min(218px, 100%);
    height: auto;
    max-height: 55px;
    object-fit: contain;
    margin: calc((var(--header-height) - 55px) / 2) auto 8px;
}

/* Auth / login page */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d27 0%, #0f1117 50%, #14161e 100%);
    position: relative;
    padding: 1.5rem 1rem 2rem;
}

.auth-lang {
    position: fixed;
    top: 1.1rem;
    right: 1.35rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.auth-lang__link {
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
}

.auth-lang__link:hover {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
}

.auth-lang__link--active {
    color: #fff;
}

.auth-lang__sep {
    color: rgba(255, 255, 255, 0.4);
}

.auth-container {
    width: 100%;
    max-width: 430px;
    padding: 0 0.75rem;
}

.auth-card {
    width: 100%;
    border-radius: 16px;
}

.auth-card__body {
    padding: 1.35rem 1.5rem 1.15rem;
}

.auth-card__brand {
    text-align: center;
    margin-bottom: 1.35rem;
}

.auth-card__logo {
    display: inline-block;
    max-width: 200px;
    max-height: 56px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.auth-card__appname {
    margin: 0.75rem 0 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--color-text);
    line-height: 1.2;
}

.auth-forgot-link {
    margin: 0.5rem 0 0;
}

.auth-footer {
    margin: 0.85rem 0 0;
    color: rgba(255, 255, 255, 0.45);
}

.auth-footer a {
    color: inherit;
    text-decoration: underline;
}

.sidebar__brand-heading {
    margin-top: 0.2rem;
    line-height: 1.2;
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.sidebar__brand-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-sidebar-text);
}

.sidebar__brand-version {
    display: block;
    width: 100%;
    margin: -25px 0 0;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-sidebar-text-muted);
    text-align: right;
    white-space: nowrap;
}

.sidebar__group + .sidebar__group {
    border-top: 1px solid var(--color-sidebar-border);
}

.sidebar__group-label {
    padding: 0.45rem 1rem 0.15rem;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-sidebar-text-muted);
    opacity: 0.85;
}

.sidebar__nav { list-style: none; margin: 0; padding: 0.15rem 0 0.25rem; flex: 1; }
.sidebar__nav li { margin: 0; }
.sidebar__sub { list-style: none; margin: 0; padding: 0 0 0.15rem; }
.sidebar__link--form { padding-left: 2.2rem; font-size: 0.9rem; }
.sidebar__link--form .sidebar__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.75rem;
    margin: 1px 6px;
    border-radius: 5px;
    font-size: 0.96rem;
    color: var(--color-sidebar-text-muted);
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar__link:hover {
    background: var(--sidebar-accent, rgba(255, 255, 255, 0.12));
    color: var(--color-sidebar-text);
    text-decoration: none;
}
.sidebar__link--active {
    background: var(--sidebar-accent-active, rgba(255, 255, 255, 0.16));
    color: var(--color-sidebar-text);
    font-weight: 600;
}
.sidebar__icon {
    flex: 0 0 1.45rem;
    width: 1.45rem;
    min-width: 1.45rem;
    max-width: 1.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
    font-variant-emoji: text;
    color: inherit;
}
.sidebar__icon--bell,
.sg-icon-bell {
    font-size: 0;
    color: inherit;
}
.sidebar__icon--bell::before,
.sg-icon-bell::before {
    content: "";
    display: block;
    width: 1.05rem;
    height: 1.05rem;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 22c1.1 0 2-.9 2-2h-4a2 2 0 0 0 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 22c1.1 0 2-.9 2-2h-4a2 2 0 0 0 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.sidebar__label {
    min-width: 0;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0;
    padding: 0;
    width: 100%;
}

.sg-app--with-sidebar .main-content.sg-main {
    flex: 1;
    min-width: 0;
    max-width: none;
    margin-top: 0;
    padding: 0;
}

.topbar {
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0 1.2rem;
    margin: 0;
    border-bottom: 1px solid var(--color-sidebar-border);
    background: var(--color-bg-elevated);
    box-sizing: border-box;
    z-index: 40;
    width: 100%;
    flex-shrink: 0;
}

.topbar-menu {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text);
    cursor: pointer;
}

.topbar-menu .material-icons {
    font-size: 1.4rem;
}

.topbar__brand {
    flex: 1;
    min-width: 0;
    margin-left: 0;
}

/* Topbar brand — own classes (never inherit sidebar white text). */
.topbar__brand-heading {
    margin-top: 0;
    line-height: 1.2;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.topbar__brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
}

.topbar__version {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    color: var(--color-text-muted);
    opacity: 1;
}

/* Explicit theme colours so menu sidebar tokens never bleed into the topbar. */
[data-theme="light"] .topbar__brand-name {
    color: #1a1f2e;
}
[data-theme="light"] .topbar__version {
    color: #4a5568;
}
[data-theme="dark"] .topbar__brand-name {
    color: #f4f7fc;
}
[data-theme="dark"] .topbar__version {
    color: #c5d0e0;
}

/* Legacy selectors (if any partial still uses sidebar classes inside topbar). */
.topbar__brand .sidebar__brand-heading {
    margin-top: 0;
    justify-content: flex-start;
}
.topbar__brand .sidebar__brand-name {
    color: var(--color-text);
}
.topbar__brand .sidebar__brand-version {
    color: var(--color-text-muted);
}
[data-theme="light"] .topbar__brand .sidebar__brand-name,
[data-theme="light"] .topbar__brand .sidebar__brand-version {
    color: #1a1f2e;
}
[data-theme="light"] .topbar__brand .sidebar__brand-version {
    color: #4a5568;
}
[data-theme="dark"] .topbar__brand .sidebar__brand-name {
    color: #f4f7fc;
}
[data-theme="dark"] .topbar__brand .sidebar__brand-version {
    color: #c5d0e0;
}

.topbar__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.topbar-ai,
.topbar-godmode {
    position: relative;
}
.topbar-ai__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 24rem;
    max-width: calc(100vw - 1.5rem);
    padding: 1rem 1.05rem 1.1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg-card);
    box-shadow: var(--sg-shadow, 0 10px 28px rgba(0, 0, 0, 0.2));
}
.topbar-ai__panel[hidden] { display: none; }
.topbar-ai__title { margin: 0; font-weight: 700; }
.topbar-ai__note { margin: 0; font-size: 0.78rem; line-height: 1.4; color: var(--color-text-muted); }
.topbar-ai__log {
    max-height: 18rem;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.topbar-ai__msg {
    margin: 0;
    white-space: pre-wrap;
    font-size: 0.86rem;
    line-height: 1.45;
}
.topbar-ai__msg--user { font-weight: 700; }
.topbar-ai__answer {
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-primary, #3b82f6) 6%, var(--color-bg-card));
}
.topbar-ai__reply {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  line-height: 1.45;
}
.topbar-ai__answer h3 { margin: 0 0 0.45rem; font-size: 0.78rem; font-weight: 600; color: var(--color-text-muted); }
.topbar-ai__answer dl { margin: 0; }
.topbar-ai__answer dl > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.28rem 0;
  border-top: 1px solid var(--color-border);
}
.topbar-ai__answer dt { margin: 0; color: var(--color-text-muted); font-size: 0.78rem; }
.topbar-ai__answer dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.topbar-ai__answer dd.is-neg { color: #c62828; }
.topbar-ai__form { display: flex; gap: 0.4rem; }
.topbar-ai__form .sg-input { flex: 1; min-width: 0; }
.topbar-godmode {
    position: relative;
}
.topbar-godmode__label {
    margin-left: 0.2rem;
    font-variant-numeric: tabular-nums;
}
.topbar-godmode__btn--on {
    border-color: var(--color-primary, #3b82f6);
    color: var(--color-primary, #3b82f6);
}
.topbar-godmode__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    width: 19.5rem;
    max-width: calc(100vw - 1.5rem);
    padding: 1.1rem 1.15rem 1.2rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg-card);
    box-shadow: var(--sg-shadow, 0 10px 28px rgba(0, 0, 0, 0.2));
}
.topbar-godmode__panel[hidden] {
    display: none;
}
.topbar-godmode__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.25;
}
.topbar-godmode__box {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.topbar-godmode__box[hidden] {
    display: none !important;
}
.topbar-godmode__box .sg-form__group {
    gap: 0.45rem;
    margin: 0;
}
.topbar-godmode__note {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--color-text-muted);
}
.topbar-godmode__code,
.topbar-godmode__panel input {
    box-sizing: border-box;
    width: 100%;
    height: 2.6rem;
    padding: 0 0.7rem;
    font-size: 1.2rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.32em;
    text-align: center;
}
.topbar-godmode__panel .sg-btn {
    width: 100%;
    justify-content: center;
    min-height: 2.35rem;
}
.topbar-godmode__schedule {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.15rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--color-border);
}
.topbar-godmode__schedule .sg-form__group {
    gap: 0.35rem;
    margin: 0;
}
.topbar-godmode__schedule label {
    font-size: 0.78rem;
    font-weight: 700;
}
.topbar-godmode__panel .topbar-godmode__when,
.topbar-godmode__panel .sg-iso-date__text {
    height: 2.4rem;
    padding: 0 0.65rem;
    font-size: 0.95rem;
    letter-spacing: 0;
    text-align: left;
}

.topbar-clock {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.topbar-clock__btn {
    gap: 0.25rem;
    padding: 0 0.55rem;
    font-weight: 700;
    font-size: 0.72rem;
}
.topbar-clock__btn .material-icons {
    font-size: 1.05rem !important;
}
.topbar-clock__btn--entrada {
    background: color-mix(in srgb, var(--color-success) 18%, var(--color-bg-card));
    color: var(--color-success);
    border-color: color-mix(in srgb, var(--color-success) 45%, var(--color-border));
}
.topbar-clock__btn--entrada:hover:not(:disabled) {
    background: var(--color-success);
    color: #0b1220;
    border-color: var(--color-success);
}
.topbar-clock__btn--saida {
    background: color-mix(in srgb, var(--color-primary) 16%, var(--color-bg-card));
    color: var(--color-primary);
    border-color: color-mix(in srgb, var(--color-primary) 42%, var(--color-border));
}
.topbar-clock__btn--saida:hover:not(:disabled) {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.topbar-clock__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
@media (max-width: 720px) {
    .topbar-clock__text {
        display: none;
    }
    .topbar-clock__btn {
        padding: 0 0.4rem;
        min-width: var(--topbar-control-height);
    }
}

:root {
    --topbar-control-height: 30px;
}

.topbar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--topbar-control-height);
    min-width: var(--topbar-control-height);
    padding: 0 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text);
    font: inherit;
    font-size: 0.8rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    flex-shrink: 0;
    box-sizing: border-box;
}

.topbar-btn--outline {
    background: transparent;
}

.topbar-btn--soft {
    background: var(--color-bg-hover);
}

.topbar-btn:hover,
.topbar-btn:focus-visible {
    border-color: var(--color-primary);
    outline: none;
}

.topbar-btn .material-icons {
    font-size: 1.15rem !important;
}

.topbar-btn__badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.1rem;
    text-align: center;
    pointer-events: none;
}

.topbar-lang {
    position: relative;
}

.topbar-lang__menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 150px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 50;
    padding: 0.35rem 0;
}

.topbar-lang__menu[hidden] {
    display: none;
}

.topbar-lang__item {
    display: block;
    padding: 0.55rem 1rem;
    color: var(--color-text);
    font-size: 0.875rem;
    text-decoration: none;
}

.topbar-lang__item:hover {
    background: var(--color-bg-hover);
}

.topbar-lang__item--active {
    font-weight: 600;
    color: var(--color-primary);
}

.topbar-profile {
    position: relative;
}

.topbar-profile__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: var(--topbar-control-height);
    padding: 0 0.45rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    max-width: 220px;
    box-sizing: border-box;
}

.topbar-profile__toggle:hover,
.topbar-profile__toggle:focus-visible {
    border-color: var(--color-primary);
    outline: none;
}

.topbar-profile__icon {
    font-size: 1.25rem !important;
    color: var(--color-primary);
    flex-shrink: 0;
}

.topbar-profile__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 767px) {
    .topbar-profile__name {
        display: none;
    }
}

.topbar-profile__caret {
    font-size: 0.95rem !important;
    opacity: 0.7;
    flex-shrink: 0;
}

.topbar-profile__menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 200px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 50;
    padding: 0.35rem 0;
}

.topbar-profile__menu[hidden] {
    display: none;
}

.topbar-profile__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.topbar-profile__item:hover {
    background: var(--color-bg-hover);
}

.topbar-profile__item--logout {
    color: var(--color-danger);
    border-top: 1px solid var(--color-border);
    margin-top: 0.25rem;
    padding-top: 0.65rem;
}

.topbar-profile__item .material-icons {
    font-size: 1.15rem !important;
}

.content-wrapper {
    padding: 1.25rem;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

.sg-impersonation-banner {
    flex-shrink: 0;
}

.sg-footer {
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .topbar__actions {
        gap: 0.75rem;
    }
}

@media (min-width: 769px) {
    .app-layout.sg-app--with-sidebar {
        height: 100vh;
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        overflow-y: auto;
        z-index: 30;
    }

    .sg-app--with-sidebar .main-content.sg-main {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
}

.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.card__body { padding: 1.25rem; }
.card__title { margin: 0 0 0.75rem; font-size: 1.25rem; }
.card__subtitle { margin: 1.25rem 0 0.5rem; font-size: 1rem; font-weight: 600; color: var(--color-text); }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; color: var(--color-text-label); }
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-input);
    color: var(--color-text);
    font: inherit;
}

.form-hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.5rem; }
.form-actions { margin-top: 1rem; }

.profile-section {
    margin-top: 1.5rem;
    padding-top: 0.25rem;
}
.profile-section:first-of-type {
    margin-top: 0;
}
.profile-section--security {
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-hover);
}
.profile-security__btn {
    gap: 0.4rem;
}
.profile-2fa__email-switch {
    margin-bottom: 1.25rem;
}
.profile-2fa__confirm {
    margin-top: 0.75rem;
}
.profile-2fa__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.profile-2fa__cancel {
    margin-top: 0.75rem;
}
.profile-security__btn .material-icons {
    font-size: 1.125rem;
}
.profile-menu-reset {
    margin-top: 0.5rem;
}
.form-actions--profile {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.sg-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    cursor: pointer;
    user-select: none;
}
.sg-toggle__text {
    flex: 1;
    min-width: 0;
    font: inherit;
    color: inherit;
    line-height: 1.35;
}
.sg-toggle__control {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 26px;
}
.sg-toggle input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}
.sg-toggle__slider {
    display: block;
    width: 44px;
    height: 26px;
    background: #c5cdd8;
    border-radius: 999px;
    position: relative;
    transition: background 0.18s ease;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.sg-toggle__slider::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.18s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}
.sg-toggle input:checked + .sg-toggle__slider {
    background: var(--color-primary);
}
.sg-toggle input:checked + .sg-toggle__slider::after {
    transform: translateX(18px);
}
.sg-toggle input:focus-visible + .sg-toggle__slider {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}
[data-theme="dark"] .sg-toggle__slider {
    background: #4a5568;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.btn--primary {
    background: var(--color-btn-insert-bg, rgba(0, 0, 0, 0.03));
    color: var(--color-btn-insert-text, var(--color-text));
    border: 1px solid var(--color-btn-insert-border, var(--color-border));
    font-weight: 600;
}
.btn--primary:hover {
    background: var(--color-btn-insert-hover-bg, var(--color-primary));
    color: var(--color-btn-insert-hover-text, #fff);
    border-color: var(--color-btn-insert-hover-bg, var(--color-primary));
}
.btn--danger {
    background: var(--color-btn-delete-bg, rgba(182, 2, 14, 0.09));
    color: var(--color-btn-delete-text, #9f1d1d);
    border: 1px solid var(--color-btn-delete-border, rgba(182, 2, 14, 0.42));
    font-weight: 600;
}
.btn--danger:hover {
    background: var(--color-btn-delete-hover-bg, #b6020e);
    color: var(--color-btn-delete-hover-text, #fff);
    border-color: var(--color-btn-delete-hover-bg, #b6020e);
}
.btn--secondary { background: var(--color-bg-hover); color: var(--color-text); border: 1px solid var(--color-border); }
.btn--ghost {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn--ghost:hover { background: var(--color-bg-hover); }
.btn--block { width: 100%; }
.btn--sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

.btn-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0;
    cursor: pointer;
    color: var(--color-text);
    font-size: 0.875rem;
    font-weight: 500;
    height: var(--topbar-control-height);
    min-height: var(--topbar-control-height);
    width: var(--topbar-control-height);
    min-width: var(--topbar-control-height);
    box-sizing: border-box;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-theme-toggle--square {
    padding: 0;
    gap: 0;
}

.btn-theme-toggle--square .btn-theme-toggle__label {
    display: none;
}

.btn-theme-toggle:hover,
.btn-theme-toggle:focus-visible {
    background: var(--color-bg-hover);
    color: var(--color-text);
    border-color: var(--color-primary);
    outline: none;
}

.btn-theme-toggle__icon {
    font-size: 1.125rem !important;
}

.btn-theme-toggle__label {
    white-space: nowrap;
}

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: 1rem; color: var(--color-text); }
.alert--success { background: rgba(74, 222, 128, 0.15); border: 1px solid var(--color-success); }
.alert--warning { background: rgba(251, 191, 36, 0.15); border: 1px solid var(--color-warning); }
.alert--danger { background: rgba(248, 113, 113, 0.15); border: 1px solid var(--color-danger); }

[data-theme="dark"] .alert--success { color: #b8f5d0; }
[data-theme="dark"] .alert--warning { color: #ffe6a8; }
[data-theme="dark"] .alert--danger { color: #ffc8c8; }

.text-muted { color: var(--color-text-muted); }
.text-muted--sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.text-primary { color: var(--color-primary); font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 1rem; }
.p-4 { padding: 1.25rem; }
.small { font-size: 0.8rem; }

.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.widget {
    padding: 1rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
}

.widget__label { display: block; font-size: 0.8rem; color: var(--color-text-muted); }
.widget__value { display: block; font-size: 1.5rem; font-weight: 700; margin-top: 0.5rem; }

.sidebar-overlay[hidden] { display: none; }

@media (max-width: 768px) {
    .topbar-menu {
        display: inline-flex;
    }

    .topbar {
        position: relative;
        z-index: 90;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .topbar__actions {
        min-width: 0;
        overflow: visible;
        gap: 0.35rem;
    }

    .topbar-godmode__label,
    .topbar-profile__name,
    .topbar-profile__caret {
        display: none;
    }

    .app-layout.sg-app--with-sidebar {
        flex-direction: column;
    }

    .sg-impersonation-banner {
        position: relative;
        z-index: 85;
    }

    .sidebar {
        position: fixed;
        z-index: 80;
        top: var(--sg-menu-top, var(--header-height));
        left: 0;
        width: min(18.5rem, calc(100vw - 3rem));
        height: calc(100% - var(--sg-menu-top, var(--header-height)));
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        transform: translateX(-100%);
        transition: transform 0.2s;
    }

    .sidebar.is-open { transform: translateX(0); }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        top: var(--sg-menu-top, var(--header-height));
        background: rgba(0, 0, 0, 0.45);
        z-index: 70;
        touch-action: none;
    }

    .sg-app--with-sidebar .main-content.sg-main {
        width: 100%;
        margin-left: 0;
    }

    body.sg-menu-open,
    body.sg-menu-open .content-wrapper,
    body.sg-menu-open .main-content {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .topbar-ai__panel,
    .topbar-godmode__panel,
    .topbar-lang__menu,
    .topbar-profile__menu {
        position: fixed;
        top: calc(var(--sg-menu-top, var(--header-height)) + 0.4rem);
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        max-width: none;
        max-height: calc(100vh - var(--sg-menu-top, var(--header-height)) - 1rem);
        overflow: auto;
        z-index: 130;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }
}

/* Banco de horas chart */
.sg-banco-chart {
  margin: 0.75rem 1rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--sg-surface-2, rgba(127,127,127,0.08));
}
.sg-banco-chart canvas {
  width: 100% !important;
  max-width: 100%;
  height: 220px !important;
  max-height: 220px !important;
  display: block;
}
.sg-banco-chart canvas[hidden],
.sg-banco-chart.is-absences canvas {
  display: none !important;
  height: 0 !important;
  max-height: 0 !important;
  width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
.sg-banco-chart.is-absences {
  padding: 0.75rem 1rem;
}
.sg-banco-chart__legend {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  opacity: 0.9;
}
.sg-banco-chart__swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}
.sg-banco-chart__swatch--contract { background: rgba(66, 133, 244, 0.85); }
.sg-banco-chart__swatch--worked { background: rgba(52, 168, 83, 0.85); }
.sg-banco-chart__swatch--faltas { background: #d97706; }
.sg-banco-chart__swatch--ferias { background: var(--sg-primary, #2563eb); }
.sg-banco-chart__swatch--limit {
  background: transparent;
  border-top: 2px dashed color-mix(in srgb, var(--sg-text-muted) 75%, var(--sg-primary));
  height: 0;
  width: 0.9rem;
  border-radius: 0;
  vertical-align: middle;
}
.sg-chart--absences {
  padding: 0;
  min-height: 220px;
  overflow-x: auto;
}
.sg-chart--absences .sg-chart__bars,
.sg-chart__bars--absences {
  height: 200px;
  padding-top: 1.15rem;
  justify-content: flex-start;
  min-width: 100%;
  gap: 0.8rem;
}
.sg-chart__bars--absences .sg-chart__col {
  flex: 0 0 4.5rem;
}
.sg-chart__bar--faltas {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}
.sg-chart__bar--ferias {
  background: linear-gradient(180deg, var(--sg-primary) 0%, color-mix(in srgb, var(--sg-primary) 55%, #000) 100%);
}
.sg-vacation-summary {
  margin-top: 0.75rem;
}
.sg-vacation-summary__table {
  overflow-x: auto;
}
.sg-vacation-card {
  margin: 0 0 1rem;
}
.sg-vacation-card__title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.sg-table--compact th,
.sg-table--compact td {
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
}

.sg-tooltip {
  position: fixed;
  z-index: 10050;
  max-width: min(320px, calc(100vw - 1.5rem));
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #fff;
  background: rgba(22, 28, 45, 0.96);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  text-align: center;
}
[data-theme="dark"] .sg-tooltip {
  background: rgba(38, 44, 62, 0.98);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.sg-form__group > label[data-field-help="1"],
.form-group > label[data-field-help="1"],
.form-label[data-field-help="1"],
.sg-table-toolbar__filter > label[data-field-help="1"],
legend[data-field-help="1"],
th[data-field-help="1"],
.sg-toggle[data-field-help="1"] .sg-toggle__text {
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: help;
}
