:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #64737f;
  --line: #d8e0e5;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(860px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.topbar,
.toolbar-row,
.panel-title,
.actions,
.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

.topbar p,
.panel-title span,
.status {
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  background: #e8eef1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
}

.tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(23, 32, 38, 0.08);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar-row {
  margin-bottom: 12px;
}

.search {
  flex: 1;
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px;
}

.panel-title {
  justify-content: space-between;
  margin-bottom: 10px;
}

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

.row {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 9px 10px;
  display: grid;
  gap: 4px;
  text-align: left;
}

.row.selected {
  border-color: var(--primary);
  background: #edfdfa;
}

.row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.row-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2f4;
  color: var(--muted);
  font-size: 12px;
}

.editor-panel {
  padding-bottom: 0;
}

#editor {
  min-height: 180px;
}

.ql-toolbar.ql-snow,
.ql-container.ql-snow {
  border-color: var(--line);
}

.preview {
  min-height: 80px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.actions {
  position: sticky;
  bottom: 0;
  padding: 10px 0 4px;
  background: var(--bg);
}

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.primary-button {
  flex: 1;
  background: var(--primary);
  color: #fff;
  padding: 0 14px;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.primary-button:disabled {
  background: #9fb8b5;
  cursor: not-allowed;
}

.secondary-button,
.icon-button {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
  padding: 0 12px;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.status {
  min-height: 22px;
  padding: 4px 0;
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: var(--primary-dark);
}

.detail-panel:empty {
  display: none;
}

.recipient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .toolbar-row {
    align-items: stretch;
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }
}
