/**
 * @package    ui
 * @purpose    Minimalistický světlý design systém CRM prototypu.
 * @feature    F-001
 * @implements KS-ARCH-04, KS-SAFETY-S1
 * @constitution-version 3.2.0
 */

:root {
  --bg: #f6f7f8;
  --surface: rgb(255 255 255 / 88%);
  --surface-solid: #ffffff;
  --line: #e8e8e8;
  --line-strong: #d7d7d7;
  --text: #1a1a1a;
  --muted: #5f6368;
  --blue: #0a84ff;
  --blue-deep: #006edc;
  --green: #2e7d52;
  --orange: #b45309;
  --red: #c0392b;
  --focus: #174ea6;
  --shadow: 0 22px 60px rgb(22 32 48 / 11%);
  --shadow-soft: 0 10px 28px rgb(22 32 48 / 7%);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); color: var(--text); }

body {
  margin: 0;
  min-width: 320px;
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(circle at top left, rgb(255 255 255 / 92%), transparent 32rem),
    linear-gradient(180deg, #fbfbfc 0%, #f4f5f7 100%);
}

body.has-modal-open {
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--blue); }

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: rgb(255 255 255 / 78%);
  backdrop-filter: blur(22px) saturate(160%);
}

.brand {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-weight: 700;
  background: var(--text);
  color: white;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 22%);
}

.brand small,
.page-header p,
.row-meta,
.mail-head,
.schedule-row small,
.info-list dt,
.section-title a,
.template-mini span,
.audit-row span {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #333;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  transform: translateX(2px);
  background: rgb(10 132 255 / 7%);
}

.nav-item span {
  color: var(--muted);
  font-size: 13px;
}

.nav-item.is-active {
  background: rgb(10 132 255 / 10%);
  color: var(--blue);
}

.app-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgb(250 250 252 / 72%);
  backdrop-filter: blur(22px) saturate(180%);
}

.global-search {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.global-search input {
  min-width: 0;
}

.nav-help {
  display: flex;
  justify-content: flex-end;
  margin: -14px 4px 14px 46px;
}

.help-tip {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  vertical-align: middle;
  margin-left: 6px;
}

.help-trigger {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgb(10 132 255 / 28%);
  border-radius: 50%;
  background: rgb(255 255 255 / 74%);
  color: var(--blue);
  cursor: help;
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  box-shadow: 0 4px 14px rgb(10 132 255 / 10%), inset 0 1px 0 rgb(255 255 255 / 86%);
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.help-trigger:hover,
.help-trigger:focus-visible,
.help-tip.is-open .help-trigger {
  transform: translateY(-1px);
  border-color: rgb(10 132 255 / 54%);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 22px rgb(10 132 255 / 18%), inset 0 1px 0 rgb(255 255 255 / 90%);
}

.help-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 80;
  display: none;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 10px;
  background: rgb(23 27 34 / 94%);
  color: #fff;
  box-shadow: 0 18px 40px rgb(20 28 42 / 22%);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  text-transform: none;
  transform: translateX(-50%) translateY(5px) scale(.985);
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
  visibility: hidden;
  white-space: normal;
}

.help-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: rgb(23 27 34 / 94%);
  transform: translateX(-50%) rotate(45deg);
}

.help-tip:hover .help-tooltip,
.help-tip:focus-within .help-tooltip,
.help-tip.is-open .help-tooltip {
  display: block;
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  visibility: visible;
}

h1 .help-tip,
h2 .help-tip,
h3 .help-tip,
summary .help-tip,
label .help-tip,
.chip-line .help-tip,
.row-kicker .help-tip,
.action-row .help-tip,
.queue-actions .help-tip,
.system-strip .help-tip,
.role-switch .help-tip {
  margin-left: 4px;
}

.global-search input,
.filter-bar input,
.filter-bar select,
.role-switch select,
.tag-create-form input,
.tag-create-form select,
.tag-edit-form input,
.tag-edit-form select,
.tag-add-form select,
.template-edit-form input,
.template-edit-form select,
.template-edit-form textarea,
.section-block input,
.section-block select,
.section-block textarea,
.compose-layout input,
.compose-layout select,
.compose-layout textarea,
.settings-section input,
.settings-section textarea,
.collapsed-line input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgb(255 255 255 / 82%);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.global-search input:focus,
.filter-bar input:focus,
.filter-bar select:focus,
.role-switch select:focus,
.tag-create-form input:focus,
.tag-create-form select:focus,
.tag-edit-form input:focus,
.tag-edit-form select:focus,
.tag-add-form select:focus,
.template-edit-form input:focus,
.template-edit-form select:focus,
.template-edit-form textarea:focus,
.section-block input:focus,
.section-block select:focus,
.section-block textarea:focus,
.compose-layout input:focus,
.compose-layout select:focus,
.compose-layout textarea:focus,
.settings-section input:focus,
.settings-section textarea:focus,
.collapsed-line input:focus {
  border-color: rgb(10 132 255 / 60%);
  box-shadow: 0 0 0 4px rgb(10 132 255 / 12%), inset 0 1px 0 rgb(255 255 255 / 78%);
}

textarea { resize: vertical; }

.system-strip,
.role-switch,
.row-kicker,
.chip-line,
.action-row,
.header-actions,
.queue-actions,
.message-meta,
.state-stack,
.attachment-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.action-row form {
  margin: 0;
}

.header-actions form,
.section-title form {
  margin: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--muted);
}

.status-dot.success { background: var(--green); }
.status-dot.warning { background: var(--orange); }

.content {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.page-header,
.customer-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.customer-header {
  position: sticky;
  top: 64px;
  z-index: 8;
  padding: 18px 0;
  background: rgb(246 247 248 / 78%);
  backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--line);
}

.customer-header.is-risk {
  border-bottom-color: #e5b08d;
}

.page-header h1,
.customer-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
}

.section-block h2,
.preview-panel h2,
.context-panel h2,
.review-column h2,
.review-context h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgb(0 0 0 / 3%), inset 0 1px 0 rgb(255 255 255 / 70%);
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
}

.button.primary {
  border-color: var(--blue-deep);
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-deep) 100%);
  color: white;
}

.button.secondary {
  background: #fbfbfb;
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}

.chip,
.rating,
.attachment-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 70%);
  color: #333;
  font-size: 13px;
  white-space: nowrap;
}

.chip.info { border-color: #c9d7f4; background: #f2f6ff; color: #174ea6; }
.chip.success { border-color: #b9d8c8; background: #eef8f2; color: #1d6b43; }
.chip.warning { border-color: #e8c295; background: #fff7ed; color: var(--orange); }
.chip.danger { border-color: #e9b8b1; background: #fff4f2; color: var(--red); }
.chip.muted { color: var(--muted); }
.chip.soft { background: #fcfcfc; }

.rating {
  border-color: #d5d9e2;
  background: #fff;
  color: #2c3440;
}

.priority-grid,
.metric-grid,
.customer-grid,
.template-grid,
.settings-grid,
.content-grid,
.compare-grid,
.form-grid {
  display: grid;
  gap: 16px;
}

.priority-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
}

.priority-card,
.section-block,
.preview-panel,
.context-panel,
.review-column,
.review-context,
.customer-card,
.template-card,
.settings-section,
.merge-surface,
.table-surface,
.warning-banner,
.notice-banner {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(145%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 74%);
}

.priority-card {
  min-height: 132px;
  padding: 18px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.priority-card:hover,
.customer-card:hover,
.queue-row:hover,
.schedule-row:hover,
.template-card:hover,
.settings-section:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  border-color: rgb(10 132 255 / 24%);
}

.priority-card span {
  display: block;
  margin-bottom: 12px;
  font-size: 28px;
  font-weight: 650;
}

.priority-card small,
.empty-state,
.error-text {
  color: var(--muted);
}

.priority-card.risk span,
.risk-text,
.error-text {
  color: var(--red);
}

.section-block,
.preview-panel,
.context-panel,
.review-column,
.review-context,
.customer-card,
.template-card,
.settings-section,
.merge-surface,
.table-surface {
  padding: 18px;
}

.content > .section-block + .section-block,
.content > .wizard + .section-block,
.content > .section-block + .import-duplicate-preview {
  margin-top: 18px;
}

.content-grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-bottom: 16px;
}

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

.dashboard-grid {
  gap: 24px;
  margin-bottom: 24px;
}

.dashboard-section {
  padding: 22px;
}

.dashboard-section .section-title {
  margin-bottom: 20px;
}

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

.queue-list,
.schedule-list,
.audit-list,
.duplicate-list {
  display: grid;
  gap: 12px;
}

.queue-list.dashboard-list,
.schedule-list.dashboard-list {
  gap: 22px;
}

.schedule-board {
  display: grid;
  gap: 18px;
}

.queue-row,
.schedule-row,
.duplicate-row,
.audit-row,
.note-row,
.template-mini,
.order-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.queue-row[data-work-modal-url] {
  cursor: pointer;
}

.queue-row[data-work-modal-url]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.open-tab-button {
  display: inline-grid;
  gap: 1px;
  min-width: 92px;
  line-height: 1.1;
}

.open-tab-button small {
  color: rgb(255 255 255 / 82%);
  font-size: 11px;
  font-weight: 500;
}

.order-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  justify-content: stretch;
  min-width: 0;
  padding: 16px;
}

.order-card-head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.order-card-head strong,
.order-card-meta,
.order-card-source {
  overflow-wrap: anywhere;
}

.order-card-meta {
  margin: 0;
  color: #272b31;
}

.order-card-items {
  min-width: 0;
}

.order-card-items summary {
  width: fit-content;
  max-width: 100%;
  cursor: pointer;
  line-height: 1.35;
}

.order-card-items ul {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 20px;
}

.order-card-source {
  color: var(--muted);
  line-height: 1.4;
}

.queue-row.is-risk,
.schedule-row.is-error,
.customer-card.is-risk {
  border-color: #e5b08d;
}

.queue-main h3,
.schedule-row h2,
.customer-card h2,
.template-card h2 {
  margin: 4px 0;
  font-size: 16px;
}

.queue-main p,
.schedule-row p,
.customer-card p {
  margin: 4px 0;
}

.dashboard-list .queue-row {
  padding: 20px 18px;
  gap: 24px;
}

.dashboard-list .queue-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.dashboard-list .queue-main h3,
.dashboard-list .queue-main p {
  margin: 0;
}

.dashboard-list .row-meta {
  gap: 8px 10px;
  line-height: 1.45;
}

.dashboard-list .queue-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-content: start;
  justify-items: end;
  min-width: 132px;
}

.dashboard-list .queue-actions .help-tip {
  margin-left: 0;
  justify-self: center;
}

.schedule-row {
  align-items: center;
  padding: 22px 24px;
  gap: 28px;
  box-shadow: 0 12px 28px rgb(22 32 48 / 5%), inset 0 1px 0 rgb(255 255 255 / 78%);
}

.schedule-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.schedule-row h2 {
  margin: 2px 0 0;
}

.schedule-meta {
  color: #272b31;
}

.schedule-preview {
  max-width: 760px;
  line-height: 1.45;
}

.schedule-actions {
  justify-content: flex-end;
  gap: 10px;
  min-width: 440px;
}

.schedule-row .error-text {
  margin-top: 2px;
}

.filter-bar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.filter-bar.is-filtering {
  opacity: .72;
  transition: opacity 140ms ease;
}

.filter-bar.is-filtering .button[type="submit"]::after {
  content: "...";
}

.filter-bar label {
  min-width: 220px;
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

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

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

.info-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.info-list div {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.info-list dt,
.info-list dd {
  min-width: 0;
}

.info-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.warning-banner,
.notice-banner {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
}

.warning-banner {
  border-color: #e5b08d;
  background: rgb(255 248 240 / 86%);
  box-shadow: 0 12px 30px rgb(180 83 9 / 8%);
}

.notice-banner {
  background: rgb(247 251 255 / 88%);
}

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

.conversation,
.compose-main {
  min-width: 0;
}

.conversation {
  padding: 4px 0 20px;
}

.thread-switcher {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.thread-switcher a {
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.thread-switcher a:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.thread-switcher a.is-active {
  border-color: var(--blue);
}

.message-list {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 62%), rgb(255 255 255 / 30%)),
    rgba(255, 255, 255, .36);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 78%);
  backdrop-filter: blur(18px) saturate(150%);
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  max-width: 78%;
  align-items: end;
  animation: bubbleIn 220ms ease both;
}

.message.outgoing {
  grid-template-columns: minmax(0, 1fr) 34px;
  justify-self: end;
}

.message.outgoing .message-avatar {
  grid-column: 2;
  grid-row: 1;
}

.message.outgoing .message-stack {
  grid-column: 1;
  grid-row: 1;
  align-items: flex-end;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e7e9ee;
  color: #3b3f46;
  font-size: 13px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
}

.message.outgoing .message-avatar {
  background: #111;
  color: #fff;
}

.message-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.message .message-meta {
  gap: 6px;
  padding-inline: 8px;
  font-size: 12px;
}

.message-bubble {
  position: relative;
  width: fit-content;
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 20px 20px 20px 6px;
  background: #ffffff;
  color: #151515;
  box-shadow: 0 8px 24px rgb(30 42 60 / 9%), inset 0 1px 0 rgb(255 255 255 / 72%);
}

.message-bubble::after {
  content: "";
  position: absolute;
  left: -5px;
  bottom: 0;
  width: 12px;
  height: 14px;
  border-bottom-right-radius: 12px;
  background: #ffffff;
}

.message.outgoing .message-bubble {
  border-radius: 20px 20px 6px 20px;
  background: linear-gradient(180deg, #2d9cff 0%, #0a84ff 55%, #0072e6 100%);
  color: white;
  box-shadow: 0 12px 30px rgb(10 132 255 / 20%);
}

.message.outgoing .message-bubble::after {
  left: auto;
  right: -5px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 12px;
  background: #0072e6;
}

.message h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.message p {
  margin: 0;
}

.message-route {
  max-width: 100%;
  padding-inline: 8px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
}

.tabs a {
  padding: 7px 9px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
}

.tabs a:hover {
  border-bottom-color: var(--blue);
}

.panel-section {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.import-panel-section {
  margin-top: 18px;
  padding: 18px 0 22px;
}

.import-panel-section + .import-panel-section {
  margin-top: 8px;
}

.import-panel-section > strong,
.import-panel-section h3 {
  display: block;
  margin: 0 0 12px;
}

.import-chip-line {
  gap: 10px;
  padding-bottom: 2px;
}

.import-duplicate-preview h2 {
  margin-bottom: 18px;
}

.import-duplicate-list {
  gap: 16px;
}

.import-duplicate-list .duplicate-row {
  align-items: center;
  padding: 18px 20px;
}

.import-duplicate-list .duplicate-row p {
  margin-top: 12px;
}

.approval-layout {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.1fr) 360px;
  gap: 16px;
}

.review-context {
  display: grid;
  gap: 20px;
  align-self: start;
  min-width: 0;
}

.review-context section,
.customer-mini {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.review-context h2,
.review-context h3 {
  margin: 0;
}

.mail-head {
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
}

blockquote {
  margin: 12px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--line-strong);
  color: #303030;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.editor-column textarea {
  width: 100%;
}

.assistant-notes,
.email-preview,
.html-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(252 252 252 / 82%);
  backdrop-filter: blur(10px);
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 0;
  background: var(--surface);
}

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

.compose-side .template-mini {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: start;
}

.compose-side .template-mini strong,
.compose-side .template-mini span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.compose-side .template-mini .chip {
  grid-column: 1 / -1;
  justify-self: start;
  white-space: normal;
}

.compose-side .template-mini .button {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.compose-layout label,
.settings-section label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
}

.send-details {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcfc;
}

.attachment-strip {
  justify-content: space-between;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.wizard {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.wizard-step {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.wizard-step.is-current {
  border-color: var(--orange);
  color: var(--text);
}

.wizard-step.is-done {
  border-color: #b9d8c8;
  color: var(--green);
}

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

.metric-grid.large {
  margin-bottom: 16px;
}

.stats-metrics {
  margin-bottom: 22px;
}

.stats-section {
  margin-top: 18px;
  padding: 24px;
}

.stats-section h2 {
  margin-bottom: 18px;
}

.metric-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.metric-grid div,
.readiness-list div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

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

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

.template-create-section,
.customer-edit-grid {
  margin-bottom: 18px;
}

.template-edit-form,
.section-block form {
  display: grid;
  gap: 12px;
}

.inline-edit {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.inline-edit summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
}

.readiness-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.audit-row.full,
.schedule-row.full {
  align-items: center;
}

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

.customer-strip a {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats-customer-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, max-content));
  gap: 14px;
}

.stats-customer-strip a {
  padding: 13px 14px;
  justify-content: space-between;
  background: rgb(255 255 255 / 78%);
  box-shadow: 0 6px 18px rgb(22 32 48 / 4%);
}

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

.tag-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 74%);
}

.tag-create-section {
  margin-bottom: 18px;
}

.tag-create-form,
.tag-edit-form,
.tag-add-form {
  display: grid;
  gap: 12px;
}

.tag-create-form {
  grid-template-columns: minmax(260px, 1fr) 180px auto;
  align-items: end;
}

.tag-create-form label,
.tag-edit-form label,
.tag-add-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

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

.tag-pill-form {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 70%);
}

.upload-form {
  display: grid;
  gap: 14px;
}

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

.upload-form input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: 9px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgb(255 255 255 / 82%);
  color: var(--text);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.work-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(13 17 23 / 28%);
  backdrop-filter: blur(12px) saturate(140%);
}

.work-detail-modal[hidden] {
  display: none;
}

.work-detail-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  border: 1px solid rgb(255 255 255 / 68%);
  border-radius: 12px;
  background: rgb(250 251 252 / 94%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.work-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 78%);
  backdrop-filter: blur(18px) saturate(150%);
}

.work-detail-head h2 {
  margin: 0;
  font-size: 20px;
}

.work-detail-body {
  min-height: 220px;
  overflow: auto;
  padding: 22px;
}

.work-detail-body .content {
  max-width: none;
  padding: 0;
}

.work-detail-body .page-header {
  position: static;
}

.work-detail-body .approval-layout,
.work-detail-body .detail-layout {
  margin-bottom: 0;
}

.modal-loading {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: white;
  color: var(--muted);
}

.toast {
  padding: 12px 14px;
  border: 1px solid #b9d8c8;
  border-radius: 8px;
  background: #f2fbf5;
  box-shadow: var(--shadow);
}

.toast.warning {
  border-color: #e8c295;
  background: #fff7ed;
}

.toast.danger {
  border-color: #e9b8b1;
  background: #fff4f2;
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.shortcut-help {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 18%);
}

.shortcut-help[hidden] {
  display: none;
}

.dialog-panel {
  width: min(520px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-panel dl div {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.sr-only {
  position: absolute;
  width: 1px !important;
  min-width: 1px !important;
  max-width: 1px !important;
  height: 1px !important;
  min-height: 1px !important;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.error-page {
  max-width: 680px;
  margin: 80px auto;
  padding: 24px;
}

@media (max-width: 1199px) {
  .app-shell { grid-template-columns: 88px minmax(0, 1fr); }
  .brand span:last-child,
  .nav-item { font-size: 0; }
  .nav-help { display: none; }
  .nav-item::first-letter { font-size: 15px; }
  .nav-item span { display: none; }
  .priority-grid,
  .metric-grid,
  .readiness-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout,
  .compose-layout,
  .queue-layout { grid-template-columns: minmax(0, 1fr); }
  .context-panel { order: -1; }
  .approval-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .review-context { grid-column: 1 / -1; }
  .customer-grid,
  .template-grid,
  .tag-grid,
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tag-create-form { grid-template-columns: minmax(260px, 1fr) minmax(160px, 220px); }
  .tag-create-form .button { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  .app-shell { display: block; padding-bottom: 68px; }
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    display: flex;
    height: auto;
    padding: 6px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }
  .brand { display: none; }
  .nav-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }
  .nav-item {
    justify-content: center;
    min-height: 46px;
    font-size: 12px;
    text-align: center;
  }
  .nav-item:nth-child(n+5) { display: none; }
  .topbar {
    grid-template-columns: 1fr;
    position: static;
    padding: 12px;
  }
  .global-search {
    align-items: flex-start;
  }
  .global-search .help-tooltip,
  .role-switch .help-tooltip,
  .system-strip .help-tooltip {
    left: auto;
    right: 0;
    transform: translateY(5px) scale(.985);
  }
  .global-search .help-tooltip::after,
  .role-switch .help-tooltip::after,
  .system-strip .help-tooltip::after {
    left: auto;
    right: 5px;
    transform: rotate(45deg);
  }
  .global-search .help-tip:hover .help-tooltip,
  .global-search .help-tip:focus-within .help-tooltip,
  .global-search .help-tip.is-open .help-tooltip,
  .role-switch .help-tip:hover .help-tooltip,
  .role-switch .help-tip:focus-within .help-tooltip,
  .role-switch .help-tip.is-open .help-tooltip,
  .system-strip .help-tip:hover .help-tooltip,
  .system-strip .help-tip:focus-within .help-tooltip,
  .system-strip .help-tip.is-open .help-tooltip {
    transform: translateY(0) scale(1);
  }
  .content { padding: 18px 12px 34px; }
  .page-header,
  .customer-header,
  .queue-row,
  .schedule-row,
  .duplicate-row,
  .audit-row {
    display: grid;
  }
  .customer-header { position: static; }
  .priority-grid,
  .content-grid.two,
  .customer-grid,
  .approval-layout,
  .form-grid.two,
  .form-grid.three,
  .compare-grid,
  .template-grid,
  .tag-grid,
  .settings-grid,
  .wizard,
  .metric-grid,
  .readiness-list {
    grid-template-columns: 1fr;
  }
  .tag-create-form {
    grid-template-columns: 1fr;
  }
  .queue-actions,
  .schedule-actions,
  .header-actions,
  .sticky-actions {
    width: 100%;
  }
  .schedule-row {
    gap: 16px;
    padding: 18px;
  }
  .schedule-actions {
    min-width: 0;
    justify-content: stretch;
  }
  .button {
    width: 100%;
  }
  .work-detail-modal {
    padding: 10px;
  }
  .work-detail-panel {
    width: min(100%, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
  }
  .work-detail-head {
    display: grid;
    padding: 14px;
  }
  .work-detail-body {
    padding: 14px;
  }
  .review-context,
  .compose-side {
    order: 3;
  }
  .message-list {
    padding: 12px;
    border-radius: 18px;
  }
  .message {
    max-width: 96%;
  }
  .message-route {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* ===== Přihlášený uživatel v horní liště ===== */
.user-strip {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}
.user-strip .user-id {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}
.user-strip .user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-strip .user-role { font-size: 12px; color: var(--muted); }
.user-strip .logout-form { margin: 0; }

/* ===== Samostatná přihlašovací stránka ===== */
.auth-body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgb(10 132 255 / 8%), transparent 60%),
    var(--bg);
}
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}
.auth-card {
  width: min(100%, 380px);
  padding: 32px 28px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 6px 0 4px; font-size: 22px; }
.auth-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 15px;
  margin-bottom: 12px;
}
.auth-brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}
.auth-lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 13px; font-weight: 600; margin-top: 10px; }
.auth-form input {
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  font-size: 15px;
  background: #fff;
}
.auth-form input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.auth-form .button { width: 100%; margin-top: 18px; justify-content: center; }
.auth-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgb(192 57 43 / 8%);
  border: 1px solid rgb(192 57 43 / 22%);
  color: var(--red);
  font-size: 13px;
}
.auth-footnote { color: var(--muted); font-size: 12px; margin: 0; }

/* =====================================================================
   REDESIGN 2026-06 — klidný, zdrženlivý design systém (override layer).
   Zklidněná modrá jen na primární akci + aktivní stav; hierarchie přes
   typografii a prostor; vlasové linky místo šedých krabic; bez šumu.
   ===================================================================== */
:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --line: #ececf0;
  --line-strong: #e2e3e8;
  --text: #1b1d22;
  --muted: #6b7280;
  --faint: #9aa0aa;
  --blue: #2d6cdf;
  --blue-deep: #2159bd;
  --blue-tint: #eef3fd;
  --green: #1f7a4d;
  --orange: #b4690e;
  --red: #c0392b;
  --focus: #2d6cdf;
  --shadow: 0 10px 30px rgb(20 28 42 / 7%);
  --shadow-soft: 0 2px 10px rgb(20 28 42 / 5%);
  /* odvozené plochy (kvůli light/dark přepínání) */
  --hover: #f3f4f6;
  --chip-bg: #f1f2f4;
  --chip-text: #4b5563;
  --bubble-in: #f4f5f7;
  --avatar-bg: #eceef1;
  --chip-info-bg: #eef3fd;
  --chip-success-bg: #e8f5ee;
  --chip-warning-bg: #fbf0df;
  --chip-danger-bg: #fcecea;
  --danger-soft: #fdf3f2;
}

/* ===== TMAVÝ REŽIM — tokeny (auto dle systému + ruční přepínač) ===== */
:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #181c22;
  --surface-solid: #181c22;
  --line: #282d35;
  --line-strong: #373d47;
  --text: #e7eaee;
  --muted: #9aa1ac;
  --faint: #6c7480;
  --blue: #4f8ef0;
  --blue-deep: #74a6f5;
  --blue-tint: #1a2740;
  --green: #57c98a;
  --orange: #e0a64a;
  --red: #ec7063;
  --focus: #4f8ef0;
  --shadow: 0 12px 32px rgb(0 0 0 / 38%);
  --shadow-soft: 0 2px 12px rgb(0 0 0 / 30%);
  --hover: #242a32;
  --chip-bg: #262b33;
  --chip-text: #c3c9d2;
  --bubble-in: #242a32;
  --avatar-bg: #2a313a;
  --chip-info-bg: #1a2740;
  --chip-success-bg: #16301f;
  --chip-warning-bg: #33260f;
  --chip-danger-bg: #341a17;
  --danger-soft: #2a1714;
  color-scheme: dark;
}

html { background: var(--bg); }
body {
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* — odšumění: nápověda, eyebrow, systémový alarm, nav blurb — */
.help-tip, .help-trigger, .help-tooltip, .nav-help, .eyebrow, .system-strip { display: none !important; }

/* — sidebar: čistá, vlasová linka, klidný brand — */
.sidebar {
  background: var(--surface);
  backdrop-filter: none;
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}
.app-shell { grid-template-columns: 232px minmax(0, 1fr); }
.brand { margin-bottom: 20px; }
.brand-mark {
  background: var(--blue-tint);
  color: var(--blue-deep);
  border: 0;
  border-radius: 9px;
  font-weight: 600;
  box-shadow: none;
}
.brand strong { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.nav-item {
  position: relative;
  min-height: 36px;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 14px;
  border-radius: 8px;
}
.nav-item:hover { transform: none; background: var(--hover); color: var(--text); }
.nav-item.is-active {
  background: var(--blue-tint);
  color: var(--blue-deep);
  font-weight: 500;
  box-shadow: none;
  /* Dlaždice je vlevo rovná (ostré rohy), vpravo zaoblená — aby proužek seděl po celé délce. */
  border-radius: 0 8px 8px 0;
}
/* Aktivní položka: rovný levý akcentový proužek po CELÉ délce dlaždice. */
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--blue);
}
.nav-item span { color: var(--faint); font-size: 12px; font-weight: 400; }
.nav-item.is-active span { color: var(--blue-deep); }

/* — topbar: čistá bílá, jen hledání + uživatel — */
.topbar {
  grid-template-columns: minmax(220px, 1fr) auto;
  background: var(--surface);
  backdrop-filter: none;
  border-bottom: 1px solid var(--line);
  min-height: 60px;
}
.user-strip .user-name { font-weight: 500; }

/* — obsah: titulky klidnější, méně tučné — */
.content { padding: 26px 32px 56px; }
.page-header { margin-bottom: 22px; }
.page-header h1, .customer-header h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.section-block h2, .preview-panel h2, .context-panel h2,
.review-column h2, .review-context h2,
.dashboard-section .section-title h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.section-title a, .section-title span { font-size: 13px; color: var(--muted); }

/* — tlačítka: ploché, jediná primární akce nese akcent — */
.button {
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: none;
}
.button:hover:not(:disabled) { transform: none; background: var(--hover); box-shadow: none; }
.button:active:not(:disabled) { transform: scale(0.99); box-shadow: none; }
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--blue-deep); border-color: var(--blue-deep); }
.button.secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.button.danger { background: var(--surface); border-color: var(--line-strong); color: var(--red); }
.button.danger:hover:not(:disabled) { background: var(--danger-soft); }
.open-tab-button small { color: rgb(255 255 255 / 80%); }
.link-button { color: var(--blue); font-weight: 500; }

/* — checkboxy a radia NESMÍ dostat stylování textových inputů (jinak z nich je obří box) — */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  flex: none;
  accent-color: var(--blue);
}
.check-line {
  display: inline-flex;
  align-items: center;
  align-self: end;
  gap: 9px;
  min-height: 38px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}
.check-line input[type="checkbox"],
.check-line input[type="radio"] { width: 17px; height: 17px; }

/* — inputy: čisté, bez vnitřního stínu, jemný focus — */
.global-search input, .filter-bar input, .filter-bar select, .tag-create-form input,
.tag-create-form select, .tag-edit-form input, .tag-edit-form select, .tag-add-form select,
.template-edit-form input, .template-edit-form select, .template-edit-form textarea,
.section-block input, .section-block select, .section-block textarea,
.compose-layout input, .compose-layout select, .compose-layout textarea,
.settings-section input, .settings-section textarea, .collapsed-line input {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: none;
}
/* Focus = jedna čistá linka: jen barva rámečku, žádný vnější outline ani ring. */
input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
.global-search input:focus, .filter-bar input:focus, .filter-bar select:focus,
.section-block input:focus, .section-block select:focus, .section-block textarea:focus,
.compose-layout input:focus, .compose-layout select:focus, .compose-layout textarea:focus,
.settings-section input:focus, .settings-section textarea:focus, .collapsed-line input:focus,
.template-edit-form input:focus, .template-edit-form textarea:focus,
.tag-create-form input:focus, .tag-create-form select:focus, .tag-add-form select:focus,
.auth-form input:focus, .auth-form input:focus-visible {
  border-color: var(--blue);
  box-shadow: none;
  outline: none;
}

/* — chipy: decentní, jednotná lehká váha — */
.chip, .attachment-chip {
  min-height: 22px;
  padding: 2px 9px;
  border: 0;
  border-radius: 7px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 12px;
  font-weight: 500;
}
.chip.info { background: var(--chip-info-bg); color: var(--blue-deep); }
.chip.success { background: var(--chip-success-bg); color: var(--green); }
.chip.warning { background: var(--chip-warning-bg); color: var(--orange); }
.chip.danger { background: var(--chip-danger-bg); color: var(--red); }
.chip.muted, .chip.soft { background: var(--chip-bg); color: var(--muted); }
.rating { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 0; }

/* — karty / plochy: bílé, vlasová linka, bez blur, vzdušné — */
.priority-card, .section-block, .preview-panel, .context-panel, .review-column,
.review-context, .customer-card, .template-card, .settings-section, .merge-surface,
.table-surface, .warning-banner, .notice-banner,
.queue-row, .schedule-row, .duplicate-row, .audit-row, .note-row, .template-mini, .order-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  backdrop-filter: none;
  box-shadow: none;
}
.priority-card:hover, .customer-card:hover, .queue-row:hover, .schedule-row:hover,
.template-card:hover, .settings-section:hover {
  transform: none;
  box-shadow: var(--shadow-soft);
  border-color: var(--line-strong);
}
.priority-card span { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.priority-card { min-height: 0; padding: 16px 18px; }
.section-block, .customer-card, .template-card, .settings-section, .merge-surface,
.table-surface, .preview-panel, .context-panel, .review-column, .review-context { padding: 20px; }
.dashboard-section { padding: 20px 22px; }

/* — řádky (fronta, plán, audit): vlasová linka, klidný hover — */
.queue-row, .schedule-row, .duplicate-row, .audit-row { backdrop-filter: none; }
.queue-main h3, .schedule-row h2, .customer-card h2, .template-card h2 { font-weight: 600; font-size: 15px; }
.row-meta { color: var(--muted); font-size: 13px; }

/* — akce na kartách: jednořádková, zarovnaná tlačítka (žádné dvouřádkové „Otevřít/Nová záložka") — */
.open-tab-button { display: inline-flex; min-width: 0; line-height: 1.2; }
.queue-actions { align-items: flex-start; }
.dashboard-list .queue-actions {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: flex-end;
  min-width: 0;
}
/* Na desktopu se akce nelámou do dvou řádků — Převzít a Otevřít drží vedle sebe vpravo. */
@media (min-width: 768px) {
  .queue-actions,
  .dashboard-list .queue-actions { flex-wrap: nowrap; }
  .queue-actions .button { flex: 0 0 auto; }
  .dashboard-list .queue-main { min-width: 0; }
}

/* — dashboard: položky jako čisté řádky uvnitř sekce, ne karty v kartě — */
.queue-list.dashboard-list { gap: 4px; }
.dashboard-list .queue-row {
  border: 0;
  border-radius: 10px;
  padding: 14px 12px;
  box-shadow: none;
}
.dashboard-list .queue-row:hover { background: var(--hover); box-shadow: none; }
.dashboard-list .queue-row.is-risk { box-shadow: inset 3px 0 0 var(--orange); }

/* — konverzace (bubliny) — klidné, čitelné, bez těžkých stínů/gradientů — */
.message-bubble { border-radius: 16px 16px 16px 6px; background: var(--bubble-in); color: var(--text); box-shadow: none; }
.message-bubble::after { background: var(--bubble-in); }
.message.outgoing .message-bubble { border-radius: 16px 16px 6px 16px; background: var(--blue-tint); color: var(--text); box-shadow: none; }
.message.outgoing .message-bubble::after { background: var(--blue-tint); }
.message.outgoing .message-bubble h3, .message.outgoing .message-bubble p { color: var(--text); }
.message-bubble h3 { font-size: 14px; font-weight: 600; }
.message-avatar { background: var(--avatar-bg); color: var(--muted); box-shadow: none; }
.message.outgoing .message-avatar { background: var(--blue-tint); color: var(--blue-deep); }

/* — odsazení spodní „úprava zákazníka" sekce — */
.customer-edit-grid { margin-top: 22px; }

/* — sticky hlavička detailu zákazníka: čistá plocha místo světlého translucentního pruhu — */
.customer-header {
  background: var(--bg);
  backdrop-filter: none;
  border-bottom: 1px solid var(--line);
}
.customer-header.is-risk { border-bottom-color: var(--line-strong); }

/* — sekční nadpisy v kartách klidnější — */
h1, h2, h3 { letter-spacing: -0.01em; }

/* ===== Přepínač světlý/tmavý režim ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--hover); color: var(--text); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.auth-theme-toggle { position: absolute; top: 18px; right: 18px; }

/* ===== Nápověda — diagram fungování systému ===== */
.help-flow { margin: 6px 0 24px; }
.help-diagram { display: block; max-width: 760px; margin: 0 auto; height: auto; }
.help-diagram text { font-family: inherit; }
.help-diagram .d-title { fill: var(--text); font-size: 16px; font-weight: 600; }
.help-diagram .d-sub { fill: var(--muted); font-size: 12.5px; }
.help-diagram .d-band-title { fill: var(--text); font-size: 14px; font-weight: 600; }
.help-diagram .accent { fill: var(--blue-deep); }
.help-steps { margin: 0; padding-left: 20px; line-height: 1.6; color: var(--text); }
.help-steps li { margin-bottom: 10px; }
.help-steps li strong { font-weight: 600; }

/* ===== Našeptávač globálního hledání ===== */
.global-search { position: relative; }
.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: 72vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.suggest-group {
  padding: 9px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}
.suggest-item {
  display: block;
  position: relative;
  padding: 9px 11px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text);
}
.suggest-item:hover,
.suggest-item.is-active { background: var(--hover); }
.suggest-main { font-size: 14px; padding-right: 84px; }
.suggest-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; padding-right: 84px; }
.suggest-main mark,
.suggest-sub mark { background: transparent; color: var(--blue-deep); font-weight: 600; }
.suggest-badge {
  position: absolute;
  top: 10px;
  right: 11px;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--muted);
}
.suggest-empty { padding: 14px 12px; color: var(--muted); font-size: 13.5px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ===== Tmavý režim — doladění zbytkových světlých hodnot z původního CSS ===== */
:root[data-theme="dark"] .order-card-meta,
:root[data-theme="dark"] .message-route { color: var(--muted); }
:root[data-theme="dark"] .auth-form input {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}
:root[data-theme="dark"] .auth-form input:focus-visible { outline-color: var(--focus); }
:root[data-theme="dark"] .auth-error { background: var(--chip-danger-bg); border-color: var(--line-strong); color: var(--red); }
:root[data-theme="dark"] .auth-body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgb(79 142 240 / 10%), transparent 60%),
    var(--bg);
}
:root[data-theme="dark"] .brand-mark { background: var(--blue-tint); color: var(--blue-deep); }
:root[data-theme="dark"] .auth-brand .brand-mark { background: var(--blue); color: #fff; }
:root[data-theme="dark"] .user-strip .user-avatar,
:root[data-theme="dark"] .message.outgoing .message-avatar { background: var(--blue-tint); color: var(--blue-deep); }
:root[data-theme="dark"] .rating { color: var(--muted); }
:root[data-theme="dark"] .notice-banner strong,
:root[data-theme="dark"] .warning-banner strong { color: var(--text); }
