/* Skip artifact shell — fixed styles served beside every artifact.
   Complements basecoat; artifacts override --accent for their own identity. */
:root {
  color-scheme: light dark;
  --accent: #2563eb;
  --accent-contrast: #ffffff;
  --accent-text: color-mix(in srgb, var(--accent) 72%, #000);
  --bg: #f8f9fb;
  --surface: #ffffff;
  --text: #14171f;
  --text-muted: #5b6472;
  --border: rgba(20, 23, 31, 0.10);
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 23, 31, 0.08);
  --space: 16px;
}
/* Theme resolution. Without data-theme the viewer's system preference decides,
   as it always did. With it, the artifact's own choice wins in BOTH directions:
   a page that hardcodes one palette must not be handed the opposite set of
   tokens by the machine it happens to be opened on. The dark values appear
   twice because a media query cannot be folded into a selector list.
   The attribute sits inside :where() so these blocks keep the specificity of a
   bare :root — the page's own <style> is linked after this file and must go on
   overriding any token it wants, exactly as it could before. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --accent-text: color-mix(in srgb, var(--accent) 78%, #fff);
    --bg: #101318;
    --surface: #181c23;
    --text: #eef1f6;
    --text-muted: #9aa4b2;
    --border: rgba(238, 241, 246, 0.12);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}
:root:where([data-theme="dark"]) {
  color-scheme: dark;
  --accent-text: color-mix(in srgb, var(--accent) 78%, #fff);
  --bg: #101318;
  --surface: #181c23;
  --text: #eef1f6;
  --text-muted: #9aa4b2;
  --border: rgba(238, 241, 246, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
:root:where([data-theme="light"]) { color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }

.shell-container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.shell-section { padding: calc(var(--space) * 2) 0; }
.shell-grid { display: grid; gap: var(--space); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.shell-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: var(--space); }
.shell-footer { padding: 24px 0 40px; color: var(--text-muted); font-size: 13px; }

.shell-hero { padding: calc(var(--space) * 3) 0 calc(var(--space) * 2); }
.shell-hero h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.15; margin: 0 0 10px; text-wrap: balance; }
.shell-hero p { color: var(--text-muted); max-width: 60ch; margin: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space);
}

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .kpi-value { font-size: 28px; font-weight: 650; line-height: 1.1; }
.kpi .kpi-label { font-size: 13px; color: var(--text-muted); }
.kpi .kpi-delta { font-size: 12.5px; font-weight: 600; }
.kpi .kpi-delta.up { color: #0a8f3c; }
.kpi .kpi-delta.down { color: #cf3131; }

table.shell-table { border-collapse: collapse; width: 100%; font-size: 14px; }
table.shell-table th {
  text-align: left; font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
}
table.shell-table th, table.shell-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); }
table.shell-table td.num, table.shell-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.shell-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

.chart-box { width: 100%; min-height: 220px; }
.chart-box svg { width: 100%; height: auto; display: block; }

.muted { color: var(--text-muted); }
.accent { color: var(--accent-text); }
.shell-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-text);
}

@media (prefers-reduced-motion: no-preference) {
  .shell-fade { animation: shell-fade 400ms ease both; }
  @keyframes shell-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

    :root {
      --accent: #F0D53C;
      --accent-contrast: #262D3D;
      --accent-text: #262D3D;
      --bg: #F5F6F8;
      --surface: #FFFFFF;
      --text: #1F2937;
      --text-muted: #6B7280;
      --border: #E4E7EC;
      --radius: 10px;
      
      --brand-blue: #262D3D;
      --brand-blue-hover: #1A2030;
      --brand-yellow: #F0D53C;
      
      --status-success-text: #1E7F4F;
      --status-success-bg: #E6F4EC;
      --status-pending-text: #B26A00;
      --status-pending-bg: #FFF4DE;
      --status-danger-text: #B42318;
      --status-danger-bg: #FEE4E2;
      --status-gray-text: #475467;
      --status-gray-bg: #EEF0F3;
    }

    body {
      font-family: 'Inter', system-ui, -apple-system, sans-serif;
      background-color: var(--bg);
      color: var(--text);
      margin: 0;
      padding: 0;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    .tabular-nums {
      font-variant-numeric: tabular-nums;
    }

    /* --- BRAND LOGO CSS RECREATION --- */
    .brand-logo {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      user-select: none;
    }
    .brand-logo .logo-more {
      font-weight: 900;
      font-size: 1.5rem;
      letter-spacing: -0.04em;
      line-height: 1;
      text-transform: uppercase;
    }
    .brand-logo .logo-divider {
      width: 100%;
      height: 1px;
      background-color: #8E8E8E;
      margin: 3px 0 2px 0;
    }
    .brand-logo .logo-cookies {
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 800;
      font-size: 1.1rem;
      letter-spacing: 0.05em;
      line-height: 1;
    }
    .brand-logo.dark-bg .logo-more { color: #FFFFFF; }
    .brand-logo.dark-bg .logo-cookies { color: #FFFFFF; }
    .brand-logo.light-bg .logo-more { color: var(--brand-blue); }
    .brand-logo.light-bg .logo-cookies { color: var(--brand-blue); }

    .rings-svg {
      display: inline-block;
      vertical-align: middle;
      margin: 0 -2px;
    }

    /* --- LOGIN PAGE --- */
    #login-screen {
      position: fixed;
      inset: 0;
      background: radial-gradient(circle at center, #2F374A 0%, #1A202C 100%);
      z-index: 9999;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1rem;
    }
    .login-card {
      background: #FFFFFF;
      width: 100%;
      max-width: 420px;
      border-radius: var(--radius);
      padding: 2.25rem 2rem;
      box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    }
    .login-divider {
      display: flex;
      align-items: center;
      text-align: center;
      color: var(--text-muted);
      margin: 1.25rem 0;
      font-size: 0.85rem;
    }
    .login-divider::before, .login-divider::after {
      content: '';
      flex: 1;
      border-bottom: 1px solid var(--border);
    }
    .login-divider::before { margin-right: .5em; }
    .login-divider::after { margin-left: .5em; }

    /* --- SYSTEM LAYOUT --- */
    .app-layout {
      display: flex;
      min-height: 100vh;
      width: 100%;
    }
    .app-sidebar {
      width: 220px;
      background-color: var(--brand-blue);
      color: #FFFFFF;
      display: flex;
      flex-direction: column;
      flex-shrink: 0;
      position: fixed;
      top: 0;
      bottom: 0;
      left: 0;
      z-index: 100;
      transition: width 0.2s ease;
    }
    .sidebar-header {
      padding: 1.25rem 1rem;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }
    .sidebar-menu {
      padding: 1rem 0;
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }
    .nav-item {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.75rem 1.25rem;
      color: #D1D5DB;
      text-decoration: none;
      font-size: 0.9rem;
      font-weight: 500;
      border-left: 3px solid transparent;
      transition: all 0.15s ease;
      cursor: pointer;
    }
    .nav-item:hover {
      background: rgba(255, 255, 255, 0.05);
      color: #FFFFFF;
    }
    .nav-item.active {
      background: rgba(240, 213, 60, 0.14);
      color: #FFFFFF;
      border-left-color: var(--brand-yellow);
      font-weight: 600;
    }
    .nav-item.active svg {
      color: var(--brand-yellow);
    }
    .sidebar-footer {
      padding: 1rem;
      font-size: 0.75rem;
      color: #9CA3AF;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .app-main {
      flex: 1;
      margin-left: 220px;
      display: flex;
      flex-direction: column;
      min-width: 0;
    }
    .app-topbar {
      height: 60px;
      background: #FFFFFF;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 1.5rem;
      position: sticky;
      top: 0;
      z-index: 90;
    }
    .app-content {
      padding: 1.5rem;
      flex: 1;
      max-width: 1400px;
      width: 100%;
      box-sizing: border-box;
      margin: 0 auto;
    }

    /* --- CARDS & PANELS --- */
    .card-panel {
      background: #FFFFFF;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: 0 1px 3px rgba(38, 45, 61, 0.08);
      padding: 1.25rem;
      margin-bottom: 1.25rem;
    }

    /* --- TAGS & BADGES --- */
    .mc-badge {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      padding: 0.25rem 0.6rem;
      border-radius: 6px;
      font-size: 0.75rem;
      font-weight: 600;
      line-height: 1.2;
    }
    .mc-badge-yellow {
      background-color: var(--brand-yellow);
      color: var(--brand-blue);
    }
    .mc-badge-success {
      background-color: var(--status-success-bg);
      color: var(--status-success-text);
    }
    .mc-badge-pending {
      background-color: var(--status-pending-bg);
      color: var(--status-pending-text);
    }
    .mc-badge-danger {
      background-color: var(--status-danger-bg);
      color: var(--status-danger-text);
    }
    .mc-badge-gray {
      background-color: var(--status-gray-bg);
      color: var(--status-gray-text);
    }

    /* --- BUTTONS --- */
    .btn-mc-primary {
      background-color: var(--brand-blue);
      color: #FFFFFF !important;
      border: 1px solid var(--brand-blue);
      font-weight: 600;
      padding: 0.5rem 1rem;
      border-radius: 6px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      transition: background-color 0.15s;
    }
    .btn-mc-primary:hover {
      background-color: var(--brand-blue-hover);
    }
    .btn-mc-secondary {
      background-color: #FFFFFF;
      color: var(--brand-blue);
      border: 1px solid var(--border);
      font-weight: 600;
      padding: 0.5rem 1rem;
      border-radius: 6px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      transition: background 0.15s, border-color 0.15s;
    }
    .btn-mc-secondary:hover {
      background-color: #F9FAFB;
      border-color: #D1D5DB;
    }
    .btn-mc-primary:focus-visible, .btn-mc-secondary:focus-visible, input:focus-visible, select:focus-visible {
      outline: 2px solid var(--brand-yellow) !important;
      outline-offset: 1px;
    }

    /* --- MODALS --- */
    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.6);
      backdrop-filter: blur(4px);
      z-index: 999;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1rem;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease;
    }
    .modal-backdrop.active {
      opacity: 1;
      pointer-events: auto;
    }
    .modal-box {
      background: #FFFFFF;
      border-radius: var(--radius);
      width: 100%;
      max-width: 520px;
      box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
      overflow: hidden;
      transform: scale(0.95);
      transition: transform 0.2s ease;
    }
    .modal-backdrop.active .modal-box {
      transform: scale(1);
    }

    /* --- TOASTS --- */
    .toast-container {
      position: fixed;
      bottom: 1.5rem;
      right: 1.5rem;
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      pointer-events: none;
    }
    .toast-msg {
      pointer-events: auto;
      background: #FFFFFF;
      border-left: 4px solid #10B981;
      box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
      padding: 0.85rem 1.25rem;
      border-radius: 6px;
      display: flex;
      align-items: center;
      gap: 0.75rem;
      font-size: 0.875rem;
      font-weight: 500;
      color: var(--text);
      animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }
    @keyframes toastIn {
      from { transform: translateY(100%) scale(0.9); opacity: 0; }
      to { transform: translateY(0) scale(1); opacity: 1; }
    }

    /* --- TABS --- */
    .tab-bar {
      display: flex;
      border-bottom: 1px solid var(--border);
      gap: 1.5rem;
      margin-bottom: 1rem;
    }
    .tab-btn {
      padding: 0.75rem 0.25rem;
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--text-muted);
      border: none;
      background: none;
      cursor: pointer;
      border-bottom: 3px solid transparent;
      transition: all 0.15s;
    }
    .tab-btn:hover {
      color: var(--brand-blue);
    }
    .tab-btn.active {
      color: var(--brand-blue);
      border-bottom-color: var(--brand-yellow);
    }

    /* --- TABLES --- */
    .mc-table-container {
      overflow-x: auto;
    }
    table.mc-table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
      font-size: 0.875rem;
    }
    table.mc-table th {
      background-color: #F9FAFB;
      color: var(--text-muted);
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      padding: 0.75rem 1rem;
      border-bottom: 1px solid var(--border);
      font-weight: 700;
      cursor: pointer;
      user-select: none;
    }
    table.mc-table th:hover {
      background-color: #F3F4F6;
    }
    table.mc-table td {
      padding: 0.85rem 1rem;
      border-bottom: 1px solid var(--border);
      color: var(--text);
      vertical-align: middle;
    }
    table.mc-table tbody tr:hover {
      background-color: #F9FAFB;
    }

    /* --- CALLOUT BOXES --- */
    .callout-amber {
      background-color: #FFF4DE;
      border-left: 4px solid #B26A00;
      color: #7A4900;
      padding: 0.85rem 1rem;
      border-radius: 4px;
      font-size: 0.85rem;
      margin-bottom: 1rem;
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }
    .callout-green {
      background-color: var(--status-success-bg);
      border-left: 4px solid var(--status-success-text);
      color: #124D30;
      padding: 1rem;
      border-radius: 6px;
      margin-bottom: 1.25rem;
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }

    /* --- RESPONSIVE MEDIA QUERIES --- */
    @media (max-width: 1024px) {
      .app-sidebar { width: 70px; }
      .app-sidebar .logo-more, .app-sidebar .logo-divider, .app-sidebar .logo-cookies span, .app-sidebar .nav-text, .app-sidebar .sidebar-footer { display: none; }
      .app-sidebar .sidebar-header { justify-content: center; padding: 1rem 0; }
      .app-sidebar .nav-item { justify-content: center; padding: 0.85rem 0; }
      .app-main { margin-left: 70px; }
    }
    @media (max-width: 720px) {
      .app-layout { flex-direction: column; }
      .app-sidebar { width: 100%; height: auto; position: relative; }
      .app-sidebar .sidebar-menu { flex-direction: row; justify-content: space-around; padding: 0.5rem; }
      .app-sidebar .logo-more, .app-sidebar .logo-divider, .app-sidebar .logo-cookies span { display: inline-block; }
      .app-sidebar .sidebar-header { justify-content: space-between; padding: 0.75rem 1rem; }
      .app-main { margin-left: 0; }
      .app-topbar { padding: 0 1rem; flex-wrap: wrap; height: auto; py: 0.5rem; }
      .grid-3, .grid-2 { grid-template-columns: 1fr !important; }
    }

    /* Grid utilities */
    .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
    .grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
    .grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
    .grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; }
    @media (max-width: 1024px) {
      .grid-5 { grid-template-columns: repeat(2, 1fr) !important; }
      .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
    }
    @media (max-width: 640px) {
      .grid-5, .grid-4 { grid-template-columns: 1fr !important; }
    }

    /* Style for Acréscimo green badges and text */
    .mc-badge-acrescimo {
      background-color: #E6F4EC;
      color: #1E7F4F;
    }
    .text-acrescimo {
      color: #1E7F4F !important;
    }

    /* Custom SVG bar charts styling */
    .chart-container {
      width: 100%;
      height: 220px;
      position: relative;
    }
    .chart-tooltip {
      position: absolute;
      background: #262D3D;
      color: #FFF;
      padding: 4px 8px;
      border-radius: 4px;
      font-size: 0.75rem;
      pointer-events: none;
      display: none;
      z-index: 10;
      white-space: nowrap;
      box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }

    /* Screen view visibility */
    .view-screen { display: none; }
    .view-screen.active { display: block; animation: fadeIn 0.2s ease; }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(4px); }
      to { opacity: 1; transform: translateY(0); }
    }

/* ---- Complementos do app (mesma linguagem visual do modelo) ---- */
[hidden] { display: none !important; }
.btn-mc-primary:disabled, .btn-mc-secondary:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: .3rem .65rem !important; font-size: .75rem !important; }
.btn-green { background-color: #1E7F4F !important; border-color: #1E7F4F !important; }
.btn-danger-link { background: none; border: none; color: #B42318; font-weight: 600; cursor: pointer; font-size: .75rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .25rem; color: var(--brand-blue); }
.field .input, .field select { width: 100%; box-sizing: border-box; }
.modal-head { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--brand-blue); }
.modal-body { padding: 1.5rem; }
.modal-foot { padding: 1rem 1.5rem; background-color: #F9FAFB; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; }
.h-title { margin: 0; font-size: 1.5rem; font-weight: 800; color: var(--brand-blue); }
.h-sub { margin: .25rem 0 0 0; font-size: .875rem; color: var(--text-muted); }
.card-title { margin: 0 0 1rem 0; font-size: 1rem; font-weight: 800; color: var(--brand-blue); }
.kpi-label { font-size: .75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--brand-blue); }
.kpi-foot { font-size: .75rem; color: var(--text-muted); margin-top: .35rem; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 1.5rem; }
.link-strong { font-weight: 700; color: var(--brand-blue); text-decoration: none; cursor: pointer; }
.link-strong:hover { text-decoration: underline; }
.text-ded { color: #B42318 !important; }
.toast-msg.error { border-left-color: #B42318; }
.login-error { color: #B42318; font-size: .8rem; margin-top: .5rem; min-height: 1rem; }
.secret-box { font-family: ui-monospace, monospace; background: #F3F4F6; border: 1px dashed var(--border); padding: .75rem; border-radius: 6px; font-size: 1rem; text-align: center; user-select: all; }
.chart-container svg text { font-family: inherit; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
th[data-sort] { white-space: nowrap; }
