:root {
  --bg: #eef3f9;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --text: #13223a;
  --muted: #77849a;
  --line: #e4eaf2;
  --blue: #1989e8;
  --green: #55b935;
  --purple: #8a67d6;
  --amber: #efa02d;
  --red: #f25f67;
  --shadow: 0 14px 34px rgba(20, 35, 60, 0.12);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: linear-gradient(180deg, #edf3fb 0%, #f6f8fb 100%);
}

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

.app-shell {
  width: min(1800px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #087ad9;
  background: #edf7ff;
  border: 1px solid #c8dff4;
  border-radius: 8px;
  font-weight: 900;
  box-shadow: inset 0 -6px 0 rgba(8, 122, 217, 0.08);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: 0;
}

.page-header p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 16px;
}

.toolbar-panel,
.table-panel {
  margin-top: 42px;
  padding: 32px;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar-row {
  display: grid;
  grid-template-columns: 230px minmax(260px, 420px) 1fr;
  align-items: center;
  gap: 28px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.field {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #5c6678;
  white-space: nowrap;
}

.field input,
.field select {
  height: 42px;
  min-width: 0;
  color: var(--text);
  background: #fff;
  border: 1px solid #d8e0eb;
  border-radius: 6px;
  outline: none;
  padding: 0 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.field select:focus,
textarea:focus {
  border-color: #8bbcf0;
  box-shadow: 0 0 0 3px rgba(25, 137, 232, 0.14);
}

.compact-field input {
  width: 150px;
}

.search-field input {
  width: 100%;
}

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

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  color: #fff;
  border: 0;
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(20, 35, 60, 0.11);
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(20, 35, 60, 0.16);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.green {
  background: var(--green);
}

.purple {
  background: var(--purple);
}

.blue {
  background: var(--blue);
}

.amber {
  background: var(--amber);
}

.red {
  background: var(--red);
}

.soft {
  color: #2d5e86;
  background: #eaf4ff;
  box-shadow: none;
  border: 1px solid #cde3f8;
}

.ghost {
  color: #607089;
  background: #f2f5f9;
  box-shadow: none;
}

.button-icon {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

.drop-zone {
  position: relative;
  height: 58px;
  margin-top: 32px;
  display: grid;
  place-items: center;
  color: #8a94a6;
  border: 1px dashed #d8e0eb;
  border-radius: 8px;
  background: #fbfdff;
  cursor: pointer;
}

.drop-zone.is-over {
  color: #167bd1;
  border-color: #8fc4f5;
  background: #f3f9ff;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-content {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.drop-content span {
  color: #1689e9;
  font-weight: 700;
}

.format-note {
  margin-top: 18px;
  color: #8a94a6;
}

.table-panel {
  margin-top: 32px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-stick {
  width: 8px;
  height: 24px;
  border-radius: 2px;
  background: linear-gradient(180deg, #ff477d, #5c86ff);
}

h2 {
  font-size: 24px;
  letter-spacing: 0;
}

.section-title span:last-child {
  color: #8a94a6;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.inline-field {
  padding: 6px 10px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.inline-field select {
  width: 130px;
  height: 34px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid var(--line);
  border-left: 0;
  border-right: 0;
}

th,
td {
  min-height: 54px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  color: #24344e;
  background: #fbfdff;
  font-weight: 800;
}

td {
  color: #4f5d73;
}

.check-cell {
  width: 58px;
  text-align: center;
}

th:nth-child(2),
td:nth-child(2) {
  width: 78px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 360px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 260px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 260px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 270px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 240px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 190px;
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.clip {
  max-width: 100%;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-text {
  max-width: 100%;
  display: block;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  line-height: 1.45;
}

.row-actions {
  display: flex;
  gap: 10px;
}

.small-button {
  height: 34px;
  padding: 0 12px;
  color: #2e6a95;
  background: #eef7ff;
  border: 1px solid #cde3f8;
  border-radius: 6px;
  cursor: pointer;
}

.small-button.danger {
  color: #b13d45;
  background: #fff1f2;
  border-color: #ffd4d8;
}

.mail-state {
  color: #96a0af;
}

.mail-state.ready {
  color: #2f8b4b;
}

.mail-state.error {
  color: #cf424c;
}

.empty-cell {
  height: 78px;
  text-align: center;
  color: #9aa3b2;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding-top: 22px;
  color: #66748b;
}

.pagination select {
  height: 42px;
  padding: 0 36px 0 14px;
  border: 1px solid #d8e0eb;
  border-radius: 6px;
  color: #4b5b72;
  background: #fff;
}

.page-button,
.page-number {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
}

.page-button {
  border: 0;
  color: #9aa3b2;
  background: #f1f4f8;
  cursor: pointer;
  font-size: 26px;
}

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

.page-number {
  color: #fff;
  background: #3d96ed;
  font-weight: 800;
}

.modal {
  width: min(720px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(12, 22, 38, 0.28);
}

.modal::backdrop {
  background: rgba(20, 30, 48, 0.42);
}

.modal-card {
  padding: 24px;
  background: #fff;
}

.modal-card.wide {
  width: min(920px, calc(100vw - 28px));
}

.mail-modal {
  width: min(920px, calc(100% - 28px));
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.modal-header h3 {
  font-size: 22px;
}

.modal-header p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  color: #78849a;
  background: #f2f5f9;
  cursor: pointer;
  font-size: 22px;
}

textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  border: 1px solid #d8e0eb;
  border-radius: 7px;
  padding: 14px;
  color: #26354c;
  outline: none;
  font-family: "Cascadia Mono", Consolas, monospace;
  line-height: 1.55;
}

.stack-field {
  display: grid;
  grid-template-columns: 110px 1fr;
  margin-bottom: 14px;
}

.stack-field input {
  width: 100%;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  color: #66748b;
}

.auto-switch {
  min-height: 44px;
  margin-right: 0;
  padding: 0 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.interval-field select {
  width: 90px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.message-list {
  margin-top: 12px;
  color: #c43d48;
  font-size: 14px;
  line-height: 1.55;
}

.settings-status {
  color: #7b879a;
  line-height: 1.5;
}

#mailBody {
  max-height: min(62vh, 620px);
  overflow: auto;
  margin: 0;
  padding: 18px;
  color: #25334a;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  white-space: pre-wrap;
  line-height: 1.65;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  color: #fff;
  background: rgba(28, 40, 62, 0.96);
  border-radius: 8px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 16px 38px rgba(16, 28, 48, 0.24);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .toolbar-row {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1800px);
    padding-top: 18px;
  }

  .page-header {
    align-items: flex-start;
    min-height: auto;
    padding-bottom: 24px;
  }

  h1 {
    font-size: 30px;
  }

  .toolbar-panel,
  .table-panel {
    margin-top: 24px;
    padding: 18px;
  }

  .toolbar-row,
  .section-header,
  .stack-field {
    grid-template-columns: 1fr;
    display: grid;
  }

  .field {
    align-items: flex-start;
    flex-direction: column;
  }

  .compact-field input,
  .field input,
  .field select {
    width: 100%;
  }

  .toolbar-actions {
    gap: 10px;
  }

  .button {
    width: 100%;
  }

  .section-title,
  .table-tools,
  .pagination,
  .drop-content,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-field {
    width: 100%;
  }
}
