* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f6f8;
  color: #17191c;
}
button, input, select {
  font: inherit;
}
button {
  border: 0;
  background: #1f6feb;
  color: white;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
}
button.secondary {
  background: #e8ebef;
  color: #1b1f24;
}
button.link-button {
  background: transparent;
  color: #1f6feb;
  padding: 0;
  text-align: left;
  font-weight: 600;
}
button:disabled {
  opacity: .5;
  cursor: not-allowed;
}
input, select {
  width: 100%;
  border: 1px solid #d7dce2;
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
}
label {
  display: grid;
  gap: 6px;
  color: #49515a;
  font-size: 13px;
}
.hidden { display: none !important; }
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login .panel {
  width: min(420px, calc(100vw - 32px));
}
.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}
.app-header, .toolbar, .panel-title, .row, .header-actions, .page-title, .page-actions, .picker-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}
.app-header, .panel-title, .page-title {
  justify-content: space-between;
}
h1, h2, h3, p {
  margin: 0;
}
h1 { font-size: 22px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.app-header {
  margin-bottom: 16px;
}
#me, #status, #selectedCount {
  color: #68717d;
  font-size: 13px;
}
.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.hint {
  color: #68717d;
  font-size: 12px;
}
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid #dfe3e8;
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #49515a;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active {
  color: #1f6feb;
  background: white;
  border: 1px solid #dfe3e8;
  border-bottom-color: white;
  margin-bottom: -1px;
}
.tab-page {
  display: none;
}
.tab-page.active {
  display: block;
}
.page-title {
  margin-bottom: 16px;
  align-items: flex-start;
}
.page-title p {
  color: #68717d;
  font-size: 13px;
  margin-top: 4px;
}
.page-actions {
  min-width: 280px;
  justify-content: flex-end;
}
.two-column {
  display: grid;
  grid-template-columns: minmax(360px, .78fr) minmax(460px, 1.22fr);
  gap: 16px;
  align-items: start;
}
.panel {
  background: white;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.panel + .panel {
  margin-top: 0;
}
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 12px 0;
}
.picker-toolbar {
  margin: 12px 0;
}
.picker-toolbar input {
  min-width: 180px;
}
.picker-toolbar button {
  flex: 0 0 auto;
}
.user-picker {
  display: grid;
  gap: 6px;
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}
.picker-user {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px;
  border: 1px solid #edf0f3;
  border-radius: 6px;
  color: #17191c;
  background: #fbfcfd;
}
.picker-user input {
  width: auto;
  margin-top: 2px;
}
.picker-user span {
  min-width: 0;
}
.picker-user span span {
  display: block;
  color: #68717d;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.selected-summary {
  border: 1px solid #edf0f3;
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}
.summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.summary-list span {
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef3ff;
  color: #174ea6;
  font-size: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
th, td {
  border-bottom: 1px solid #edf0f3;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
th {
  color: #68717d;
  font-weight: 600;
  font-size: 12px;
}
td:first-child, th:first-child {
  width: 34px;
}
.email {
  color: #68717d;
  font-size: 12px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef3ff;
  color: #174ea6;
  font-size: 12px;
}
.chip button {
  padding: 0;
  background: transparent;
  color: inherit;
}
.groups {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.group {
  border: 1px solid #edf0f3;
  border-radius: 6px;
  padding: 10px;
}
.group strong {
  display: block;
  margin-bottom: 8px;
}
.group label {
  display: flex;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: #17191c;
  margin: 5px 0;
}
.group input[type="checkbox"] {
  width: auto;
}
.panel:has(> label),
.panel:has(> .action-grid) {
  display: grid;
  gap: 12px;
}
.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.charts canvas {
  width: 100%;
  max-height: 340px;
}
.chat-layout {
  display: grid;
  grid-template-columns: minmax(420px, .85fr) minmax(520px, 1.15fr);
  gap: 16px;
  margin-top: 16px;
}
.policy-grid {
  display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
.policy-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.policy-list div {
  display: grid;
  grid-template-columns: minmax(140px, .55fr) minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #edf0f3;
}
.policy-list div:last-child {
  border-bottom: 0;
}
.policy-list span {
  color: #49515a;
}
.compact-table th,
.compact-table td {
  font-size: 13px;
}
.cost-panel {
  margin-top: 16px;
}
.cost-drivers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.cost-drivers article {
  border: 1px solid #edf0f3;
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfd;
}
.cost-drivers strong {
  display: block;
  margin-bottom: 6px;
}
.cost-drivers p {
  color: #49515a;
  font-size: 13px;
  line-height: 1.4;
}
.chat-list {
  overflow: auto;
  max-height: 760px;
}
.chat-detail {
  border: 1px solid #edf0f3;
  border-radius: 6px;
  min-height: 280px;
  max-height: 760px;
  overflow: auto;
  padding: 12px;
  background: #fbfcfd;
}
.active-row {
  background: #f0f6ff;
}
.empty {
  color: #68717d;
  padding: 24px;
  text-align: center;
}
.empty.compact {
  padding: 14px;
  border: 1px dashed #d7dce2;
  border-radius: 6px;
}
.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
h3 {
  margin: 0 0 4px;
}
.messages {
  display: grid;
  gap: 12px;
}
.message {
  border: 1px solid #e5e9ef;
  border-radius: 6px;
  padding: 12px;
  background: white;
}
.user-message {
  border-left: 4px solid #68717d;
}
.assistant-message {
  border-left: 4px solid #1f6feb;
}
.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #68717d;
  font-size: 12px;
  margin-bottom: 8px;
}
.message-meta strong {
  color: #17191c;
}
.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 10px;
}
.settings {
  margin: 8px 0;
}
.settings summary {
  cursor: pointer;
  color: #49515a;
  font-size: 12px;
  font-weight: 600;
}
pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 6px;
  background: #f3f5f7;
  overflow: auto;
  font-size: 12px;
  line-height: 1.35;
}
.tx-table {
  margin-top: 8px;
}
.tx-table th,
.tx-table td {
  font-size: 12px;
  padding: 7px 6px;
}
.error {
  color: #b42318;
  min-height: 20px;
  font-size: 13px;
}
@media (max-width: 1100px) {
  .two-column, .charts, .chat-layout, .policy-grid, .cost-drivers {
    grid-template-columns: 1fr;
  }
  .chat-detail {
    max-height: none;
  }
}
@media (max-width: 720px) {
  .app {
    padding: 12px;
  }
  .app-header, .page-title, .panel-title, .row, .header-actions, .picker-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .page-actions {
    min-width: 0;
    width: 100%;
  }
  .filters {
    width: 100%;
  }
  .action-grid {
    grid-template-columns: 1fr;
  }
  th, td {
    padding: 8px 6px;
  }
}
