:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #f6821f;
  --accent-dark: #d96d0c;
  --blue: #2563eb;
  --ok: #15803d;
  --error: #b91c1c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.nav-link:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav-link.active { background: #fff3e6; color: var(--accent-dark); }

.user-box { display: flex; align-items: center; gap: 10px; }
.user-email { color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { max-width: 1080px; margin: 24px auto 60px; padding: 0 20px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px;
  border-top: 1px solid var(--border);
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfbfc;
}
.card-actions { display: flex; gap: 8px; }
.card-body { padding: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fbfbfc; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #f2f3f5; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--error); border-color: #f3c7c7; }
.btn-danger:hover { background: #fdf2f2; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

form.inline { display: inline; }

label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #ffd9b0; border-color: var(--accent); }
textarea { resize: vertical; min-height: 160px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.flash-ok { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.flash-error { background: #fef2f2; border-color: #fecaca; color: var(--error); }

.empty { padding: 32px; text-align: center; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #eef1f4;
  color: var(--muted);
}
.badge-ok { background: #dcfce7; color: var(--ok); }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-error { background: #fee2e2; color: var(--error); }

.mail-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.mail-sidebar { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.sidebar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.sidebar-item:hover { background: var(--bg); text-decoration: none; }
.sidebar-item.active { background: #fff3e6; color: var(--accent-dark); font-weight: 600; }

.msg-row { display: flex; gap: 12px; align-items: baseline; }
.msg-from { font-weight: 600; min-width: 150px; }
.msg-subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.unread .msg-from, .unread .msg-subject { font-weight: 700; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; }

.reader-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 16px; }
.reader-subject { font-size: 19px; font-weight: 700; margin-bottom: 8px; }
.reader-meta { color: var(--muted); font-size: 13px; }
.reader-body { overflow-x: auto; }
.reader-body img { max-width: 100%; height: auto; }
.reader-body iframe { display: none; }

.attach-list { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.attach-item { display: flex; gap: 10px; align-items: center; padding: 6px 0; }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

.login-wrap { max-width: 380px; margin: 60px auto; }
.login-wrap .card-body { padding: 24px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .nav { order: 3; width: 100%; }
  .mail-layout { grid-template-columns: 1fr; }
  .msg-from { min-width: 0; }
  .content { padding: 0 14px; }
}
