:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --border: #e4e7eb;
  --border-strong: #d1d5db;
  --text: #1c2230;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eaf0ff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fff6e0;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --note: #fffbea;
  --note-border: #f3e2a2;
  --side-bg: #141a26;
  --side-text: #c9d1de;
  --side-muted: #7c879a;
  --side-active: #222b3c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}
h1 {
  font-size: 20px;
  font-weight: 650;
}
h2 {
  font-size: 16px;
  font-weight: 650;
}
h3 {
  font-size: 14px;
  font-weight: 650;
}

.boot {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--muted);
}

.icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex: none;
}
.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Przyciski i formularze ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.btn:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.danger {
  color: var(--danger);
}
.btn.danger:hover {
  background: var(--danger-soft);
  border-color: #f3b4b4;
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.btn.ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
.btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}
.btn.icon-only {
  width: 34px;
  padding: 0;
}
.btn.small.icon-only {
  width: 28px;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='search'],
select,
textarea {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
textarea {
  height: auto;
  min-height: 120px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.5;
}
select {
  padding-right: 6px;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--accent);
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 550;
  color: #374151;
}
label.field .hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}
label.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
label.check input {
  margin-top: 3px;
}
label.check .hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
}
.form-grid .wide {
  grid-column: 1 / -1;
}
.form-section {
  margin-top: 20px;
}
.form-section > h3 {
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ---------- Układ ---------- */

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

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  color: var(--side-text);
  overflow-y: auto;
  padding: 14px 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.brand img {
  width: 26px;
  height: 26px;
}
.sidebar .new-btn {
  margin: 0 4px 14px;
}
.nav-group {
  margin-bottom: 14px;
}
.nav-title {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--side-muted);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--side-text);
  font-weight: 500;
}
.nav-link:hover {
  background: var(--side-active);
  text-decoration: none;
  color: #fff;
}
.nav-link.active {
  background: var(--side-active);
  color: #fff;
}
.nav-link .count {
  margin-left: auto;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 10px;
  background: #2b3548;
  color: #dbe3ef;
  font-size: 12px;
  text-align: center;
}
.nav-link .count.hot {
  background: var(--accent);
  color: #fff;
}
.sidebar-footer {
  margin-top: auto;
  padding: 10px 4px 0;
  border-top: 1px solid #263044;
}
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--side-text);
}
.sync-indicator:hover {
  background: var(--side-active);
  text-decoration: none;
}
.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px 2px;
  font-size: 13px;
}
.user-box .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}
.user-box .btn.ghost {
  color: var(--side-muted);
}
.user-box .btn.ghost:hover {
  background: var(--side-active);
  color: #fff;
}

.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
}
.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}
.page {
  padding: 22px 28px 40px;
  max-width: 1280px;
}
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-header .spacer {
  flex: 1;
}
.page-header .search {
  position: relative;
  width: 300px;
  max-width: 100%;
}
.page-header .search .icon {
  position: absolute;
  left: 10px;
  top: 10px;
  color: var(--faint);
}
.page-header .search input {
  padding-left: 32px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body {
  padding: 18px 20px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.mobile-bar {
  display: none;
}

/* ---------- Plakietki ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #eef0f3;
  color: #4b5563;
}
.badge.st-new {
  background: #e0ecff;
  color: #1e4fd1;
}
.badge.st-open {
  background: #fff1db;
  color: #9a4b00;
}
.badge.st-pending {
  background: #efe9ff;
  color: #5b34c7;
}
.badge.st-resolved {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.st-closed {
  background: #eef0f3;
  color: #4b5563;
}
.badge.st-spam {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.pr-high {
  background: #fff1db;
  color: #9a4b00;
}
.badge.pr-urgent {
  background: var(--danger);
  color: #fff;
}
.badge.pr-low {
  background: #eef0f3;
  color: #6b7280;
}
.badge.outline {
  background: transparent;
  border: 1px solid var(--border-strong);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--faint);
}
.dot.ok {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}
.dot.warn {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}
.dot.err {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}
.dot.unread {
  background: var(--accent);
}

/* ---------- Lista ticketów ---------- */

.tabs-inline {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ticket-list {
  overflow: hidden;
}
.ticket-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 150px 120px 90px;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  color: inherit;
}
.ticket-row:last-child {
  border-bottom: 0;
}
.ticket-row:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.ticket-row .subject-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ticket-row .subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.ticket-row.unread .subject {
  font-weight: 700;
}
.ticket-row .num {
  color: var(--faint);
  font-size: 12px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.ticket-row .snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.ticket-row .who {
  min-width: 0;
  font-size: 13px;
}
.ticket-row .who div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-row .time {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.ticket-row .meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.list-footer {
  display: flex;
  justify-content: center;
  padding: 14px;
}

/* ---------- Ticket ---------- */

.ticket-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  padding: 18px 24px 40px;
  max-width: 1400px;
}
.ticket-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.ticket-head .title {
  flex: 1;
  min-width: 0;
}
.ticket-head h1 {
  word-break: break-word;
}
.ticket-head h1 .editable {
  cursor: text;
  border-radius: 4px;
}
.ticket-head h1 .editable:hover {
  background: rgba(0, 0, 0, 0.04);
}
.ticket-head .sub {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.msg {
  overflow: hidden;
}
.msg.out {
  border-left: 3px solid var(--accent);
}
.msg.forward {
  border-left: 3px solid #8b5cf6;
}
.msg.failed {
  border-left: 3px solid var(--danger);
}
.msg-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  cursor: pointer;
}
.msg-head .avatar {
  flex: none;
}
.msg-head .who {
  flex: 1;
  min-width: 0;
}
.msg-head .who .from {
  font-weight: 600;
}
.msg-head .who .from .addr {
  font-weight: 400;
  color: var(--muted);
}
.msg-head .who .to {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-head .when {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.msg-head .tags {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
}
.msg-collapsed-snippet {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-body {
  padding: 0 16px 14px 60px;
}
.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}
.msg-text .quote {
  color: var(--muted);
  border-left: 2px solid var(--border-strong);
  padding-left: 10px;
  margin-top: 6px;
}
.quote-toggle {
  display: inline-block;
  margin-top: 6px;
  padding: 0 8px;
  border-radius: 10px;
  background: #eef0f3;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.msg-html {
  width: 100%;
  border: 0;
  min-height: 60px;
  display: block;
  background: #fff;
}
.images-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--muted);
}
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 280px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}
.attachment:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}
.attachment .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment .size {
  color: var(--muted);
  font-size: 12px;
  flex: none;
}
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.send-error {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 12px 60px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}
.send-error .text {
  flex: 1;
}

.note-card {
  background: var(--note);
  border: 1px solid var(--note-border);
  border-radius: var(--radius);
  padding: 10px 16px;
}
.note-card .head {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #8a6d0b;
  margin-bottom: 4px;
}
.note-card .body {
  white-space: pre-wrap;
  word-break: break-word;
}

.event {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 12px;
}
.event .icon {
  width: 14px;
  height: 14px;
}
.event .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #374151;
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
}
.avatar.agent {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Edytor odpowiedzi */
.composer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 4px;
  box-shadow: 0 -6px 18px rgba(16, 24, 40, 0.06), var(--shadow);
}
.composer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
}
.composer-tabs button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}
.composer-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.composer-tabs button.note-tab.active {
  color: #a16207;
  border-bottom-color: #eab308;
}
.composer-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer.mode-note .composer-body {
  background: var(--note);
}
.composer .row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.composer .row > .label {
  width: 46px;
  flex: none;
  color: var(--muted);
  font-size: 13px;
}
.composer .row input {
  height: 32px;
}
.composer textarea {
  min-height: 110px;
  max-height: 50vh;
}
.composer-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.composer-footer .spacer {
  flex: 1;
}
.composer-footer select {
  width: auto;
  height: 32px;
}
.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 10px;
  border-radius: 14px;
  background: #eef0f3;
  font-size: 12px;
}
.file-chip button {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  padding: 2px;
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* Panel boczny ticketu */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  position: sticky;
  top: 18px;
}
.prop {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.prop:last-child {
  margin-bottom: 0;
}
.prop > .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.contact-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-top: 4px;
  word-break: break-all;
}
.contact-line .icon {
  color: var(--faint);
}
.mini-list a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.mini-list a:first-child {
  border-top: 0;
}
.mini-list a span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Tabele ---------- */

table.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table tr.clickable {
  cursor: pointer;
}
.table tr.clickable:hover td {
  background: var(--panel-2);
}
.table-wrap {
  overflow-x: auto;
}

.log-level {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.log-level.error {
  color: var(--danger);
}
.log-level.warn {
  color: var(--warn);
}
.log-level.info {
  color: var(--muted);
}

/* ---------- Skrzynki / synchronizacja ---------- */

.mailbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.mailbox-card .head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.mailbox-card .head .titles {
  flex: 1;
  min-width: 0;
}
.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 10px;
  font-size: 13px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  word-break: break-word;
}
.error-box {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}
.ok-box {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 13px;
}
.info-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: #1e3a8a;
  font-size: 13px;
}
.warn-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: #7c4a03;
  font-size: 13px;
}

/* ---------- Logowanie ---------- */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(37, 99, 235, 0.12), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(139, 92, 246, 0.1), transparent 40%), var(--bg);
}
.auth-card {
  width: 380px;
  max-width: 100%;
  padding: 28px;
}
.auth-card .brand {
  color: var(--text);
  padding: 0 0 18px;
}
.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-card .btn {
  height: 38px;
  margin-top: 4px;
}

/* ---------- Modal i powiadomienia ---------- */

/* Okno: nagłówek i przyciski zawsze widoczne, przewija się tylko treść (ważne na telefonie). */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
  animation: fade 0.12s ease-out;
}
.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.modal.wide {
  max-width: 820px;
}
.modal-head {
  flex: none;
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  flex: 1;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
}
.modal-foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: slide 0.18s ease-out;
}
.toast.error {
  background: var(--danger);
}
.toast.ok {
  background: #166534;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes slide {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

.spin {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Telefon / wąskie ekrany ---------- */

@media (max-width: 1100px) {
  .ticket-page {
    grid-template-columns: 1fr;
  }
  .side-panel {
    position: static;
    order: -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-items: start;
  }
  .ticket-head {
    order: -2;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.18s;
  }
  .layout.menu-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--side-bg);
    color: #fff;
    font-weight: 650;
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .mobile-bar .btn.ghost {
    color: #fff;
  }
  .page,
  .ticket-page {
    padding: 16px;
  }
  .ticket-row {
    grid-template-columns: 10px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 14px;
  }
  .ticket-row .who,
  .ticket-row .meta {
    display: none;
  }
  .msg-body {
    padding: 0 14px 14px;
  }
  .composer {
    position: static;
  }
  .modal-backdrop {
    padding: 10px;
  }
  .modal {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }
  .modal-head,
  .modal-body,
  .modal-foot {
    padding-left: 14px;
    padding-right: 14px;
  }
  .send-error {
    margin-left: 14px;
  }
  .page-header .search {
    width: 100%;
  }
  .kv {
    grid-template-columns: 1fr;
  }
}
