/* ════════════════════════════════════════════════════════════════════════════
   SEB & FV Portal – Stylesheet
   Schule am Pfaffenberg Mühltal
   ════════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Source+Sans+3:wght@300;400;500;600&display=swap');

/* ── Globale Basis-Regeln ───────────────────────────────────────────────────── */
[hidden] { display: none !important; }

/* ── CSS-Variablen ─────────────────────────────────────────────────────────── */
:root {
  --color-primary:       #2d6a4f;
  --color-primary-dark:  #1b4332;
  --color-primary-light: #52b788;
  --color-primary-bg:    #d8f3dc;
  --color-accent:        #e9a800;
  --color-accent-dark:   #b97d00;
  --color-bg:            #f8faf8;
  --color-surface:       #ffffff;
  --color-border:        #d4e6d4;
  --color-text:          #1a2e1a;
  --color-text-muted:    #5a7a5a;
  --color-danger:        #c0392b;
  --color-danger-bg:     #fdecea;

  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body:    'Source Sans 3', system-ui, sans-serif;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  14px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12);

  --transition: 150ms ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { display: block; max-width: 100%; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
ul, ol { list-style: none; }

/* ── Loading-Overlay ────────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 9999;
  transition: opacity 400ms ease;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error-Banner ───────────────────────────────────────────────────────────── */
#error-banner {
  display: none;
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  margin: 1rem;
  font-size: .9rem;
}
#error-banner.visible { display: block; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.portal-header {
  background: var(--color-primary-dark);
  color: #fff;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.header-brand .logo {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.header-brand h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  line-height: 1.2;
  font-weight: 700;
}
.header-brand .subtitle {
  font-size: .75rem;
  opacity: .75;
  font-weight: 300;
}

.header-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
}
.user-badge {
  background: rgba(255,255,255,.15);
  border-radius: 999px;
  padding: .3rem .75rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.user-badge .user-name { font-weight: 500; }
.user-badge .user-role {
  font-size: .7rem;
  opacity: .8;
  background: var(--color-accent);
  color: var(--color-primary-dark);
  border-radius: 999px;
  padding: .1rem .4rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.logout-btn {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: .3rem .7rem;
  font-size: .8rem;
  transition: background var(--transition);
}
.logout-btn:hover { background: rgba(255,255,255,.22); }

.notif-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: .3rem .5rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  opacity: .7;
}
.notif-btn:hover    { background: rgba(255,255,255,.12); opacity: 1; }
.notif-btn.notif-active { opacity: 1; }
#refresh-btn.refreshing { animation: refresh-spin .6s linear; }
@keyframes refresh-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Navigations-Tabs ────────────────────────────────────────────────────────── */
.portal-nav {
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  padding: 0 1.5rem;
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.portal-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .875rem 1.1rem;
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: .9rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  position: relative;
}
.nav-tab:hover { color: var(--color-primary); }
.nav-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.nav-tab .tab-icon { font-size: 1.1rem; }
.tab-badge {
  background: var(--color-accent);
  color: var(--color-primary-dark);
  font-size: .65rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .1rem .4rem;
  min-width: 18px;
  text-align: center;
}

/* ── Hauptbereich ────────────────────────────────────────────────────────────── */
.portal-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ── Modul-Panels ────────────────────────────────────────────────────────────── */
.module-panel {
  display: none;
  animation: fadeIn 200ms ease;
}
.module-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Karten ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-primary-bg);
}
.card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--color-primary-dark);
}
.card-body { padding: 1.25rem; }

/* ── Dashboard-Übersicht (Begrüßungskarte) ───────────────────────────────────── */
.welcome-card {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-md);
}
.welcome-card h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: .25rem;
}
.welcome-card p { font-size: .9rem; opacity: .85; }
.welcome-card .welcome-icon {
  font-size: 3rem;
  opacity: .3;
}

/* ── Module-Grid ─────────────────────────────────────────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.module-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-sm);
}
.module-tile:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary-light);
  transform: translateY(-2px);
}
.module-tile .tile-icon { font-size: 2rem; }
.module-tile .tile-label {
  font-weight: 600;
  font-size: .95rem;
  color: var(--color-text);
}
.module-tile .tile-desc {
  font-size: .8rem;
  color: var(--color-text-muted);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  border: none;
  transition: background var(--transition), opacity var(--transition);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-secondary {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-border); }
.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}
.btn-danger:hover:not(:disabled) { background: var(--color-danger); color: #fff; }

/* ── Placeholder für Module ──────────────────────────────────────────────────── */
.module-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}
.module-placeholder .placeholder-icon { font-size: 3rem; margin-bottom: .75rem; }
.module-placeholder h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--color-primary-dark);
  margin-bottom: .5rem;
}
.module-placeholder p { font-size: .9rem; max-width: 360px; margin: 0 auto; }

/* ── Zugriff verweigert ──────────────────────────────────────────────────────── */
.access-denied {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  color: var(--color-danger);
  font-size: .9rem;
}

/* ── System-Status-Leiste (nur für server-admin) ─────────────────────────────── */
.status-bar {
  background: var(--color-primary-dark);
  border-bottom: 1px solid rgba(255,255,255,.1);
  overflow: hidden;
  transition: max-height 350ms ease, opacity 350ms ease;
  max-height: 60px;
  opacity: 1;
}
.status-bar.collapsed {
  max-height: 0;
  opacity: 0;
}
.status-bar-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .45rem 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.status-bar-inner::-webkit-scrollbar { display: none; }

.status-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  text-decoration: none;
  color: rgba(255,255,255,.75);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: color var(--transition);
}
.status-item:hover { color: #fff; text-decoration: none; }
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
  transition: background 300ms;
}
.status-dot.online  { background: #52e88a; box-shadow: 0 0 5px rgba(82,232,138,.6); }
.status-dot.offline { background: #e85252; box-shadow: 0 0 5px rgba(232,82,82,.6); }
.status-dot.checking { animation: pulse-dot 1s infinite; background: var(--color-accent); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* Status-Toggle-Button im Header */
.status-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.85);
  border-radius: var(--radius-sm);
  padding: .25rem .6rem;
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}
.status-toggle-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.status-toggle-btn .toggle-arrow { transition: transform 250ms; display: inline-block; }
.status-toggle-btn.open .toggle-arrow { transform: rotate(180deg); }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.portal-footer {
  text-align: center;
  padding: .75rem;
  font-size: .75rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-header { padding: .6rem 1rem; }
  .header-brand h1 { font-size: 1rem; }
  .header-brand .subtitle { display: none; }
  .portal-main { padding: 1rem; }
  .welcome-card { padding: 1rem 1.25rem; }
  .welcome-card h2 { font-size: 1.2rem; }
  .welcome-card .welcome-icon { display: none; }
  .module-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 480px) {
  .user-badge .user-name { display: none; }
  .nav-tab .tab-label { display: none; }
  .nav-tab { padding: .875rem .75rem; }
}

/* ════════════════════════════════════════════════════════════════════════════
   Modul: Admin (aus admin.js extrahiert)
   ════════════════════════════════════════════════════════════════════════════ */
.admin-modal { display:none; }
.admin-modal.is-open { position:fixed; inset:0; background:rgba(0,0,0,.5); display:flex;
  align-items:center; justify-content:center; z-index:500; padding:1rem; }
.admin-modal-box { background:var(--color-surface); border-radius:12px; padding:1.5rem;
  max-width:480px; width:100%; box-shadow:0 8px 32px rgba(0,0,0,.2); }
.admin-modal-title { font-family:var(--font-heading); font-size:1.1rem;
  color:var(--color-primary-dark); margin-bottom:.75rem; }
.admin-modal-footer { display:flex; justify-content:flex-end; gap:.5rem; margin-top:1rem; }
.admin-input { width:100%; padding:.5rem .75rem; border:1px solid var(--color-border);
  border-radius:6px; font-family:inherit; font-size:.9rem; background:var(--color-bg);
  color:var(--color-text); }
.admin-input:focus { outline:none; border-color:var(--color-primary);
  box-shadow:0 0 0 3px rgba(45,106,79,.12); }
.user-card { background:var(--color-bg); border:1px solid var(--color-border);
  border-radius:10px; padding:1rem; margin-bottom:.75rem; }
.user-card-header { display:flex; align-items:center; justify-content:space-between;
  gap:.5rem; flex-wrap:wrap; }
.user-name-block { display:flex; align-items:center; gap:.5rem; }
.user-active-badge { font-size:.7rem; padding:.15rem .4rem; border-radius:999px;
  font-weight:600; }
.badge-active { background:#d1fae5; color:#065f46; }
.badge-inactive { background:#fee2e2; color:#991b1b; }
.badge-class { background:var(--color-primary-bg); color:var(--color-primary-dark);
  font-size:.7rem; padding:.15rem .4rem; border-radius:999px; font-weight:600; }
.user-actions { display:flex; gap:.4rem; flex-wrap:wrap; margin-top:.6rem; }
.groups-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(130px,1fr));
  gap:.3rem; margin-top:.75rem; padding:.75rem; background:var(--color-primary-bg);
  border-radius:8px; }
.group-toggle { display:flex; align-items:center; gap:.35rem; cursor:pointer;
  font-size:.8rem; user-select:none; }
.group-toggle input { cursor:pointer; }
.search-box { width:100%; padding:.5rem .75rem; border:1px solid var(--color-border);
  border-radius:8px; font-family:inherit; font-size:.9rem; background:var(--color-surface);
  margin-bottom:1rem; }
.search-box:focus { outline:none; border-color:var(--color-primary); }
.token-card { background:var(--color-bg); border:1px solid var(--color-border);
  border-radius:10px; padding:1rem; margin-bottom:.75rem; }
.schuljahr-bar { background:var(--color-primary-bg); border:1px solid var(--color-border);
  border-radius:8px; padding:.75rem 1rem; margin-bottom:1rem;
  display:flex; align-items:center; justify-content:space-between; gap:.5rem; flex-wrap:wrap; }
@media(max-width:640px) {
  #admin-tab-tokens > div { grid-template-columns:1fr !important; }
  #admin-tab-tokens > div > div:first-child { grid-column:1; }
  #admin-tab-tokens > div > div:last-child  { grid-column:1; }
}

/* ════════════════════════════════════════════════════════════════════════════
   Modul: Kontakte (aus contacts.js extrahiert)
   ════════════════════════════════════════════════════════════════════════════ */
.contacts-root { padding: 0; }
.contacts-tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--color-border);
  padding: 0 1rem; background: var(--color-surface);
}
.contacts-tab-btn {
  padding: .65rem 1.1rem; background: none; border: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  cursor: pointer; font-size: .88rem; font-weight: 500;
  color: var(--color-text-muted); transition: color .15s, border-color .15s;
}
.contacts-tab-btn.active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary); font-weight: 700;
}
.contacts-tab-btn:disabled { opacity: .4; cursor: not-allowed; }
.contacts-panel { display: none; padding: 1.25rem; }
.contacts-panel.active { display: block; }
.contacts-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem;
}
.contacts-folder-info {
  font-size: .82rem; color: var(--color-text-muted);
  background: var(--color-primary-bg); border-radius: 6px; padding: .35rem .8rem;
}
.contacts-table-wrap { overflow-x: auto; }
.contacts-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.contacts-table th {
  background: var(--color-primary, #2d6a4f); color: #fff;
  font-weight: 600; font-size: .78rem; padding: .5rem .75rem;
  text-align: left; white-space: nowrap;
}
.contacts-table td {
  padding: .5rem .75rem; border-bottom: 1px solid var(--color-border);
  vertical-align: top; word-break: break-word;
}
.contacts-table tr:nth-child(even) td { background: var(--color-primary-bg); }
.contacts-table tr:hover td { background: #e8f5e9; }
.contacts-action-btn {
  background: none; border: 1px solid var(--color-border);
  border-radius: 4px; cursor: pointer; padding: 2px 7px;
  font-size: .8rem; color: var(--color-text-muted);
  transition: background .12s, color .12s;
}
.contacts-action-btn:hover { background: var(--color-primary-bg); color: var(--color-primary-dark); }
.contacts-action-btn.del:hover { background: #fde; color: #c0392b; border-color: #c0392b; }
.contacts-empty { text-align: center; color: var(--color-text-muted); padding: 2rem; font-size: .9rem; }
.contacts-pdf-result { margin-top: .75rem; padding: .5rem .9rem; border-radius: 6px; font-size: .82rem; }
.contacts-pdf-result.ok { background: #d4edda; color: #155724; }
.contacts-pdf-result.err { background: #f8d7da; color: #721c24; }
.contacts-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.contacts-modal {
  background: var(--color-surface); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2); width: 520px;
  max-width: 96vw; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.contacts-modal-header {
  padding: .9rem 1.25rem; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; color: var(--color-primary-dark); flex-shrink: 0;
}
.contacts-modal-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--color-text-muted); line-height: 1; padding: 2px 6px;
}
.contacts-modal-close:hover { color: #c0392b; }
.contacts-modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.contacts-modal-footer {
  padding: .75rem 1.25rem; border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end; gap: .5rem; flex-shrink: 0;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .75rem; }
.form-row.full { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: .25rem; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--color-text-muted); }
.form-group input, .form-group textarea {
  border: 1px solid var(--color-border); border-radius: 5px;
  padding: .4rem .7rem; font-size: .85rem;
  background: var(--color-bg); color: inherit; font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}
.contacts-modal-error { color: #c0392b; font-size: .82rem; margin-top: .5rem; }

/* ════════════════════════════════════════════════════════════════════════════
   Modul: Mail (aus mail.js extrahiert)
   ════════════════════════════════════════════════════════════════════════════ */
.mail-root {
  display: flex; height: calc(100vh - 180px); min-height: 500px;
  overflow: hidden; border: 1px solid var(--color-border);
  border-radius: 8px; background: var(--color-bg);
}
.mail-col-boxes {
  width: 180px; min-width: 140px; flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface); overflow-y: auto;
  display: flex; flex-direction: column;
}
.mail-col-boxes h3 {
  font-size: .75rem; font-weight: 700; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  padding: .75rem 1rem .4rem; margin: 0;
}
.mail-box-btn {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: .55rem 1rem;
  cursor: pointer; font-size: .85rem; color: var(--color-text, #333);
  border-left: 3px solid transparent; transition: background .15s, border-color .15s;
}
.mail-box-btn:hover { background: var(--color-primary-bg); }
.mail-box-btn.active {
  border-left-color: var(--color-primary); background: var(--color-primary-bg);
  font-weight: 600; color: var(--color-primary-dark);
}
.mail-folder-btn {
  display: flex; align-items: center; gap: .35rem;
  width: 100%; text-align: left;
  background: none; border: none; padding: .4rem 1rem;
  cursor: pointer; font-size: .82rem; color: var(--color-text, #333);
  border-left: 3px solid transparent; transition: background .15s, border-color .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mail-folder-btn:hover { background: var(--color-primary-bg); }
.mail-folder-btn.active {
  border-left-color: var(--color-primary); background: var(--color-primary-bg);
  font-weight: 600; color: var(--color-primary-dark);
}
.mail-folder-icon { flex-shrink: 0; font-size: .85rem; }
.mail-box-unread {
  display: inline-block; background: var(--color-primary); color: #fff;
  border-radius: 10px; font-size: .7rem; padding: 1px 6px;
  margin-left: 4px; vertical-align: middle;
}
.mail-col-list {
  width: 300px; min-width: 220px; flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; overflow: hidden;
}
.mail-list-header {
  padding: .6rem 1rem; border-bottom: 1px solid var(--color-border);
  background: var(--color-surface); flex-shrink: 0;
  font-size: .8rem; color: var(--color-text-muted);
}
.mail-list-scroll { flex: 1; overflow-y: auto; }
.mail-msg-item {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .65rem 1rem; cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background .12s; position: relative;
}
.mail-msg-item:hover { background: var(--color-primary-bg); }
.mail-msg-item.active { background: var(--color-primary-bg); border-left: 3px solid var(--color-primary); }
.mail-msg-unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-primary); flex-shrink: 0; margin-top: 5px;
}
.mail-msg-body { flex: 1; min-width: 0; }
.mail-msg-from {
  font-size: .82rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--color-text, #333);
}
.mail-msg-item:not(.unread) .mail-msg-from { font-weight: 400; }
.mail-msg-subject {
  font-size: .78rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  color: var(--color-text-muted); margin-top: 1px;
}
.mail-msg-date {
  font-size: .72rem; color: var(--color-text-muted);
  white-space: nowrap; flex-shrink: 0; align-self: flex-start;
}
.mail-msg-delete {
  display: none; position: absolute; right: .5rem; top: 50%;
  transform: translateY(-50%); background: none; border: none;
  cursor: pointer; color: var(--color-text-muted);
  font-size: 1rem; padding: 2px 4px; border-radius: 4px;
}
.mail-msg-item:hover .mail-msg-delete { display: block; }
.mail-msg-delete:hover { color: #c0392b; background: #fde; }
.mail-load-more {
  display: block; width: 100%; text-align: center;
  padding: .7rem; background: none; border: none;
  border-top: 1px solid var(--color-border);
  cursor: pointer; font-size: .82rem; color: var(--color-primary);
}
.mail-load-more:hover { background: var(--color-primary-bg); }
.mail-col-read {
  flex: 1; min-width: 0; display: flex;
  flex-direction: column; overflow: hidden;
}
.mail-read-header {
  padding: .75rem 1.25rem; border-bottom: 1px solid var(--color-border);
  background: var(--color-surface); flex-shrink: 0;
}
.mail-read-meta { font-size: .8rem; color: var(--color-text-muted); line-height: 1.7; }
.mail-read-subject {
  font-size: 1.05rem; font-weight: 700;
  color: var(--color-primary-dark); margin: 0 0 .3rem;
}
.mail-read-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.mail-read-body { flex: 1; overflow: hidden; position: relative; }
.mail-read-body iframe { width: 100%; height: 100%; border: none; display: block; }
.mail-read-body pre {
  margin: 0; padding: 1rem 1.25rem; white-space: pre-wrap;
  word-break: break-word; font-size: .85rem; line-height: 1.6;
  overflow-y: auto; height: 100%; box-sizing: border-box; font-family: inherit;
}
.mail-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%;
  color: var(--color-text-muted); font-size: .9rem; gap: .5rem;
}
.mail-empty-icon { font-size: 2.5rem; }
.mail-attachments {
  padding: .5rem 1.25rem; border-top: 1px solid var(--color-border);
  font-size: .8rem; color: var(--color-text-muted);
  background: var(--color-surface); flex-shrink: 0;
}
.mail-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.mail-modal {
  background: var(--color-surface); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2); width: 560px;
  max-width: 96vw; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.mail-modal-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: .95rem; color: var(--color-primary-dark); flex-shrink: 0;
}
.mail-modal-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--color-text-muted); line-height: 1; padding: 2px 6px;
}
.mail-modal-close:hover { color: #c0392b; }
.mail-modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.mail-modal-footer {
  padding: .75rem 1.25rem; border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end; gap: .5rem; flex-shrink: 0;
}
.mail-tmpl-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--color-border); margin-bottom: 1rem;
}
.mail-tmpl-tab {
  padding: .4rem 1rem; background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  font-size: .85rem; color: var(--color-text-muted); margin-bottom: -1px;
}
.mail-tmpl-tab.active {
  border-bottom-color: var(--color-primary);
  color: var(--color-primary-dark); font-weight: 600;
}
.mail-modal.mail-compose { width: 640px; }
.mail-compose-field { display:flex; flex-direction:column; margin-bottom:.75rem; }
.mail-compose-field label { font-size:.82rem; font-weight:600; margin-bottom:.25rem; }
.mail-compose-field input, .mail-compose-field textarea, .mail-compose-field select {
  padding:.45rem .65rem; border:1px solid var(--color-border);
  border-radius:var(--radius-sm); font-size:.85rem;
  background:var(--color-bg); color:var(--color-text); box-sizing:border-box; width:100%;
}
.mail-compose-field textarea { min-height:180px; font-family:inherit; resize:vertical; }
.fwd-recipients { max-height:200px; overflow-y:auto; border:1px solid var(--color-border);
  border-radius:var(--radius-sm); background:var(--color-bg); font-size:.8rem; padding:.4rem 0; }
.fwd-recipients-row { padding:.25rem .75rem; border-bottom:1px solid var(--color-border); display:flex; gap:.5rem; }
.fwd-recipients-row:last-child { border-bottom:none; }
.fwd-recipients-name { color:var(--color-text-muted); min-width:100px; flex-shrink:0; }
@media (max-width: 700px) {
  .mail-root { flex-direction: column; height: auto; min-height: unset; }
  .mail-col-boxes { width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); flex-direction: row; overflow-x: auto; }
  .mail-col-boxes h3 { display: none; }
  .mail-box-btn { border-left: none; border-bottom: 3px solid transparent; }
  .mail-box-btn.active { border-bottom-color: var(--color-primary); border-left-color: transparent; }
  .mail-col-list { width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); max-height: 280px; }
  .mail-col-read { min-height: 300px; }
}
