/* ==========================================================================
   Altitude Telecom — Call Summary Portal
   --------------------------------------------------------------------------
   Alpine palette: granite for dark surfaces, glacier blue for actions and
   data, a cool snowfield canvas. The one decorative motif is the mountain
   ridgeline under the header and the topographic contours on sign-in.

   No inline styles anywhere: the Content-Security-Policy sets
   style-src 'self', which blocks inline style attributes and <style> blocks.
   Fonts and images are self-hosted for the same reason (default-src 'self').

   To adopt official brand colours later, change the tokens in :root only.
   ========================================================================== */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url("/fonts/archivo-variable.woff2") format("woff2-variations"),
    url("/fonts/archivo-variable.woff2") format("woff2");
}

:root {
  /* Surfaces */
  --granite: #15212a;
  --granite-2: #1f2f3b;
  --ridge: #2b3f4c;
  --snow: #f3f6f8;
  --ice: #e4edf2;
  --white: #ffffff;
  --line: #d7e1e7;
  --line-soft: #e8eef2;

  /* Brand */
  --glacier: #1f6e93;
  --glacier-deep: #175572;
  --glacier-light: #7fc4e0;
  --glacier-wash: rgba(31, 110, 147, 0.1);

  /* Text */
  --ink: #142029;
  --ink-soft: #4d5f6c;
  --ink-faint: #8a9aa5;
  --on-dark: #e9f2f6;
  --on-dark-soft: #a9bcc8;

  /* Status */
  --pine: #2b7a4f;
  --pine-wash: #e1f1e7;
  --rust: #b0412b;
  --rust-wash: #f8e5e0;
  --melt: #8a5d00;
  --melt-wash: #f8eccc;
  --aspen: #d99a1e;

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;

  --shadow-panel: 0 1px 2px rgba(20, 32, 41, 0.05), 0 6px 18px rgba(20, 32, 41, 0.05);
  --shadow-float: 0 24px 60px rgba(10, 18, 24, 0.35);

  --gutter: clamp(16px, 3vw, 40px);
  --page-max: 1680px;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--snow);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--snow);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

p {
  margin-top: 0;
}

a {
  color: var(--glacier);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   Wordmark — the expanded width axis of Archivo carries the brand
   -------------------------------------------------------------------------- */

.wordmark {
  display: flex;
  flex-direction: column;
  margin: 0;
  line-height: 0.95;
  color: var(--on-dark);
}

.wordmark-main {
  font-size: 19px;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: 0.01em;
}

.wordmark-sub {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 500;
  font-stretch: 125%;
  letter-spacing: 0.32em;
  color: var(--glacier-light);
}

.wordmark-lg .wordmark-main {
  font-size: clamp(40px, 6vw, 68px);
  letter-spacing: -0.005em;
}

.wordmark-lg .wordmark-sub {
  margin-top: 10px;
  font-size: clamp(13px, 1.5vw, 17px);
  letter-spacing: 0.5em;
}

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

label {
  display: block;
  margin: 18px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234d5f6c' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px 8px;
}

input:hover,
select:hover {
  border-color: #b9c9d3;
}

input:focus,
select:focus {
  border-color: var(--glacier);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 110, 147, 0.2);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--glacier);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  color: var(--white);
  background: var(--glacier);
  border: 1px solid var(--glacier);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover {
  background: var(--glacier-deep);
  border-color: var(--glacier-deep);
}

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

button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.ghost-button {
  color: var(--glacier-deep);
  background: var(--white);
  border-color: var(--line);
}

.ghost-button:hover {
  color: var(--glacier-deep);
  background: var(--ice);
  border-color: #b9c9d3;
}

.danger-button {
  color: var(--rust);
  background: var(--white);
  border-color: #e3b9ae;
}

.danger-button:hover {
  color: var(--white);
  background: var(--rust);
  border-color: var(--rust);
}

.small-button {
  min-height: 32px;
  padding: 4px 11px;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Sign-in
   -------------------------------------------------------------------------- */

.login-page {
  background: var(--granite);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.85fr);
  min-height: 100vh;
}

.login-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 6vw, 72px);
  overflow: hidden;
  color: var(--on-dark);
  background:
    url("/brand/contours.svg") center / cover no-repeat,
    radial-gradient(120% 80% at 80% 20%, #23394a 0%, var(--granite) 60%);
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.login-mark {
  width: 56px;
  height: 56px;
}

.login-tagline {
  max-width: 26ch;
  margin: 0;
  font-size: clamp(18px, 1.8vw, 22px);
  font-weight: 400;
  line-height: 1.4;
  color: var(--on-dark-soft);
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 5vw, 72px);
  background: var(--white);
  animation: card-in 420ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.login-card > * {
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  margin-bottom: 8px;
  font-size: 28px;
  font-stretch: 110%;
  color: var(--granite);
}

.intro {
  margin: 0 0 18px;
  color: var(--ink-soft);
}

.login-card input {
  min-height: 46px;
}

.login-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 26px;
  font-size: 16px;
}

.message {
  min-height: 22px;
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.message[data-tone="error"] {
  font-weight: 600;
  color: var(--rust);
}

.login-footnote {
  margin: 28px 0 0;
  padding-top: 18px;
  font-size: 13px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line-soft);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   App header — granite bar with a ridgeline along its lower edge
   -------------------------------------------------------------------------- */

.site-header {
  position: relative;
  padding-bottom: 26px;
  color: var(--on-dark);
  background: var(--granite);
}

.site-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 28px;
  background: url("/brand/ridge.svg") center bottom / 100% 100% no-repeat;
  pointer-events: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(100%, var(--page-max));
  margin: 0 auto;
  padding: 18px var(--gutter) 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
}

.brand-divider {
  align-self: stretch;
  width: 1px;
  margin: 4px 6px;
  background: rgba(169, 188, 200, 0.3);
}

.page-title {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
}

.identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.identity-details {
  margin-right: 8px;
  text-align: right;
  line-height: 1.3;
}

.identity-name {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  color: var(--white);
}

.identity-meta {
  margin: 0;
  font-size: 12px;
  color: var(--on-dark-soft);
}

/* Header actions — quiet outlines on the dark bar */
.portal-nav-button,
.secondary-button,
.header-password-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--on-dark);
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  border: 1px solid rgba(169, 188, 200, 0.35);
  border-radius: var(--r-sm);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.portal-nav-button:hover,
.secondary-button:hover,
.header-password-button:hover {
  color: var(--white);
  background: rgba(127, 196, 224, 0.14);
  border-color: var(--glacier-light);
}

.portal-nav-button {
  color: var(--granite);
  background: var(--glacier-light);
  border-color: var(--glacier-light);
}

.portal-nav-button:hover {
  color: var(--granite);
  background: #a5d6ea;
  border-color: #a5d6ea;
}

.site-header :focus-visible {
  outline-color: var(--glacier-light);
}

/* --------------------------------------------------------------------------
   Page layout and panels
   -------------------------------------------------------------------------- */

.dashboard {
  width: min(100%, var(--page-max));
  margin: 0 auto;
  padding: 22px var(--gutter) 64px;
}

.panel {
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
  font-stretch: 110%;
  color: var(--granite);
}

.panel-body {
  padding: 22px 24px 26px;
}

.panel-hint,
#status-message {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.count-badge {
  padding: 4px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--glacier-deep);
  background: var(--ice);
  border-radius: 999px;
  white-space: nowrap;
}

.count-badge:empty {
  display: none;
}

/* --------------------------------------------------------------------------
   Analytics
   -------------------------------------------------------------------------- */

.analytics {
  margin-bottom: 18px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
}

.stat-card {
  display: flex;
  flex-direction: column;
  padding: 20px 24px 22px;
  background: var(--white);
}

.stat-value {
  order: 2;
  margin: 2px 0 0;
  font-size: clamp(28px, 2.6vw, 36px);
  font-weight: 700;
  font-stretch: 112%;
  line-height: 1.1;
  color: var(--granite);
}

.stat-label {
  order: 1;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.stat-hint {
  order: 3;
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-faint);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.chart-panel {
  display: flex;
  flex-direction: column;
}

.chart-panel:nth-child(1),
.chart-panel:nth-child(4),
.chart-panel:nth-child(5) {
  grid-column: span 2;
}

.chart-heading {
  padding: 16px 20px 0;
}

.chart-heading h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--granite);
}

.chart-body {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  height: 220px;
  padding: 14px 20px 18px;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: 100%;
  max-height: 200px;
  overflow: visible;
}

/* Bar charts scale with their viewBox; in the wide panels, cap the width
   so labels stay the same size as the narrower charts. */
#chart-resolved .chart-svg,
#chart-direction .chart-svg {
  max-width: 340px;
}

.chart-empty {
  width: 100%;
  margin: 0;
  font-size: 14px;
  text-align: center;
  color: var(--ink-faint);
}

.bar-fill {
  fill: var(--glacier);
}

.bar-fill-ok {
  fill: var(--pine);
}

.bar-fill-bad {
  fill: var(--rust);
}

.chart-label {
  font-family: var(--font);
  font-size: 11px;
  fill: var(--ink-soft);
}

.chart-value {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  fill: var(--granite);
}

.chart-gridline {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.line-area {
  fill: rgba(31, 110, 147, 0.12);
}

.line-stroke {
  fill: none;
  stroke: var(--glacier);
  stroke-width: 2.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.line-dot {
  fill: var(--white);
  stroke: var(--glacier);
  stroke-width: 2;
}

.hbar-list {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hbar-item {
  display: grid;
  grid-template-columns: 92px 1fr 34px;
  align-items: center;
  gap: 12px;
}

.hbar-item + .hbar-item {
  margin-top: 10px;
}

.hbar-label {
  font-size: 13px;
  color: var(--ink-soft);
}

.hbar-track {
  display: block;
  height: 10px;
  overflow: hidden;
  background: var(--ice);
  border-radius: 5px;
}

.hbar-svg {
  display: block;
  width: 100%;
  height: 10px;
}

.hbar-value {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  color: var(--granite);
}

/* --------------------------------------------------------------------------
   Filters
   -------------------------------------------------------------------------- */

.filter-panel {
  margin-bottom: 18px;
}

.filter-panel-heading {
  padding: 4px 16px;
}

.filter-toggle {
  min-height: 46px;
  padding: 8px 8px;
  font-size: 15px;
  font-weight: 650;
  color: var(--granite);
  background: none;
  border: 0;
}

.filter-toggle:hover {
  color: var(--glacier);
  background: none;
}

.filter-toggle-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 4px 3px 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.filter-toggle-open .filter-toggle-icon {
  margin-bottom: -3px;
  transform: rotate(-135deg);
}

.filter-count {
  min-width: 22px;
  font-size: 12px;
  text-align: center;
}

.filter-form {
  display: none;
}

.filter-form.is-open {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 16px 18px;
  padding: 20px 24px 24px;
  border-top: 1px solid var(--line-soft);
}

.filter-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.filter-field label {
  margin: 0 0 6px;
}

.filter-search {
  grid-column: span 2;
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-container {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line-soft);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  background: #f7f9fb;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.cell-data {
  white-space: nowrap;
}

.cell-empty {
  color: var(--ink-faint);
}

.call-row {
  cursor: pointer;
}

.call-row td {
  transition: background-color 100ms ease;
}

.call-row:hover td {
  background: #f0f6f9;
}

.call-row:focus-visible {
  outline: 2px solid var(--glacier);
  outline-offset: -2px;
}

/* Sortable headers */
.sort-button {
  min-height: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: 0;
}

.sort-button:hover {
  color: var(--glacier);
  background: none;
}

.sort-button::after {
  content: "\2195";
  margin-left: 4px;
  opacity: 0.3;
}

.sort-button.sort-active {
  color: var(--glacier-deep);
}

.sort-button.sort-active[aria-sort="ascending"]::after {
  content: "\2191";
  opacity: 1;
}

.sort-button.sort-active[aria-sort="descending"]::after {
  content: "\2193";
  opacity: 1;
}

/* Calls table: fixed columns, ellipsis, responsive column hiding instead of
   horizontal scrolling. */
#calls-table {
  table-layout: fixed;
}

#calls-table th,
#calls-table td {
  padding-right: 10px;
  padding-left: 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#calls-table th:first-child,
#calls-table td:first-child {
  padding-left: 24px;
}

#calls-table th:nth-child(1) { width: 14%; }
#calls-table th:nth-child(2) { width: 8%; }
#calls-table th:nth-child(3) { width: 11%; }
#calls-table th:nth-child(4) { width: 16%; }
#calls-table th:nth-child(5) { width: 12%; }
#calls-table th:nth-child(6) { width: 7%; }
#calls-table th:nth-child(7) { width: 10%; }
#calls-table th:nth-child(8) { width: 8%; }
#calls-table th:nth-child(9) { width: 14%; }

/* --------------------------------------------------------------------------
   Pills
   -------------------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 999px;
}

.pill-ok {
  color: var(--pine);
  background: var(--pine-wash);
}

.pill-warn {
  color: var(--melt);
  background: var(--melt-wash);
}

.pill-bad {
  color: var(--rust);
  background: var(--rust-wash);
}

.pill-muted {
  color: var(--ink-soft);
  background: var(--ice);
}

.self-pill {
  margin-left: 8px;
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */

.empty-state {
  padding: 56px 24px 60px;
  text-align: center;
}

.empty-state p {
  max-width: 46ch;
  margin: 0 auto;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   Dialogs
   -------------------------------------------------------------------------- */

.call-dialog {
  width: min(860px, calc(100vw - 32px));
  max-height: min(88vh, 920px);
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--white);
  border: 0;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
}

.call-dialog[open] {
  animation: dialog-in 200ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.call-dialog::backdrop {
  background: rgba(15, 24, 31, 0.6);
}

.password-dialog {
  width: min(520px, calc(100vw - 32px));
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 22px;
  color: var(--on-dark);
  background: var(--granite);
}

.dialog-head h2 {
  margin: 0;
  font-size: 21px;
  font-stretch: 108%;
  color: var(--white);
}

.dialog-head .eyebrow {
  color: var(--glacier-light);
}

.dialog-body {
  max-height: calc(88vh - 110px);
  padding: 26px 28px 32px;
  overflow-y: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px 20px;
  margin: 0 0 28px;
}

.detail-grid dt {
  padding-top: 1px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.detail-grid dd {
  margin: 0;
}

.detail-file {
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: var(--ink-soft);
}

.party-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.party-list li + li {
  margin-top: 8px;
}

.party-name {
  font-weight: 650;
}

.party-meta {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
}

.stars {
  display: flex;
  align-items: center;
  gap: 3px;
}

.star {
  font-size: 18px;
  line-height: 1;
}

.star-filled {
  color: var(--aspen);
}

.star-empty {
  color: var(--line);
}

.star-label {
  margin-left: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.transcript-heading {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--granite);
}

.transcript {
  max-width: 78ch;
  margin: 0;
  padding: 18px 20px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--snow);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}

.password-form {
  display: grid;
  gap: 16px;
}

/* --------------------------------------------------------------------------
   Administration
   -------------------------------------------------------------------------- */

.admin-panel {
  margin-bottom: 18px;
}

.admin-message {
  min-height: 0;
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--ink-soft);
}

.admin-message:empty {
  margin: 0;
}

.admin-message[data-tone="error"] {
  padding: 11px 14px;
  font-weight: 600;
  color: var(--rust);
  background: var(--rust-wash);
  border-radius: var(--r-sm);
}

.admin-message[data-tone="ok"] {
  padding: 11px 14px;
  font-weight: 600;
  color: var(--pine);
  background: var(--pine-wash);
  border-radius: var(--r-sm);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(240px, 480px) auto;
  align-items: end;
  justify-content: start;
  gap: 14px;
  margin-bottom: 18px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  align-items: start;
}

.admin-form .permission-set,
.admin-form .filter-actions {
  grid-column: 1 / -1;
}

.admin-form .filter-actions {
  justify-content: flex-start;
}

.permission-set {
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.permission-set legend {
  padding: 0 6px;
  font-size: 14px;
  font-weight: 650;
  color: var(--granite);
}

.permission-set > .panel-hint {
  margin: 0;
}

.permission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 22px;
  margin-top: 12px;
}

.permission-item {
  display: flex;
  gap: 10px;
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
}

.permission-item input {
  flex: 0 0 auto;
  margin-top: 2px;
}

.permission-label {
  display: block;
  font-weight: 650;
}

.permission-description {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
}

.org-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.org-list li {
  padding: 5px 12px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--snow);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
}

#users-table {
  min-width: 1040px;
  table-layout: fixed;
}

#users-table th:first-child,
#users-table td:first-child {
  padding-left: 24px;
}

#users-table th:nth-child(1) { width: 14%; }
#users-table th:nth-child(2) { width: 20%; }
#users-table th:nth-child(3) { width: 14%; }
#users-table th:nth-child(4) { width: 11%; }
#users-table th:nth-child(5) { width: 20%; }
#users-table th:nth-child(6) { width: 8%; }
#users-table th:nth-child(7) { width: 13%; }

#users-table td {
  height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#users-table td:last-child {
  overflow: visible;
  white-space: nowrap;
}

.permission-cell {
  max-width: 0;
  white-space: nowrap;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1240px) {
  .identity-details {
    display: none;
  }

  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-panel:nth-child(1) {
    grid-column: 1 / -1;
  }

  .chart-panel:nth-child(4),
  .chart-panel:nth-child(5) {
    grid-column: span 1;
  }

  .filter-form.is-open {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #calls-table th:nth-child(5),
  #calls-table td:nth-child(5),
  #calls-table th:nth-child(6),
  #calls-table td:nth-child(6) {
    display: none;
  }

  #calls-table th:nth-child(1) { width: 18%; }
  #calls-table th:nth-child(2) { width: 10%; }
  #calls-table th:nth-child(3) { width: 14%; }
  #calls-table th:nth-child(4) { width: 22%; }
  #calls-table th:nth-child(7) { width: 12%; }
  #calls-table th:nth-child(8) { width: 10%; }
  #calls-table th:nth-child(9) { width: 14%; }
}

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-aside {
    min-height: 0;
    padding: 28px 24px 32px;
  }

  .login-brand {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }

  .login-mark {
    width: 44px;
    height: 44px;
  }

  .wordmark-lg .wordmark-main {
    font-size: 34px;
  }

  .wordmark-lg .wordmark-sub {
    margin-top: 6px;
    font-size: 12px;
  }

  .login-tagline {
    margin-top: 20px;
    font-size: 16px;
  }

  .login-card {
    align-items: center;
    padding: 36px 24px 48px;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .identity {
    flex-wrap: wrap;
  }

  .chart-grid,
  .admin-form {
    grid-template-columns: 1fr;
  }

  .chart-panel:nth-child(1),
  .chart-panel:nth-child(4),
  .chart-panel:nth-child(5) {
    grid-column: auto;
  }

  .filter-form.is-open {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #calls-table th:nth-child(9),
  #calls-table td:nth-child(9) {
    display: none;
  }

  #calls-table th:nth-child(1) { width: 24%; }
  #calls-table th:nth-child(2) { width: 14%; }
  #calls-table th:nth-child(3) { width: 20%; }
  #calls-table th:nth-child(4) { width: 20%; }
  #calls-table th:nth-child(7) { width: 12%; }
  #calls-table th:nth-child(8) { width: 10%; }

  #users-table th:nth-child(3),
  #users-table td:nth-child(3) {
    display: none;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .brand-divider,
  .page-title {
    display: none;
  }

  .identity {
    width: 100%;
  }

  .identity > * {
    flex: 1 1 auto;
  }

  .stat-row {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 16px;
  }

  .filter-form.is-open {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .filter-search {
    grid-column: auto;
  }

  .filter-actions button {
    flex: 1;
  }

  .panel-heading,
  .panel-body {
    padding-right: 16px;
    padding-left: 16px;
  }

  #calls-table th:first-child,
  #calls-table td:first-child {
    padding-left: 16px;
  }

  #calls-table th:nth-child(3),
  #calls-table td:nth-child(3),
  #calls-table th:nth-child(7),
  #calls-table td:nth-child(7) {
    display: none;
  }

  #calls-table th:nth-child(1) { width: 34%; }
  #calls-table th:nth-child(2) { width: 20%; }
  #calls-table th:nth-child(4) { width: 28%; }
  #calls-table th:nth-child(8) { width: 18%; }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .detail-grid dd {
    margin-bottom: 14px;
  }

  .dialog-head,
  .dialog-body {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
