:root {
  color-scheme: light;
  --canvas: #f4f6f8;
  --ink: #1a2733;
  --muted: #586977;
  --line: #dce3e9;
  --blue: #1d5f8a;
  --blue-dark: #124b70;
  --sidebar: #122635;
  font: 15px/1.55 system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--blue-dark); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.55rem); line-height: 1.1; letter-spacing: -.035em; margin-bottom: 22px; }
h2 { font-size: 1.2rem; line-height: 1.25; margin-bottom: 15px; }
.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
aside { background: var(--sidebar); color: #fff; padding: 25px 16px; display: flex; flex-direction: column; gap: 25px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #fff; text-decoration: none; }
.brand span { background: #33556a; border-radius: 8px; padding: 3px 9px; }
aside nav { display: grid; gap: 5px; }
aside nav a { padding: 8px 12px; color: #daebf4; border-radius: 8px; text-decoration: none; }
aside nav a:hover, aside nav a[aria-current] { background: #294354; color: #fff; }
aside form { margin-top: auto; }
main { padding: clamp(20px, 4vw, 54px); width: 100%; max-width: 1420px; }
.login { max-width: 490px; margin: 12vh auto; }
.card { border: 1px solid var(--line); background: #fff; padding: clamp(16px, 2.5vw, 25px); border-radius: 12px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid > .card { margin-bottom: 0; }
.heading, .actions, .filters, .pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.heading { justify-content: space-between; margin-bottom: 12px; }
.heading > h1, .heading > h2 { margin-bottom: 0; }
.actions { margin-top: 12px; }
.heading > .actions { margin-top: 0; }
.back { display: inline-block; margin-bottom: 13px; }
.muted, dt { color: var(--muted); }
dl { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(100px, 1.5fr); gap: 6px 10px; }
dd { margin: 0; }
.break { overflow-wrap: anywhere; }
.badge { display: inline-block; background: #e8f0f5; color: #204b62; padding: 3px 9px; font-size: .86rem; border-radius: 6px; text-decoration: none; }
button, .button { font: inherit; font-weight: 650; border: 1px solid transparent; padding: 8px 12px; border-radius: 7px; background: var(--blue); color: #fff; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: var(--blue-dark); }
.secondary { border-color: var(--line); background: #fff; color: var(--blue-dark); }
.secondary:hover { background: #edf4f8; }
.filters { align-items: end; margin-bottom: 16px; }
label { display: block; font-weight: 600; }
input:not([type=checkbox], [type=hidden]), select, textarea { width: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid #aab8c5; border-radius: 6px; color: var(--ink); background: #fff; font: inherit; }
input[readonly] { background: #f3f5f7; }
form > div:has(label) { margin-bottom: 10px; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 6px 16px; }
.columns .wide, .columns > .errorlist { grid-column: 1 / -1; }
.notice { background: #e8f2f6; border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.notice.error, .errorlist { color: #9b2c28; background: #fff1ef; }
.errorlist { padding: 8px 12px; list-style: none; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 530px; border-collapse: collapse; text-align: left; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .82rem; color: var(--muted); }
.summary { overflow-wrap: anywhere; }
.thread { display: flex; flex-direction: column; gap: 11px; background: #eef3f6; }
.bubble { align-self: flex-end; background: #e0edf4; border: 1px solid #d7e4ec; border-radius: 9px; max-width: 84%; padding: 8px 12px; overflow-wrap: anywhere; }
.bubble.client { align-self: flex-start; background: #fff; }
.bubble p, .preserve { white-space: pre-wrap; }
.bubble p { margin: 5px 0; }
.message-meta { display: flex; gap: 8px; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--muted); }
.message-meta button { padding: 2px 5px; }
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.list li:last-child { border: 0; }
.message-quote { margin: 6px 0; padding: 3px 8px; border-left: 2px solid #5993ae; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-audio { display: block; width: min(250px, 100%); margin-top: 6px; }

@media (max-width: 800px) {
  .layout, .grid { grid-template-columns: 1fr; }
  aside { gap: 10px; padding: 12px 18px; }
  aside nav { display: flex; flex-wrap: wrap; gap: 3px; }
  aside form { margin-top: 0; }
  main { padding: 23px 15px; }
}
@media (max-width: 460px) {
  .columns { grid-template-columns: 1fr; }
  .bubble { max-width: 100%; }
}

button.danger { background: #9b2c28; color: #fff; }
button.danger:hover { background: #7e211e; }
button:disabled { opacity: .5; cursor: not-allowed; }

.messenger-icon { display: inline-block; flex: 0 0 auto; width: 18px; height: 18px; object-fit: contain; vertical-align: middle; }
.button:has(.messenger-icon), .messenger-heading { display: inline-flex; align-items: center; gap: 7px; }
.messenger-heading .messenger-icon { width: 22px; height: 22px; }
