:root {
  --bg: #edf2ff;
  --bg2: #f8fbff;
  --card: #ffffff;
  --text: #0f1d33;
  --muted: #566883;
  --primary: #0f2e63;
  --primary-soft: #e1eaf8;
  --border: #d5e0ef;
  --danger-bg: #fde7e7;
  --danger-text: #7c1d1d;
  --danger-border: #efc1c1;
  --success-bg: #e8f7ec;
  --success-text: #0d5b25;
  --success-border: #bfe5c9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 8% 12%, #dce9ff 0%, var(--bg) 32%, var(--bg2) 100%);
}
.app-shell { min-height: 100vh; }
.app-shell-authed { display: grid; grid-template-columns: 270px 1fr; }
.sidebar {
  background: linear-gradient(180deg, #0f2e63 0%, #10284f 100%);
  color: #fff;
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar-brand { margin-bottom: 1rem; }
.sidebar-logo { width: 170px; height: auto; margin-bottom: 0.3rem; }
.sidebar-brand p { margin: 0; opacity: 0.85; font-size: 0.85rem; }
.side-nav { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.8rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #d9e6ff;
  text-decoration: none;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  transition: background-color 0.2s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.12); }
.nav-item.active { background: rgba(255, 255, 255, 0.2); color: #fff; }
.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  opacity: 0.8;
  font-size: 0.85rem;
}
.main-area { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: linear-gradient(90deg, #0f2e63 0%, #153a78 100%);
  color: #fff;
  border-bottom: 1px solid #2b4c84;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 0.7rem; }
.topbar-logo { width: 130px; height: auto; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }
.topbar-title-wrap { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-title-wrap strong { font-size: 1rem; }
.topbar-title-wrap span { font-size: 0.78rem; opacity: 0.9; }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; }
.top-link {
  text-decoration: none;
  color: #e8f0ff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.top-link:hover { color: #ffffff; }
.inline-form { margin: 0; }
.logout-btn {
  margin: 0;
  border: 1px solid #6d8ec6;
  border-radius: 8px;
  padding: 0.45rem 0.72rem;
  background: #0d2348;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.container { max-width: 1160px; margin: 1.1rem auto; padding: 0 1rem 1.2rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.05rem;
  box-shadow: 0 10px 26px rgba(15, 46, 99, 0.07);
  margin-bottom: 1rem;
}
.card h2, .card h3 { margin-top: 0; display: flex; align-items: center; gap: 0.5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.9rem; }
.stat { font-size: 1.8rem; font-weight: 800; margin: 0.2rem 0 0; color: #102f62; }
.form-grid { display: grid; gap: 0.5rem; }
.two-col { grid-template-columns: 1fr 1fr; column-gap: 0.9rem; }
label { font-weight: 600; font-size: 0.93rem; color: #223556; }
input, select {
  padding: 0.62rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}
button {
  margin-top: 0.5rem;
  padding: 0.68rem;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.6rem; border-bottom: 1px solid var(--border); }
.alert { border: 1px solid transparent; border-radius: 8px; padding: 0.7rem 0.8rem; margin-bottom: 0.8rem; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.muted { color: var(--muted); }
.placeholder-list { display: grid; gap: 0.45rem; }
.placeholder-row {
  background: #f6f9ff;
  border: 1px solid #dce6f7;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  color: #27426d;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
@media (max-width: 980px) {
  .app-shell-authed { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
}
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 0.55rem; }
  .two-col { grid-template-columns: 1fr; }
  .sidebar-logo { width: 140px; }
  .topbar-logo { width: 110px; }
}
.table-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.btn-mini {
  margin-top: 0;
  padding: 0.38rem 0.62rem;
  font-size: 0.82rem;
}

.btn-soft {
  background: #315a9f;
}
.inbox-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1rem;
  align-items: start;
}

.message-list {
  display: grid;
  gap: 0.5rem;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding-right: 0.2rem;
}

.message-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  background: #f8fbff;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.message-row:hover {
  background: #eef5ff;
}

.message-row.selected {
  border-color: #8eaee3;
  background: #e9f1ff;
}

.message-dot {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.2rem;
  color: #1f4d93;
}

.message-main strong {
  display: inline-block;
  margin-bottom: 0.15rem;
}

.message-meta {
  color: #4a5f82;
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.message-time {
  color: #44597a;
  font-size: 0.8rem;
  white-space: nowrap;
}

.message-detail h4 {
  margin-top: 0;
}

.inbox-detail-card {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.mail-render-frame {
  width: 100%;
  min-height: 760px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.45rem;
}

@media (max-width: 980px) {
  .inbox-layout {
    grid-template-columns: 1fr;
  }
}
.side-folder-wrap {
  margin-top: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 0.7rem;
}

.side-folder-wrap h4 {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
  color: #dce8ff;
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: #d8e6ff;
  text-decoration: none;
  font-size: 0.86rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
}

.folder-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.folder-empty {
  color: #c4d6f9;
  font-size: 0.82rem;
  margin: 0.2rem 0 0;
}

.account-switch-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 0.5rem;
  flex-wrap: wrap;
  max-width: 560px;
}

.account-chip {
  margin: 0;
  border: 1px solid #7694c7;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  background: #143769;
  color: #e6efff;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  cursor: pointer;
}

.account-chip.active {
  background: #e8f0ff;
  color: #0f2e63;
  border-color: #b8ccef;
}

.dashboard-stat-grid .account-stat-card {
  min-height: 190px;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.mini-grid small {
  display: block;
  color: #506584;
}

.mini-grid strong {
  font-size: 1rem;
}

@media (max-width: 760px) {
  .account-switch-group {
    margin-right: 0;
    max-width: 100%;
  }
}
.folder-item.active {
  background: rgba(255,255,255,0.2);
}

.mail-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-chip {
  text-decoration: none;
  border: 1px solid #c2d3ef;
  color: #123465;
  background: #edf3ff;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.filter-chip.active {
  background: #0f2e63;
  color: #fff;
  border-color: #0f2e63;
}
.folder-item.active {
  background: rgba(255,255,255,0.2);
}

.mail-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-chip {
  text-decoration: none;
  border: 1px solid #c2d3ef;
  color: #123465;
  background: #edf3ff;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.filter-chip.active {
  background: #0f2e63;
  color: #fff;
  border-color: #0f2e63;
}

.folder-manage-list {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.45rem;
}

.folder-manage-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  background: #f8fbff;
}

.folder-inline-form {
  display: flex;
  gap: 0.3rem;
}

.folder-inline-form input {
  width: 120px;
  padding: 0.35rem;
  font-size: 0.82rem;
}

.btn-danger {
  background: #a13030;
}
