/* Shell of the module screens (js/shell.js). The cards reuse the classes of index.html. */
body:not([data-authenticated="true"]) #appNav,
body:not([data-authenticated="true"]) #homeTools,
body:not([data-authenticated="true"]) #screenHost { display: none; }

/* A module screen replaces the sections of the company dashboard. */
body[data-screen]:not([data-screen="dashboard"]) main > .dashboard-section,
body[data-screen]:not([data-screen="dashboard"]) main > #emptyState,
body[data-screen]:not([data-screen="dashboard"]) #homeTools { display: none !important; }
.home-tools, .period-tools { display: grid; gap: 8px; }
.onda1b-toolbar:empty { display: none; }
body[data-screen]:not([data-screen="dashboard"])[data-range="false"] .range-panel { display: none !important; }

/* ---- Visual base of the signed-in pages (foundation document, section 17) ----
   One accent, one radius, an 8 px grid, the system font, and a touch target of 44 px.
   No blur and no shadow: the page must stay fast on a slow phone. */
:root {
  --radius: 12px;
  --radius-control: 10px;
  --tap: 44px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

/* Light mode of the signed-in pages. The sign-in page stays dark. */
@media (prefers-color-scheme: light) {
  body[data-authenticated="true"] {
    color-scheme: light;
    --bg: #f5f5f7;
    --panel: #fff;
    --panel-elevated: #fff;
    --control: rgba(118, 118, 128, .12);
    --control-active: rgba(118, 118, 128, .2);
    --text: #1d1d1f;
    --muted: #6e6e73;
    --quiet: #8e8e93;
    --line: rgba(0, 0, 0, .1);
    --line-strong: rgba(0, 0, 0, .18);
    --accent: #0071e3;
    --good: #1a7f37;
    --warn: #b25000;
    --bad: #d70015;
    --hairline: none;
    background: var(--bg);
    color: var(--text);
  }
  /* The logo file is drawn for a dark page. */
  body[data-authenticated="true"] .compact-brand img { background: #1d1d1f; border-radius: 8px; padding: 4px 8px; }
}

a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Navigation: a quiet row of text links on a wide page ---- */
.app-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; margin: 0 0 12px; }
.app-nav[hidden], .screen-host[hidden] { display: none; }
.app-nav-toggle { display: none; }
.app-nav-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; margin-left: 12px; }
.app-nav-group-title { padding: 0 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
/* A link of a screen to another screen has the same class: a text link in the accent color. */
.app-nav-item { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--accent); font-size: 15px; text-decoration: none; }
.app-nav .app-nav-item { min-height: 36px; padding: 0 10px; border-radius: var(--radius-control); color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; }
.app-nav .app-nav-item:hover { background: var(--control); color: var(--text); }
.app-nav .app-nav-item[aria-current="page"] { background: var(--control); color: var(--text); font-weight: 600; }

/* ---- Period: the fixed ranges and "Período" are one segmented control; "Atualizar" is a separate action ---- */
body[data-authenticated="true"] .range-panel { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
.range-group { display: flex; flex: 1; flex-wrap: wrap; gap: 2px; min-width: 0; padding: 2px; border-radius: var(--radius); background: var(--control); }
body[data-authenticated="true"] .range-panel #rangePicker, .range-period-slot { display: contents; }
#rangeGroup button { flex: 1 1 auto; min-width: 0; min-height: var(--tap); padding: 0 8px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; transform: none; }
#rangeGroup button:not([aria-pressed="true"]):hover { background: var(--control); color: var(--text); }
#rangeGroup button[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: none; }
/* The button of the home route stays in the group while a screen shows; the screen has its own button. */
body:not([data-screen="dashboard"]) #rangePeriodSlot [data-owner="home"] { display: none; }
#refreshButton { min-width: 0; min-height: 48px; padding: 0 16px; border: 0; border-radius: var(--radius); background: var(--control); color: var(--accent); font-size: 14px; font-weight: 600; }
#refreshButton:hover { transform: none; }
/* The toolbar of the home route is in the same row: its button, then its message and its sheet on a full row. */
.range-panel .home-tools, .range-panel .home-tools > .period-tools { display: contents; }
.range-panel .home-tools[hidden] { display: none; }
.range-panel .period-tools > .onda1b-toolbar { margin: 0; }
.range-panel .period-tools > [data-slot="tools-message"], .range-panel .period-tools > [data-slot="period-sheet-host"] { flex: 1 1 100%; }
.range-panel .onda1b-button, #refreshButton { min-height: 48px; border-radius: var(--radius); }

/* ---- Section headings: one quiet style ---- */
.section-title { margin: 0 0 12px; color: var(--text); font-size: 17px; font-weight: 600; letter-spacing: 0; }
.section-note, .period-line { margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.dashboard-section { margin-top: 24px; }
.metric-value, .metric-number, .chart-card, .donut-card { font-variant-numeric: tabular-nums; }

/* ---- Phone: one bar with the title of the screen; the list opens from it ---- */
@media (max-width: 760px) {
  main {
    width: calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .app-topbar { min-height: 0; margin-bottom: 0; padding: 0 0 8px; border-bottom: 0; }
  .app-nav {
    display: block; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
    max-height: calc(100vh - env(safe-area-inset-top, 0px)); max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    overflow-y: auto; overscroll-behavior: contain;
    margin: 0 -16px 12px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .app-nav[data-open="true"] { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .app-nav-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px;
    padding: 0; border: 0; border-radius: 0; background: none; color: var(--text);
    font: inherit; font-size: 17px; font-weight: 600; text-align: left;
  }
  .app-nav-toggle:hover { background: none; transform: none; border-color: transparent; }
  .app-nav-toggle:focus-visible { outline-offset: -2px; border-radius: var(--radius-control); }
  .app-nav-toggle-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-nav-toggle-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--control); }
  .app-nav-toggle-icon::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-2px) rotate(45deg); transition: transform 200ms ease; }
  .app-nav-toggle[aria-expanded="true"] .app-nav-toggle-icon::before { transform: translateY(2px) rotate(225deg); }
  .app-nav:not([data-open="true"]) > :not(.app-nav-toggle) { display: none; }

  /* The open list: the groups are quiet headers, the screens are rows. */
  .app-nav-group { display: block; margin: 0; }
  .app-nav-group-title { display: block; padding: 20px 12px 8px; }
  .app-nav .app-nav-item {
    display: flex; justify-content: space-between; min-height: 48px; padding: 0 12px; border-radius: 0;
    background: var(--panel); box-shadow: inset 0 -1px 0 var(--line); color: var(--text); font-size: 16px; font-weight: 400; white-space: normal;
  }
  .app-nav > .app-nav-item { margin-top: 8px; border-radius: var(--radius); box-shadow: none; }
  .app-nav-group-title + .app-nav-item { border-radius: var(--radius) var(--radius) 0 0; }
  .app-nav-group .app-nav-item:last-child { border-radius: 0 0 var(--radius) var(--radius); box-shadow: none; }
  .app-nav-group-title + .app-nav-item:last-child { border-radius: var(--radius); }
  .app-nav .app-nav-item:hover { background: var(--panel); }
  .app-nav .app-nav-item[aria-current="page"] { background: var(--panel); color: var(--accent); font-weight: 600; }
  .app-nav .app-nav-item[aria-current="page"]::after { content: ""; flex: none; width: 6px; height: 11px; margin: 0 4px 3px 12px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }

  body[data-authenticated="true"] header { margin-bottom: 8px; }
  #rangeGroup button { padding: 0 4px; font-size: 13px; }
  .range-group { flex: 1 1 100%; }
  #refreshButton { width: auto; }
  .section-title { font-size: 16px; }
  .dashboard-section { margin-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-nav-toggle-icon::before { transition: none; }
}

.screen { display: grid; gap: 20px; }
/* The page styles of `header` are for the sign-in panel: a screen header is a plain block at the left. */
.screen .screen-header { display: block; width: auto; max-width: none; min-height: 0; margin: 0; padding: 0; text-align: left; }
.screen-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.screen-subtitle, .screen-note, .screen-error { margin: 0; opacity: .75; font-size: 14px; }
.screen-section { display: grid; gap: 12px; }
.screen-list { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.screen-row { display: grid; gap: 4px; min-height: var(--tap); padding: 12px 16px; border-radius: var(--radius); background: var(--panel); color: inherit; text-decoration: none; }
.screen-row.is-disabled { opacity: .5; }
.screen-row-title { font-weight: 600; }
.screen-row-subtitle, .screen-row-meta { font-size: 13px; opacity: .75; }
.screen-row-values { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: flex-end; }
.screen-value-label { display: block; font-size: 12px; opacity: .7; }
.screen-value-text { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.screen-value-unit { font-size: 12px; opacity: .7; margin-left: 2px; }
.screen-warning { color: #FF9500; font-weight: 600; font-size: 14px; }
.screen-status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; opacity: .85; }
.screen-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-color, #8E8E93); }
.screen-children { margin-left: 20px; }
.screen-empty { display: grid; gap: 6px; padding: 24px; text-align: center; }
.screen-table-wrap { overflow-x: auto; }
.screen-table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.screen-table th, .screen-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid rgba(127, 127, 127, .2); white-space: nowrap; }
.screen-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.screen > * { min-width: 0; }
/* "Níveis": one line, as a breadcrumb. A long name is cut with an ellipsis; the line scrolls inside itself. */
.screen-levels { display: flex; align-items: center; overflow-x: auto; scrollbar-width: none; white-space: nowrap; margin: -8px 0; }
.screen-levels::-webkit-scrollbar { display: none; }
.screen-levels-title { flex: none; margin-right: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.screen-levels-group { flex: none; margin-right: 8px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.screen-levels-item { display: block; flex: none; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; line-height: var(--tap); font-size: 14px; }
.screen-levels-item + .screen-levels-item::before { content: "\203A"; margin: 0 8px; color: var(--quiet); }
.screen-related { display: flex; flex-wrap: wrap; align-items: center; gap: 0 24px; }
.screen-row-note { font-size: 14px; opacity: .75; }
.screen-value { display: inline-block; }
.screen-telemetry-link, .screen-back-link { justify-self: start; }
.screen .dashboard-section { display: grid; gap: 12px; }
.period-tools .onda1b-toolbar { justify-content: flex-start; max-width: none; margin: 0; }
.period-tools [data-slot="tools-message"]:empty, .period-tools [data-slot="period-sheet-host"]:empty { display: none; }
