:root {
  color: #17202a;
  background: #eef2f5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

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

button {
  border: 1px solid #c8d2dc;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  border-color: #227c70;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d2dc;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #227c70;
  box-shadow: 0 0 0 3px rgba(34, 124, 112, 0.14);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: #52616f;
  font-size: 0.9rem;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, rgba(34, 124, 112, 0.18), rgba(232, 145, 59, 0.1)), #eef2f5;
}

.auth-panel,
.panel {
  background: #ffffff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(23, 32, 42, 0.08);
}

.auth-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
}

.brand {
  color: #17202a;
  font-size: 1.15rem;
  font-weight: 800;
}

.brand.large {
  font-size: 1.75rem;
}

.subtle {
  display: block;
  color: #72808e;
  font-size: 0.85rem;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  background: #eef2f5;
  border-radius: 8px;
}

.segmented button {
  border: 0;
  background: transparent;
}

.segmented .active,
.nav .active {
  background: #227c70;
  color: #ffffff;
  border-color: #227c70;
}

.primary {
  background: #227c70;
  border-color: #227c70;
  color: #ffffff;
  font-weight: 700;
}

.ghost {
  background: transparent;
}

.alert,
.success {
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.alert {
  background: #fff0ee;
  color: #b3261e;
  border: 1px solid #ffd3cc;
}

.success {
  background: #ebf7ee;
  color: #216e39;
  border: 1px solid #bce5c8;
}

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

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  min-height: 100vh;
  padding: 24px 18px;
  background: #fbfcfd;
  border-right: 1px solid #d9e0e7;
}

.nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav button {
  justify-content: start;
  text-align: left;
}

.main {
  min-width: 0;
  padding: 26px;
}

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

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e7edf3;
  color: #52616f;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  background: #e3f4ec;
  color: #176a4a;
}

.badge.danger {
  background: #ffe8e4;
  color: #b3261e;
}

.workspace {
  display: grid;
  gap: 18px;
}

.workspace.split {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  align-items: start;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.panel.wide {
  min-width: 0;
}

.panel-title {
  color: #17202a;
  font-size: 1rem;
  font-weight: 800;
}

.compose {
  max-width: 980px;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.row {
  display: grid;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid #edf1f5;
  border-radius: 7px;
  background: #fbfcfd;
}

.row strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.mailbox-row {
  grid-template-columns: minmax(180px, 1.4fr) auto auto minmax(140px, 1fr) auto;
}

.message-row {
  grid-template-columns: minmax(180px, 1fr) auto minmax(120px, 160px);
}

.user-row {
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
}

.audit-row {
  grid-template-columns: minmax(130px, 1fr) 130px minmax(150px, 1fr) 150px;
}

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

.actions button,
.user-row button {
  min-height: 32px;
  padding: 0 10px;
}

.rules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  border-top: 1px solid #edf1f5;
  padding-top: 14px;
}

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

.checkboxes label {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  color: #17202a;
  font-weight: 500;
}

.checkboxes input {
  width: 16px;
  height: 16px;
}

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

  .sidebar {
    min-height: auto;
    grid-template-rows: auto auto auto;
    border-right: 0;
    border-bottom: 1px solid #d9e0e7;
  }

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

  .main {
    padding: 18px;
  }

  .topbar,
  .workspace.split,
  .grid.two,
  .rules {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .mailbox-row,
  .message-row,
  .user-row,
  .audit-row {
    grid-template-columns: 1fr;
  }

  .actions,
  .badge-row {
    justify-content: flex-start;
  }
}
