:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #14181f;
  --ink-2: #4b5565;
  --ink-3: #8a94a6;
  --line: #e2e6ec;
  --line-2: #eef1f5;
  --nav: #101720;
  --nav-ink: #c7d0dc;
  --nav-active: #1c2734;
  --accent: #1c5ed6;
  --accent-ink: #ffffff;
  --ok: #157f4a;
  --ok-bg: #e7f5ee;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.boot { padding: 48px; color: var(--ink-3); }

/* ------------------------------- login ---------------------------------- */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #0d141d 0%, #1b2836 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .35);
}
.login-card h1 { font-size: 17px; margin: 0 0 4px; letter-spacing: .2px; }
.login-card .sub { color: var(--ink-3); font-size: 12.5px; margin-bottom: 22px; }
.login-card .domain { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }

/* ------------------------------- layout --------------------------------- */

.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.side {
  background: var(--nav);
  color: var(--nav-ink);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 4px 10px 18px; }
.brand b { display: block; color: #fff; font-size: 13.5px; letter-spacing: .3px; }
.brand span { font-size: 11.5px; color: #7d8b9d; font-family: ui-monospace, Menlo, monospace; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--nav-ink);
  padding: 9px 11px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 13.5px;
}
.nav button:hover { background: rgba(255, 255, 255, .06); }
.nav button.active { background: var(--nav-active); color: #fff; }
.nav .ic { width: 17px; display: inline-block; text-align: center; opacity: .9; }
.nav .badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 600;
}
.side-foot { margin-top: auto; padding: 10px; font-size: 11.5px; color: #64748b; }
.side-foot button {
  background: transparent; border: 1px solid #2a3644; color: var(--nav-ink);
  padding: 6px 10px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 12.5px; width: 100%;
}
.side-foot button:hover { background: rgba(255, 255, 255, .06); }

/* who-am-I chip in the sidebar footer */
.side-foot .who {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 2px 9px; margin-bottom: 8px;
  border-bottom: 1px solid #2a3644;
  font-size: 12px; color: var(--nav-ink);
}
.side-foot .who-dot {
  flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%;
  background: #64748b;
}
.side-foot .who-dot.admin { background: var(--ok, #22c55e); }
.side-foot .who-txt {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.main { padding: 22px 26px 60px; max-width: 1180px; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; margin: 0; letter-spacing: .2px; }
.page-head .spacer { flex: 1; }

/* ------------------------------- widgets -------------------------------- */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 18px 20px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: 13.5px; color: var(--ink);
  background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28, 94, 214, .12); }
textarea { resize: vertical; min-height: 200px; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: var(--accent-ink); border: 0;
  padding: 9px 16px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 550;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f8fafc; }
.btn.danger { background: var(--bad); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.mute { background: var(--line-2); color: var(--ink-2); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
     color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ------------------------------ mail list ------------------------------- */

.mail-list { padding: 6px; }
.mail-item {
  display: grid; grid-template-columns: 190px 1fr auto; gap: 12px;
  padding: 11px 13px; border-radius: 8px; cursor: pointer; align-items: baseline;
}
.mail-item:hover { background: #f6f8fb; }
.mail-item.unread .mi-from, .mail-item.unread .mi-subj { font-weight: 700; }
.mi-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-subj { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.mi-subj .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-subj .snip { color: var(--ink-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.mi-date { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

.reader { padding: 20px 22px; }
.reader h2 { font-size: 17px; margin: 0 0 12px; }
.meta { display: grid; grid-template-columns: 76px 1fr; gap: 4px 10px; font-size: 13px; margin-bottom: 16px; }
.meta dt { color: var(--ink-3); }
.meta dd { margin: 0; word-break: break-word; }
.body-box { border-top: 1px solid var(--line); padding-top: 16px; }
.body-box iframe { width: 100%; min-height: 380px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
pre.plain { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13.5px; margin: 0; }

.att-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.att-row a { text-decoration: none; }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 24px; font-weight: 680; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v.small { font-size: 16px; font-weight: 600; }

.bar { height: 8px; border-radius: 999px; background: var(--bad-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  background: #101720; color: #fff; padding: 11px 16px; border-radius: 9px;
  font-size: 13.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); max-width: 420px;
}
.toast.bad { background: var(--bad); }

.notice { border-radius: 8px; padding: 11px 14px; font-size: 13px; margin-bottom: 14px; }
.notice.info { background: #eef4ff; color: #143a86; border: 1px solid #d6e3ff; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f2e0bb; }
.notice.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid #f6d3d0; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 13px; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink-2); }
.seg button.active { background: var(--accent); color: #fff; }

.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 26px; text-align: center; color: var(--ink-3); background: #fbfcfe; }
.drop.hot { border-color: var(--accent); background: #f2f7ff; color: var(--accent); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .mail-item { grid-template-columns: 1fr auto; }
  .mail-item .mi-from { grid-column: 1 / -1; }
}
