:root {
  color-scheme: light;
  --bg: #f0f1f3;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --navy: #172038;
  --black: #0b0b0b;
  --ink: #172038;
  --muted: #9a9ea6;
  --muted-2: #c7cad0;
  --line: #eef0f4;
  --line-strong: #dfe2e8;
  --blue: #3D67E8;
  --blue-2: #6B8FEF;
  --blue-3: #BACAF7;
  --blue-4: #E8EFFE;
  --green: #2E8B6E;
  --amber: #E05C20;
  --red: #C83D2F;
  --gray: #9a9ea6;
  --shadow: 0 2px 12px rgba(23, 32, 56, .07);
  --shadow-lg: 0 4px 20px rgba(23, 32, 56, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 246px 1fr;
}

.sidebar {
  background: var(--navy);
  color: white;
  padding: 34px 22px;
  border-right: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 0 30px rgba(23, 32, 56, .10);
}

.brand {
  margin-bottom: 34px;
}

.brand-kicker {
  color: var(--blue-3);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 8px 0 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
  font-weight: 700;
}

.brand-logo {
  display: inline-flex;
  align-items: baseline;
  margin-top: 8px;
}

.brand-logo .firmness,
.brand-logo .suffix {
  font-family: "Nunito", sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.brand-logo .firmness {
  color: #fff;
}

.brand-logo .suffix {
  color: var(--blue-2);
}

.brand-title {
  margin-top: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.auth .brand-logo .firmness {
  color: var(--navy);
}

.auth .brand-logo .suffix {
  color: var(--blue);
}

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

.nav button {
  width: 100%;
  border: 1px solid rgba(255,255,255,.08);
  background: transparent;
  color: #d8def2;
  text-align: left;
  padding: 11px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
}

.nav button.active {
  border-color: rgba(107,143,239,.55);
  background: rgba(61,103,232,.16);
  color: #fff;
}

.userbox {
  margin-top: 28px;
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 18px;
  color: #d8def2;
  font-size: 13px;
  line-height: 1.6;
}

.main {
  max-width: 1280px;
  width: 100%;
  padding: 46px 56px 80px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
  font-weight: 800;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
  border-radius: 7px;
  font-size: 12.5px;
  box-shadow: 0 1px 2px rgba(23,32,56,.03);
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn.blue {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

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

.btn:disabled {
  opacity: .45;
  cursor: default;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.auth .panel {
  width: min(100%, 520px);
  padding: 38px;
}

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

.grid {
  display: grid;
  gap: 14px;
}

.field label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted-2);
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.field textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.65;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.queue {
  display: grid;
  gap: 10px;
}

.queue-item {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.queue-item.active {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue), var(--shadow);
}

.task-section-title {
  margin: 34px 0 12px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.task-head {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: stretch;
  min-height: 88px;
}

.priority-strip {
  background: var(--gray);
}

.priority-strip.P1 { background: var(--red); }
.priority-strip.P2 { background: var(--amber); }
.priority-strip.P3 { background: var(--blue); }

.task-main {
  padding: 14px 0;
  min-width: 0;
}

.task-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.task-title {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 9px;
}

.task-side {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 0;
}

.timer {
  min-width: 112px;
  text-align: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  background: var(--surface-2);
}

.timer.ok { color: var(--blue); }
.timer.warn { color: var(--amber); }
.timer.danger { color: var(--red); }
.timer.paused { color: var(--gray); background: var(--surface-2); }

.bubble {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  background: var(--blue);
  color: white;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
}

.expand-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 7px;
  width: 36px;
  height: 36px;
  font-weight: 800;
}

.task-body {
  border-top: 1px solid var(--line);
  background: #f7f8fb;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 42%);
  gap: 16px;
}

.detail-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(23,32,56,.03);
}

.detail-block h4 {
  margin: 0 0 8px;
  font-size: 9.5px;
  color: var(--muted-2);
  letter-spacing: .14em;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-block p {
  margin: 0;
  line-height: 1.75;
}

.messages {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  grid-template-rows: minmax(220px, 1fr) auto;
  max-height: 620px;
}

.message-list {
  overflow-y: auto;
  padding: 14px;
}

.message {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.message:last-child {
  border-bottom: 0;
}

.message-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.message-author {
  color: var(--ink);
  font-weight: 800;
}

.message-content {
  white-space: pre-wrap;
  line-height: 1.7;
  margin-top: 5px;
}

.reads {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.composer textarea {
  width: 100%;
  min-height: 74px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric .value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 6px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table th, .table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 18px 18px 14px;
  }
  .brand {
    margin-bottom: 14px;
  }
  .brand-kicker {
    font-size: 8.5px;
  }
  .brand-logo .firmness,
  .brand-logo .suffix {
    font-size: 23px;
  }
  .brand-title {
    margin-top: 8px;
    font-size: 13px;
  }
  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .nav button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
    min-height: 38px;
  }
  .userbox {
    display: none;
  }
  .main {
    max-width: none;
    padding: 24px 18px 64px;
  }
  .split, .task-body { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }
  .auth {
    padding: 16px;
    align-items: start;
  }
  .auth .panel {
    margin-top: 34px;
    padding: 26px 22px;
  }
  .auth h1 {
    font-size: 24px;
    line-height: 1.25;
  }
  .main { padding: 18px 12px 56px; }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
  }
  .topbar h2 {
    font-size: 22px;
  }
  .toolbar {
    width: 100%;
  }
  .toolbar .btn,
  .actions .btn {
    flex: 1 1 auto;
    min-height: 42px;
  }
  .panel {
    border-radius: 10px;
    padding: 16px;
  }
  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
    padding: 11px 12px;
  }
  .field textarea {
    min-height: 150px;
  }
  .queue {
    gap: 8px;
  }
  .queue-item {
    text-align: left;
  }
  .task-section-title {
    margin: 24px 0 10px;
    font-size: 10px;
  }
  .task-list {
    gap: 8px;
  }
  .task-head {
    grid-template-columns: 6px minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
  }
  .priority-strip {
    grid-row: 1 / span 2;
  }
  .task-main {
    padding: 12px 10px 0 0;
  }
  .task-title-row {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  .task-title {
    flex: 1 1 100%;
    white-space: normal;
    line-height: 1.45;
    font-size: 15.5px;
  }
  .priority-tag,
  .status-tag {
    order: -1;
  }
  .task-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    margin-top: 8px;
    font-size: 12.5px;
  }
  .task-side {
    grid-column: 2;
    padding: 8px 10px 12px 0;
    justify-content: space-between;
    width: 100%;
  }
  .timer {
    min-width: 118px;
    padding: 8px;
    font-size: 12.5px;
  }
  .bubble {
    min-width: 30px;
    height: 30px;
  }
  .expand-btn {
    width: 42px;
    height: 38px;
  }
  .task-body {
    padding: 10px;
    gap: 10px;
  }
  .detail-block {
    border-radius: 8px;
    padding: 12px;
  }
  .messages {
    border-radius: 8px;
    max-height: none;
    grid-template-rows: auto auto;
  }
  .message-list {
    max-height: 380px;
    padding: 12px;
  }
  .message-top {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .composer {
    padding: 10px;
  }
  .composer textarea {
    min-height: 96px;
    font-size: 16px;
  }
  .actions {
    justify-content: stretch;
  }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .metric {
    padding: 12px;
  }
  .metric .value {
    font-size: 24px;
  }
  .table {
    min-width: 760px;
  }
}

@media (max-width: 420px) {
  .sidebar {
    padding: 14px 12px 10px;
  }
  .brand-logo .firmness,
  .brand-logo .suffix {
    font-size: 21px;
  }
  .nav button {
    font-size: 12px;
    padding: 9px 10px;
  }
  .main {
    padding: 14px 10px 50px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .task-side {
    gap: 6px;
  }
  .timer {
    min-width: 104px;
    font-size: 11.5px;
  }
}
