:root {
  --pico-spacing: 0.6rem;
  --sidebar-width: 250px;
  --sidebar-bg: #121923;
}
[x-cloak] { display: none !important; }
body {
  margin: 0;
  background: #11161f;
}
.app-shell {
  min-height: 100vh;
  position: relative;
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.login-card {
  width: min(420px, 100%);
  margin: 0;
  padding: 1.1rem;
  border: 1px solid rgba(92, 151, 255, 0.18);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(19, 26, 36, 0.96), rgba(16, 22, 31, 0.98));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.login-form {
  display: grid;
  gap: .7rem;
}
.login-form label {
  display: grid;
  gap: .35rem;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  padding: 1rem 0.8rem;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--pico-muted-border-color);
  overflow-y: auto;
  transform: translateX(-105%);
  transition: transform .18s ease;
  z-index: 30;
}
.sidebar.open { transform: translateX(0); }
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.sidebar-head p { margin: .2rem 0 0; }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.sidebar-nav button,
.sidebar-close,
.sidebar-toggle {
  font: inherit;
}
.sidebar-nav button {
  width: 100%;
  margin: 0;
  padding: .7rem .8rem;
  text-align: left;
  background: transparent;
  color: var(--pico-color);
  border: 1px solid transparent;
  border-radius: 10px;
}
.sidebar-nav button:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--pico-muted-border-color);
}
.sidebar-nav button.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-color: var(--pico-primary-background);
}
.sidebar-close,
.sidebar-toggle {
  width: auto;
  margin: 0;
  padding: .45rem .7rem;
  border-radius: 8px;
  font-size: 0;
}
.sidebar-close::after,
.sidebar-toggle::after {
  font-size: .85rem;
}
.sidebar-close::after {
  content: 'Close';
}
.sidebar-toggle::after {
  content: 'Menu';
}
.page-shell {
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
  padding: 1rem 1.25rem 1.5rem;
}
.content-shell {
  width: 100%;
  max-width: none;
}
.content-shell > section {
  width: 100%;
}
.topbar {
  margin-bottom: 1rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.topbar-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .85rem;
}
.topbar-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  margin-left: auto;
  flex-wrap: wrap;
}
.auth-meta {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.auth-badge {
  display: inline-flex;
  align-items: center;
  padding: .16rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.auth-badge.admin {
  color: #fff;
  background: #1d8d4a;
}
.auth-badge.responsible {
  color: #dbe7ff;
  background: rgba(92, 151, 255, 0.18);
  border-color: rgba(92, 151, 255, 0.28);
}
.topbar hgroup { margin: 0; }
.topbar h2 { margin-bottom: .2rem; }
.topbar p { margin: 0; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; margin-left: .5rem; }
.badge.on  { background: #1d8d4a; color: white; }
.badge.off { background: #555; color: #ddd; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip { display: inline-block; padding: .25rem .8rem; border: 1px solid var(--pico-muted-border-color); border-radius: 999px; text-decoration: none; }
.chip:hover { background: var(--pico-primary-background); color: var(--pico-primary-inverse); }
.muted { opacity: .7; }
.small { font-size: .8rem; }
.tiny { padding: .15rem .55rem !important; font-size: .75rem !important; margin: 0 .15rem !important; width: auto !important; }
.error { color: #c33; }
.table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--pico-muted-border-color); border-radius: 6px; margin-top: .5rem; }
.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #161d29;
  box-shadow: inset 0 -1px 0 var(--pico-muted-border-color);
}
.table-wrap thead th.clickable {
  cursor: pointer;
  user-select: none;
  transition: color .16s ease, background-color .16s ease;
}
.table-wrap thead th.clickable:hover {
  color: #74b9ff;
  background: #1b2433;
}
.app-card.fullscreen-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  padding: 1rem;
  background: #11161f;
  box-sizing: border-box;
  overflow: hidden;
}
.app-card.fullscreen-card .app-card-header {
  flex: 0 0 auto;
}
.app-card.fullscreen-card .app-card-body {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: .25rem;
  scrollbar-gutter: stable;
}
.app-card.fullscreen-card .app-card-controls {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #11161f;
  padding-bottom: .35rem;
}
.app-body-tools {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 .35rem;
}
.row-compact {
  align-items: center;
  gap: .45rem;
}
.compact-filter {
  max-width: 360px;
  min-height: 2.25rem;
  padding: .35rem .7rem;
  font-size: .9rem;
}
.filter-panel-anchor {
  position: relative;
}
.filter-trigger {
  min-height: 2.25rem;
  white-space: nowrap;
}
.filter-panel {
  position: absolute;
  top: calc(100% + .45rem);
  left: 0;
  z-index: 30;
  width: min(38rem, 90vw);
  max-width: calc(100vw - 1rem);
  max-height: min(70vh, 32rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: .85rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: .65rem;
  background: #131a24;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}
.filter-panel-section + .filter-panel-section {
  margin-top: .8rem;
  padding-top: .8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.filter-panel-title {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #9fb4cc;
  margin-bottom: .45rem;
}
.filter-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .45rem;
}
.filter-check {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .42rem .5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: .45rem;
  background: rgba(255, 255, 255, 0.02);
  margin: 0;
  font-size: .82rem;
}
.filter-check input {
  margin: 0;
}
.filter-rule-list {
  display: grid;
  gap: .45rem;
  margin-bottom: .45rem;
}
.filter-rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 5.5rem minmax(0, 1fr) auto;
  gap: .45rem;
  align-items: center;
}
.filter-rule-row select,
.filter-rule-row input {
  margin: 0;
}
.filter-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: .45rem;
  margin-top: .85rem;
}
.monitoring-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .55rem;
  margin: .6rem 0 .35rem;
}
.monitoring-summary-strip article {
  padding: .7rem .75rem;
  border: 1px solid rgba(92, 151, 255, 0.16);
  border-radius: .55rem;
  background: linear-gradient(180deg, rgba(92, 151, 255, 0.10), rgba(92, 151, 255, 0.03));
}
.monitoring-summary-strip article strong {
  display: block;
  margin-bottom: .25rem;
  font-size: .78rem;
  color: #9fb4cc;
}
.monitoring-summary-strip article div {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.deploy-status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .55rem;
  margin: .35rem 0 .85rem;
}
.deploy-status-strip article {
  margin: 0;
  padding: .65rem .75rem;
  border: 1px solid rgba(92, 151, 255, 0.16);
  border-radius: .5rem;
  background: rgba(255, 255, 255, 0.025);
}
.deploy-status-strip strong {
  display: block;
  margin-bottom: .25rem;
  color: #9fb4cc;
  font-size: .78rem;
}
.deploy-status-strip div {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  flex-wrap: wrap;
}
.table-pager {
  align-items: center;
  justify-content: flex-end;
  margin-top: .5rem;
}
.app-card.fullscreen-card .table-wrap {
  height: calc(100vh - 18rem);
  max-height: none;
  min-height: 20rem;
  overflow: auto;
  overscroll-behavior: auto;
}
.app-card.fullscreen-card .app-card-controls[style*="display: none"] + .table-wrap {
  height: calc(100vh - 8rem);
}
table { font-size: .85rem; }
.table-wrap tbody tr.clickable { cursor: pointer; }
.table-wrap tbody tr.clickable:hover { background: rgba(29, 141, 74, 0.12); }
.table-wrap tbody tr.status-active { background: rgba(29, 141, 74, 0.06); }
.table-wrap tbody tr.status-disable { background: rgba(220, 53, 69, 0.14); }
.table-wrap tbody tr.status-locked { background: rgba(220, 53, 69, 0.10); }
.table-wrap tbody tr.status-old { background: rgba(220, 53, 69, 0.08); }
.table-wrap tbody tr.group-summary-row {
  background: rgba(92, 151, 255, 0.10);
  font-weight: 600;
}
.table-wrap tbody tr.group-summary-row:hover {
  background: rgba(92, 151, 255, 0.16);
}
.table-wrap tbody tr.group-child-row td {
  background: rgba(255, 255, 255, 0.02);
}
.table-wrap tbody td.group-child-label {
  padding-left: 1.4rem;
}
.table-wrap tbody td.negative-cell {
  color: #ff7d88;
  font-weight: 600;
}
.linkish {
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: color .16s ease, text-decoration-color .16s ease;
}
.table-wrap tbody tr.clickable:hover td.linkish,
.table-wrap tbody td.linkish:hover {
  color: #74b9ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.logs { max-height: 60vh; overflow: auto; background: #111; color: #ddd; padding: .5rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; }
.logs .stderr span { color: #f99; }
.logs .meta span { color: #6cf; font-style: italic; }
article footer button { margin-right: .35rem; }
form { display: flex; gap: .35rem; flex-wrap: wrap; align-items: end; }
form input { flex: 1 1 140px; min-width: 120px; }
ul { list-style: none; padding-left: 0; }
ul li { padding: .25rem 0; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.responsible-note + p {
  display: none;
}
dialog[open] { max-width: 96vw; }
.breakdown-modal {
  width: min(1320px, 96vw);
  min-width: min(1320px, 96vw);
}
.breakdown-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: .55rem;
}
.breakdown-summary-grid article {
  min-width: 0;
  padding: .7rem .75rem;
}
.breakdown-summary-grid article strong {
  display: block;
  margin-bottom: .3rem;
  font-size: .88rem;
  line-height: 1.15;
  word-break: normal;
  overflow-wrap: break-word;
}
.breakdown-summary-grid article div {
  font-size: 1.05rem;
  line-height: 1.22;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.app-card {
  width: 100%;
  margin-bottom: 1.5rem;
  box-sizing: border-box;
  content-visibility: auto;
  contain-intrinsic-size: 500px;
}
.app-card-header { margin-bottom: 0; }
.app-card-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
}
.app-card-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.app-card-action {
  font-size: .8rem;
  opacity: .75;
  padding: .2rem .65rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 999px;
}
.subtabs { display: flex; gap: .25rem; flex-wrap: wrap; margin: .75rem 0; border-bottom: 1px solid var(--pico-muted-border-color); padding-bottom: .25rem; }
.subtabs button { background: transparent; color: var(--pico-color); border: 1px solid var(--pico-muted-border-color); padding: .25rem .7rem; border-radius: 4px; font-size: .8rem; }
.subtabs button.active { background: var(--pico-primary-background); color: var(--pico-primary-inverse); border-color: var(--pico-primary-background); }
.subtabs button.updating { background: #1d8d4a; color: #fff; border-color: #1d8d4a; }
.subtabs button.report-ready { border-color: #1d8d4a; color: #9be8b2; }
.subtabs button.report-ready.active { background: #1d8d4a; color: #fff; border-color: #1d8d4a; }
.subtabs button.report-waiting,
.subtabs button.report-error { border-color: #b33939; color: #ffb3b3; }
.subtabs button.report-waiting.active,
.subtabs button.report-error.active { background: #8b2626; color: #fff; border-color: #8b2626; }
.breakdown-modal .grid article.summary-excluded {
  border: 1px solid rgba(220, 53, 69, 0.35);
  background: rgba(220, 53, 69, 0.12);
}
.breakdown-modal .grid article.summary-excluded,
.breakdown-modal .grid article.summary-excluded strong,
.breakdown-modal .grid article.summary-excluded div {
  color: #ff8f99;
}
label.inline { display: inline-flex; align-items: center; gap: .35rem; margin: 0 .5rem 0 0; font-size: .85rem; }
label.inline input[type=checkbox] { margin: 0; }
label.inline input[type=number] { display: inline-block; padding: .15rem .4rem; margin: 0; font-size: .85rem; }
@media (min-width: 1024px) {
  .sidebar-backdrop { display: none !important; }
  .page-shell {
    padding-left: calc(var(--sidebar-width) + 1.5rem);
    transition: padding-left .18s ease;
  }
  .page-shell.sidebar-hidden {
    padding-left: 1.25rem;
  }
}
@media (max-width: 768px) {
  .page-shell {
    padding: .85rem .85rem 1.25rem;
  }
  .topbar-main {
    flex-direction: column;
    gap: .6rem;
  }
  .topbar-meta {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }
  .content-shell {
    max-width: 100%;
  }
  .filter-panel {
    width: min(28rem, calc(100vw - 2rem));
  }
  .filter-rule-row {
    grid-template-columns: 1fr;
  }
}

/* Activity controls + commission highlights */
.activity-controls {
  background: rgba(80, 130, 200, 0.08);
  padding: .5rem .75rem;
  border-radius: .35rem;
  margin: .35rem 0;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem;
}
.activity-controls strong {
  color: #dbe7ff;
  margin-right: .35rem;
}
.activity-controls select {
  width: auto;
  min-width: 9rem;
}
.summary-commission {
  border-left: 3px solid #4a8;
}
.breakdown-supervisor {
  background: rgba(180, 140, 60, 0.08);
  padding: .4rem .65rem;
  border-radius: .35rem;
  margin: .35rem 0;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.breakdown-supervisor input {
  margin: 0;
}
.breakdown-supervisor.readonly {
  justify-content: flex-start;
}
