:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --ink: #17211f;
  --muted: #66736f;
  --line: #dce5e1;
  --panel: #ffffff;
  --green: #1f9d63;
  --green-dark: #117246;
  --blue: #2563eb;
  --red: #d12f2f;
  --amber: #b7791f;
  --shadow: 0 18px 50px rgba(30, 44, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.button-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

button:hover {
  border-color: #b9c9c3;
}

button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.sidebar {
  min-height: 100vh;
  background: #17211f;
  color: #edf7f3;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  font-weight: 800;
}

.brand small,
.meta-status {
  display: block;
  color: #a9bdb5;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #d6e7e0;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: transparent;
}

main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 17px;
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.toolbar,
.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workgrid,
.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e9f7ef;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

.pill.muted {
  background: #eef2f6;
  color: var(--muted);
}

.incoming-empty,
.live-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 1px dashed #c8d6d1;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.call-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 14px;
  background: #fbfdfc;
}

.operator-shell {
  grid-template-columns: 1fr;
}

.operator-main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.operator-header {
  background: #17211f;
  color: #fff;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.operator-header p {
  color: #b9cdc5;
  margin-top: 4px;
}

.operator-header .toolbar {
  align-items: center;
}

.operator-header select {
  min-width: 220px;
}

.user-menu {
  position: relative;
}

.user-menu-button {
  min-width: 180px;
  justify-content: space-between;
  background: #fff;
}

.user-menu-button::after {
  content: "⌄";
  margin-left: 12px;
  font-size: 18px;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 6px;
}

.user-menu-panel button {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
}

.operator-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1.2fr);
  gap: 18px;
}

.operator-layout.single {
  grid-template-columns: 1fr;
}

.operator-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.operator-history {
  margin-top: 18px;
}

.incoming-toast {
  position: sticky;
  top: 14px;
  z-index: 5;
  margin-bottom: 18px;
  border: 1px solid #b7e2ca;
  border-radius: 8px;
  background: #f1fbf6;
  box-shadow: var(--shadow);
  padding: 14px;
}

.call-person {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.call-person strong {
  font-size: 22px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.8fr 0.8fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.row small,
.muted {
  color: var(--muted);
}

.status {
  font-weight: 800;
}

.status.ringing,
.status.assigned {
  color: var(--amber);
}

.status.live,
.status.completed {
  color: var(--green-dark);
}

.status.missed,
.status.failed {
  color: var(--red);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  font-size: 26px;
}

.metric span {
  color: var(--muted);
}

.bars {
  display: grid;
  gap: 9px;
}

.bar {
  display: grid;
  grid-template-columns: 44px 1fr 32px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8efec;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

.operators-admin {
  display: grid;
  gap: 10px;
}

.operator-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.settings-form {
  max-width: 620px;
  display: grid;
  gap: 14px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.settings-form .check {
  display: flex;
  align-items: center;
  gap: 10px;
}

dialog {
  border: 0;
  border-radius: 8px;
  max-width: 720px;
  width: min(720px, calc(100vw - 28px));
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(12, 20, 18, 0.45);
}

dialog article {
  padding: 22px;
  position: relative;
}

.icon-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  padding: 0;
  font-size: 24px;
}

.transcript {
  white-space: pre-wrap;
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

audio {
  width: 100%;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .workgrid,
  .split,
  .metrics,
  .operator-stats {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .row,
  .operator-card {
    grid-template-columns: 1fr;
  }
}
