:root {
  --bg: #f4f6f8;
  --bg-accent: #d7e8f5;
  --card: #ffffff;
  --text: #152027;
  --muted: #54636d;
  --line: #d4dee4;
  --button: #0f6fae;
  --button-hover: #0c5687;
  --error: #b01931;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, var(--bg-accent), var(--bg) 38%);
  overflow-x: hidden;
}

.topbar {
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  backdrop-filter: blur(6px);
}

.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.03em;
}

.page {
  max-width: 1100px;
  margin: 1.2rem auto 2rem;
  padding: 0 1rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 8px 18px rgba(25, 47, 64, 0.06);
}

.card-narrow {
  max-width: 440px;
  margin: 6vh auto 0;
}

.subtle {
  color: var(--muted);
}

.search-guide {
  margin: 0.45rem 0 0.95rem 1rem;
  padding: 0;
}

.search-guide li {
  margin: 0.25rem 0;
}

.error {
  color: var(--error);
  font-weight: 600;
}

label {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.filters {
  display: grid;
  gap: 0.95rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.filters__wide {
  grid-column: 1 / -1;
}

.filters__actions {
  width: 100%;
  min-height: 2.4rem;
}

.btn {
  background: var(--button);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-quiet {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.45rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.col-received {
  width: 16%;
}

.col-subject {
  width: 24%;
}

.col-from,
.col-to {
  width: 20%;
}

.col-score,
.col-size,
.col-open {
  width: 6%;
  white-space: nowrap;
}

.attachments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.attachments li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line);
  padding: 0.6rem;
  border-radius: 8px;
}

.body-preview {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

.body-preview-html {
  white-space: normal;
  overflow-wrap: anywhere;
}

.body-preview-html img {
  max-width: 100%;
  height: auto;
}

.body-preview-html table {
  display: block;
  width: 100%;
  overflow-x: auto;
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.options {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  display: grid;
  gap: 0.35rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

.check input {
  width: auto;
}

@media (max-width: 640px) {
  .filters {
    grid-template-columns: 1fr;
  }

  .attachments li {
    flex-direction: column;
  }

  .col-size,
  .col-score,
  .col-to {
    display: none;
  }
}
