@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f5f8ff;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #5b6478;
  --accent: #2563eb;
  --accent2: #14b8a6;
  --danger: #b91c1c;
  --border: #d8e1f0;
  --focus: #7c8cff;
}
* { box-sizing: border-box; }
.text-wrap {
  overflow-wrap: anywhere;
  word-break: break-word;
}
body {
  margin: 0;
  font-family: "Inter", "Segoe UI Variable", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: var(--text);
  background: var(--bg);
}
.topbar, .nav, .container, .footer { padding: 12px 24px; }
.topbar > *,
.brand > *,
.grid > *,
.mail-client-grid > *,
.mail-client-grid-robust > *,
.mail-topbar > *,
.message-row-head > * {
  min-width: 0;
}
.topbar {
  background: linear-gradient(90deg, #1d4ed8, #06b6d4);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.35rem; }
.logo { width: 40px; height: 40px; }
.logo.large { width: 72px; height: 72px; }
.muted { color: var(--muted); }
.topbar .muted { color: #dbeafe; }
.nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 12px;
}
.nav a.active {
  background: #e8eeff;
  color: #1e40af;
}
.container {
  display: grid;
  gap: 16px;
  max-width: 1450px;
  width: 100%;
  margin: 0 auto;
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 6px 18px rgba(23, 45, 99, 0.08);
}
.card h2, .card h3, .card h4 { margin-top: 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}
th, td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
th { background: #edf3ff; }
input, select, textarea, button {
  width: 100%;
  margin-top: 6px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #c6d4ef;
  border-radius: 8px;
}
input:focus, select:focus, textarea:focus, button:focus, a:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
}
button, .button-link {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  font-weight: 600;
  transition: all 160ms ease;
}
button:hover, .button-link:hover { background: #1d4ed8; transform: translateY(-1px); }
button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
.error {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px;
}
.notice {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.timestamps { text-align: right; font-size: 13px; }
.stats div {
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  text-align: center;
}
.stats span {
  color: var(--muted);
  display: block;
}
.stats strong {
  font-size: 24px;
  color: var(--accent2);
}
.footer {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.footer-icon { width: 20px; height: 20px; }
pre {
  white-space: pre-wrap;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
}
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-box {
  width: 420px;
  max-width: 92vw;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
#calendar {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-cell {
  border: 1px solid #e5eaf7;
  min-height: 36px;
  border-radius: 4px;
  text-align: center;
  font-size: 12px;
  padding-top: 4px;
}
.calendar-header {
  font-weight: bold;
  background: #eff6ff;
}
.mail-client-grid {
  display: grid;
  grid-template-columns: 220px 1.6fr 1fr;
  gap: 16px;
}
.mail-client-grid-robust {
  display: grid;
  grid-template-columns: 240px 1.5fr 1fr;
  gap: 16px;
}
.mail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.mail-search-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  width: 100%;
}
.mail-topbar button {
  width: auto;
  margin: 0;
}
.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.mail-sidebar {
  background: #251a4f;
  color: #eef2ff;
  border-radius: 12px;
  padding: 14px;
}
.mail-sidebar h3, .mail-sidebar h4 { margin-top: 0; color: #eef2ff; }
.folder-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: #e9e9ff;
  border: 1px solid #413676;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.folder-pill.active {
  background: #5b43c4;
  border-color: #8874e1;
}
.folder-pill span {
  background: #fff;
  color: #2a1f5f;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}
.notification-stack {
  display: grid;
  gap: 8px;
}
.notify-card {
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.notify-card.info { background: #dbeafe; color: #1e3a8a; }
.notify-card.warning { background: #fef3c7; color: #92400e; }
.notify-card.success { background: #dcfce7; color: #166534; }
.mail-list-panel, .mail-detail-panel {
  max-height: 70vh;
  overflow: auto;
}
.message-list {
  display: grid;
  gap: 8px;
}
.message-row {
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}
.message-row.selected {
  border-color: #4f46e5;
  background: #eef2ff;
}
.message-row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.message-row-subject {
  font-weight: 700;
  margin-top: 4px;
}
.message-row-preview {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}
.message-row-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.chip {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid #c6d4ef;
}
.chip.attach { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.chip.unread { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.chip.high { background: #fff1f2; border-color: #fb7185; color: #9f1239; }
.simple-list {
  list-style: none;
  padding-left: 0;
}
.simple-list li {
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
}
.folder-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.folder-list li {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
}
.selected-row {
  background: #e0ecff;
}
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form input,
.inline-form select,
.inline-form button {
  width: auto;
  margin: 0;
}
.trend-bar-wrap {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.trend-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
}
.action-row {
  margin-top: 10px;
}
.action-form {
  display: inline-block;
}
.action-form button {
  width: auto;
  margin: 0;
  padding: 10px 14px;
}
p,
li,
label,
span,
a,
code,
.message-row-subject,
.message-row-preview,
.notify-card,
.folder-pill,
.muted {
  overflow-wrap: anywhere;
  word-break: break-word;
}
@media (max-width: 900px) {
  .grid.two, .grid.four, .mail-client-grid, .mail-client-grid-robust { grid-template-columns: 1fr; }
  .mail-search-form { grid-template-columns: 1fr; }
  .mail-topbar { display: grid; }
  .timestamps { text-align: left; }
}
