:root {
    --wine-950: #35101f;
    --wine-900: #4b142b;
    --wine-800: #661c39;
    --wine-700: #7b2345;
    --wine-600: #913452;
    --wine-100: #f6eaf0;
    --wine-50: #fbf6f8;
    --ink: #271f23;
    --muted: #766d72;
    --line: #e8dfe3;
    --surface: #ffffff;
    --background: #f7f4f5;
    --green: #2e7654;
    --green-soft: #e5f3ec;
    --amber: #9a6816;
    --amber-soft: #fbf0d9;
    --red: #a83243;
    --red-soft: #f9e4e8;
    --blue: #356897;
    --blue-soft: #e7f0f8;
    --purple: #715197;
    --purple-soft: #eee7f6;
    --shadow: 0 16px 46px rgba(61, 29, 43, 0.08);
    --shadow-soft: 0 8px 24px rgba(61, 29, 43, 0.06);
    --sidebar-width: 286px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 28px 22px 20px;
    color: #fff;
    background:
        radial-gradient(circle at 10% 0%, rgba(255,255,255,.12), transparent 28%),
        linear-gradient(170deg, var(--wine-950), var(--wine-800) 58%, #7f2b4b);
    box-shadow: 14px 0 38px rgba(45, 17, 30, .12);
}
.brand { display: flex; align-items: center; gap: 13px; padding: 4px 8px 30px; }
.brand-mark, .login-brand-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 50%;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 34px;
    line-height: 1;
}
.brand-copy { display: grid; gap: 3px; }
.brand-copy strong { font-size: 16px; letter-spacing: .16em; }
.brand-copy small { color: rgba(255,255,255,.65); font-size: 11px; }
.nav-menu { display: grid; gap: 8px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 13px;
    color: rgba(255,255,255,.72);
    font-size: 14px;
    font-weight: 650;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-link.active { color: #fff; background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.16); }
.nav-icon {
    display: grid;
    place-items: center;
    width: 31px;
    height: 31px;
    border-radius: 9px;
    background: rgba(255,255,255,.11);
    font-size: 10px;
    letter-spacing: .04em;
}
.sidebar-footer { margin-top: auto; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.14); }
.user-card { display: flex; align-items: center; gap: 11px; min-width: 0; margin-bottom: 13px; }
.user-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    color: #fff;
    font-weight: 800;
}
.user-copy { display: grid; gap: 3px; min-width: 0; }
.user-copy strong, .user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: 13px; }
.user-copy small { color: rgba(255,255,255,.62); font-size: 10px; }
.logout-button {
    width: 100%;
    min-height: 40px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    color: #fff;
    background: rgba(255,255,255,.08);
    cursor: pointer;
}
.logout-button:hover { background: rgba(255,255,255,.14); }
.version { display: block; margin-top: 10px; color: rgba(255,255,255,.42); text-align: center; font-size: 9px; }

.main-content { min-height: 100vh; margin-left: var(--sidebar-width); padding: 34px clamp(22px, 3vw, 52px) 52px; }
.main-content-full { min-height: 100vh; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.page-header h1 { margin: 6px 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4vw, 54px); font-weight: 400; letter-spacing: -.035em; }
.page-header p { max-width: 740px; margin: 0; color: var(--muted); line-height: 1.55; }
.eyebrow { color: var(--wine-700); font-size: 10px; font-weight: 850; letter-spacing: .17em; }
.eyebrow.light { color: rgba(255,255,255,.66); }
.header-meta { display: grid; justify-items: end; gap: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.source-pill { padding: 7px 10px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-weight: 750; }
.source-pill.source-warning { color: var(--amber); background: var(--amber-soft); }
.source-alert { margin: -8px 0 18px; padding: 13px 15px; border: 1px solid #edd19b; border-radius: 11px; color: #77500f; background: var(--amber-soft); font-size: 13px; }

.panel { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-soft); }
.filters-panel { margin-bottom: 18px; padding: 18px; }
.filters-grid { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 12px; align-items: end; }
.field-search { grid-column: span 2; }
.filter-actions { justify-content: flex-end; }
.field { display: grid; gap: 7px; min-width: 0; }
.field label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.field input, .field select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    color: var(--ink);
    background: #fff;
    padding: 0 11px;
    font-size: 12px;
}
.field input:focus, .field select:focus { border-color: var(--wine-600); box-shadow: 0 0 0 3px rgba(123,35,69,.1); }
.filter-actions { display: flex; gap: 8px; }
.primary-button, .ghost-button, .secondary-button, .microsoft-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 15px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 750;
    font-size: 12px;
}
.primary-button { color: #fff; background: var(--wine-700); }
.primary-button:hover { background: var(--wine-800); }
.ghost-button { border: 1px solid var(--line); color: var(--wine-700); background: #fff; }
.ghost-button:hover { background: var(--wine-50); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { position: relative; min-height: 112px; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow-soft); }
.kpi-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--muted); }
.kpi-card span { display: block; min-height: 30px; color: var(--muted); font-size: 11px; font-weight: 750; }
.kpi-card strong { display: block; margin-top: 8px; font-size: 28px; letter-spacing: -.035em; }
.kpi-card small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.kpi-card-text strong { overflow: hidden; font-size: clamp(17px, 1.35vw, 23px); line-height: 1.16; text-overflow: ellipsis; }
.tone-blue::before { background: var(--blue); }.tone-blue strong { color: var(--blue); }
.tone-purple::before { background: var(--purple); }.tone-purple strong { color: var(--purple); }
.tone-amber::before { background: var(--amber); }.tone-amber strong { color: var(--amber); }
.tone-green::before { background: var(--green); }.tone-green strong { color: var(--green); }
.tone-red::before { background: var(--red); }.tone-red strong { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.chart-panel { min-height: 310px; padding: 20px; overflow: hidden; }
.chart-wide { grid-column: span 2; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.panel-heading h3 { margin: 0 0 5px; font-size: 15px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.svg-chart { min-height: 225px; display: grid; align-items: center; overflow: hidden; }
.svg-chart svg { display: block; width: 100%; height: auto; max-height: 260px; overflow: visible; }
.chart-empty { place-items: center; color: var(--muted); font-size: 12px; }
.chart-label { fill: #5d5458; font-size: 12px; }
.chart-value { fill: #352d31; font-size: 12px; font-weight: 800; }
.chart-axis-label { fill: #7b7176; font-size: 10px; }
.chart-grid-line { stroke: #ece4e8; stroke-width: 1; }
.chart-area { fill: rgba(123,35,69,.09); }
.chart-line { fill: none; stroke: var(--wine-700); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: #fff; stroke: var(--wine-700); stroke-width: 3; }
.chart-bar { transition: opacity .2s ease; }
.chart-bar:hover { opacity: .78; }

.table-panel { overflow: hidden; }
.table-heading { margin: 0; padding: 20px 20px 12px; }
.table-wrap { width: 100%; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 1580px; border-collapse: separate; border-spacing: 0; font-size: 11px; }
th, td { padding: 12px 11px; border-bottom: 1px solid #eee8eb; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; color: #645a60; background: #faf7f8; font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:hover td { background: #fcfafb; }
.ticket-title { min-width: 220px; max-width: 330px; font-weight: 650; }
.problem-cell { min-width: 180px; max-width: 300px; }
.store-cell { min-width: 150px; font-weight: 650; }
.nowrap { white-space: nowrap; }
.status-badge, .priority-badge, .sla-badge, .category-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; border-radius: 999px; white-space: nowrap; font-size: 9px; font-weight: 800; }
.category-badge { color: var(--wine-700); background: var(--wine-100); }
.category-infraestrutura { color: var(--blue); background: var(--blue-soft); }
.category-sistemas { color: var(--purple); background: var(--purple-soft); }
.status-novo { color: var(--blue); background: var(--blue-soft); }
.status-em-andamento, .status-planejado { color: var(--purple); background: var(--purple-soft); }
.status-pendente { color: var(--amber); background: var(--amber-soft); }
.status-solucionado, .status-fechado { color: var(--green); background: var(--green-soft); }
.priority-critica, .priority-muito-alta { color: var(--red); background: var(--red-soft); }
.priority-alta { color: var(--amber); background: var(--amber-soft); }
.priority-media { color: var(--blue); background: var(--blue-soft); }
.priority-baixa, .priority-muito-baixa, .priority-nao-informada { color: #686064; background: #f0edef; }
.sla-vencido { color: var(--red); background: var(--red-soft); }
.sla-a-vencer { color: var(--amber); background: var(--amber-soft); }
.sla-dentro-do-sla { color: var(--green); background: var(--green-soft); }
.sla-sem-sla { color: #686064; background: #f0edef; }
.empty-cell { padding: 34px; color: var(--muted); text-align: center; }

.flash-stack { position: fixed; top: 18px; right: 18px; z-index: 100; display: grid; gap: 8px; max-width: min(430px, calc(100vw - 36px)); }
.flash { padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow); font-size: 12px; }
.flash-danger { border-color: #e9b1b9; color: #8d2533; }
.flash-warning { border-color: #efd096; color: #7f5715; }
.flash-success { border-color: #a8d9c1; color: #216b4b; }
.flash-info { border-color: #b9d0e5; color: #315f88; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(390px, .8fr); background: #fff; }
.login-visual { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: clamp(45px, 7vw, 110px); color: #fff; background: radial-gradient(circle at 80% 15%, rgba(255,255,255,.16), transparent 31%), linear-gradient(145deg, var(--wine-950), var(--wine-700) 58%, #a64e72); }
.login-visual::after { content: ""; position: absolute; right: -140px; bottom: -180px; width: 430px; height: 430px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.04), 0 0 0 140px rgba(255,255,255,.025); }
.login-brand-mark { margin-bottom: 36px; width: 66px; height: 66px; font-size: 43px; }
.login-visual h1 { max-width: 720px; margin: 15px 0 18px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(42px, 5vw, 76px); font-weight: 400; line-height: 1.02; letter-spacing: -.045em; }
.login-visual p { max-width: 620px; margin: 0; color: rgba(255,255,255,.72); font-size: 16px; line-height: 1.65; }
.login-features { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 30px; }
.login-features span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; background: rgba(255,255,255,.08); font-size: 11px; }
.login-panel { display: grid; place-items: center; padding: 35px; background: #faf8f9; }
.login-card { width: min(100%, 430px); padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 25px 70px rgba(69,36,50,.12); }
.login-card h2 { margin: 9px 0 8px; font-size: 28px; }
.login-card > p { margin: 0 0 25px; color: var(--muted); }
.microsoft-button { width: 100%; min-height: 50px; gap: 12px; color: #fff; background: #202020; }
.microsoft-button:hover { background: #000; }
.microsoft-button.disabled { opacity: .45; cursor: not-allowed; }
.microsoft-grid { display: grid; grid-template-columns: 8px 8px; grid-template-rows: 8px 8px; gap: 2px; }
.microsoft-grid i:nth-child(1) { background: #f35325; }.microsoft-grid i:nth-child(2) { background: #81bc06; }.microsoft-grid i:nth-child(3) { background: #05a6f0; }.microsoft-grid i:nth-child(4) { background: #ffba08; }
.config-warning { display: grid; gap: 4px; margin-top: 14px; padding: 12px; border-radius: 10px; color: #77500f; background: var(--amber-soft); font-size: 11px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: #938a8f; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.secondary-button { width: 100%; color: var(--wine-700); background: var(--wine-100); }
.secondary-button:hover { background: #ecd6e0; }
.demo-warning { margin: 10px 0 0 !important; text-align: center; font-size: 10px; }
code { padding: 1px 4px; border-radius: 5px; background: #f2edef; }

.error-page { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 12px; padding: 30px; text-align: center; }
.error-page h1 { max-width: 650px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 5vw, 58px); font-weight: 400; }
.error-page p { max-width: 590px; margin: 0 0 10px; color: var(--muted); }
.error-mark { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 8px; border-radius: 50%; color: #fff; background: var(--wine-700); font-size: 30px; font-weight: 800; }

.mobile-menu-button, .sidebar-overlay { display: none; }

@media (max-width: 1500px) {
    .filters-grid { grid-template-columns: repeat(4, minmax(145px, 1fr)); }
    .field-search { grid-column: span 2; }
    .filter-actions { justify-content: flex-end; }
}
@media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-wide { grid-column: span 2; }
}
@media (max-width: 860px) {
    body.menu-open { overflow: hidden; }
    .sidebar { width: min(86vw, 310px); transform: translateX(-105%); transition: transform .24s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 40; display: block; opacity: 0; pointer-events: none; background: rgba(28,14,20,.46); transition: opacity .24s ease; }
    .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
    .mobile-menu-button { position: fixed; top: 14px; left: 14px; z-index: 60; display: grid; width: 43px; height: 43px; padding: 11px; border: 0; border-radius: 11px; background: var(--wine-700); box-shadow: var(--shadow); }
    .mobile-menu-button span { align-self: center; width: 100%; height: 2px; border-radius: 99px; background: #fff; }
    .main-content { margin-left: 0; padding: 76px 18px 28px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .header-meta { justify-items: start; }
    .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field-search, .filter-actions { grid-column: span 2; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .chart-wide { grid-column: span 1; }
    .login-shell { grid-template-columns: 1fr; }
    .login-visual { min-height: 42vh; padding: 50px 28px; }
    .login-visual h1 { font-size: clamp(36px, 10vw, 55px); }
    .login-panel { padding: 24px 18px; }
}
@media (max-width: 540px) {
    .filters-grid { grid-template-columns: 1fr; }
    .field-search, .filter-actions { grid-column: span 1; }
    .filter-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .kpi-grid { gap: 10px; }
    .kpi-card { min-height: 96px; padding: 15px; }
    .kpi-card strong { font-size: 23px; }
    .chart-panel { min-height: 270px; padding: 16px; }
    .login-card { padding: 26px 20px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
