:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #60717f;
  --line: #d9e2e8;
  --paper: #ffffff;
  --canvas: #f5f7f4;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #d97706;
  --danger: #b42318;
  --soft: #eaf4f1;
  --shadow: 0 18px 50px rgba(23, 32, 38, 0.10);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 0 36px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.nav a,
.button,
button.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.button.primary,
.nav a.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.button.warn { border-color: #fed7aa; color: #9a3412; background: #fff7ed; }
.button.danger { border-color: #fecaca; color: var(--danger); background: #fff5f5; }
.button:hover, .nav a:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(23, 32, 38, 0.08); }

.wrap {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 32px 0 54px;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: stretch;
}

.panel,
.card,
.auth-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 24px; }
.card { padding: 18px; }
.auth-box {
  width: min(480px, calc(100% - 32px));
  margin: 42px auto;
  padding: 28px;
}

h1, h2, h3 { margin: 0; line-height: 1.18; }
h1 { font-size: 38px; }
h2 { font-size: 24px; }
h3 { font-size: 17px; }
p { color: var(--muted); line-height: 1.65; }
.small { color: var(--muted); font-size: 13px; }
.kicker { color: var(--brand-strong); font-size: 13px; font-weight: 800; text-transform: uppercase; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 108px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.stat strong { font-size: 30px; }

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

.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { color: #2e3b43; font-size: 13px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
textarea { min-height: 150px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.checkbox-row { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.checkbox-row input { width: 18px; min-height: 18px; }

.alert {
  padding: 13px 15px;
  margin: 0 0 18px;
  border-radius: 8px;
  border: 1px solid #bae6d5;
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
}
.alert.error { border-color: #fecaca; background: #fff1f2; color: var(--danger); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #40505b; font-size: 12px; text-transform: uppercase; background: #f8faf8; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; min-height: 26px; align-items: center; padding: 0 9px; border-radius: 999px; background: var(--soft); color: var(--brand-strong); font-size: 12px; font-weight: 800; }
.badge.gray { background: #eef2f4; color: #455660; }
.badge.warn { background: #fff7ed; color: #9a3412; }

.mail-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 20px;
}
.mail-side {
  position: sticky;
  top: 86px;
  align-self: start;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.mail-side a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: #33424c;
  font-weight: 700;
}
.mail-side a.active, .mail-side a:hover { background: var(--soft); color: var(--brand-strong); }
.mail-main { min-width: 0; }
.message-list { display: grid; gap: 10px; }
.message-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.32fr) minmax(220px, 1fr) 120px;
  gap: 14px;
  align-items: center;
  min-height: 66px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.message-row.unread { border-color: #99f6e4; background: #f0fdfa; }
.message-subject { font-weight: 800; overflow-wrap: anywhere; }
.message-body {
  min-height: 320px;
  white-space: pre-wrap;
  line-height: 1.7;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status-line { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 0; }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px 18px; }
  .nav { justify-content: flex-start; }
  .hero, .grid.two, .grid.three, .grid.four, .form-grid, .mail-shell { grid-template-columns: 1fr; }
  h1 { font-size: 30px; }
  .mail-side { position: static; }
  .message-row { grid-template-columns: 1fr; }
}
