
:root {
  --bg: #020c22;
  --panel: #07152f;
  --panel-2: #0b1e44;
  --text: #f5f8ff;
  --muted: #98afcf;
  --border: #20365e;
  --primary: #2f6bff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, Helvetica, sans-serif; }
a { color: inherit; text-decoration: none; }
.mobile-only { display: none !important; }
.desktop-only-inline { display: block; }
.desktop-only { display: inline-flex; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 12px;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background:#081634;
}
.topbar-left { display:flex; align-items:center; gap:12px; min-width: 0; }
.topbar-actions { display:flex; gap:10px; align-items:center; flex-wrap: wrap; justify-content: flex-end; }
.mailbox-pill {
  display:inline-flex;
  align-items:center;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  color: var(--muted);
  background: rgba(11,30,68,.35);
  font-size:12px;
}
.layout {
  display:grid;
  grid-template-columns: 240px minmax(280px, 390px) minmax(320px, 1fr);
  min-height: calc(100vh - 66px);
}
.folders-panel, .messages-panel, .detail-panel {
  min-width: 0;
  border-right:1px solid var(--border);
  padding:16px 14px;
  background: transparent;
}
.detail-panel { border-right:none; }
.panel-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:14px;
}
.sticky-head {
  position: sticky;
  top: 79px;
  z-index: 10;
  padding-bottom: 12px;
  background: linear-gradient(180deg, rgba(2,12,34,0.98), rgba(2,12,34,0.88));
  backdrop-filter: blur(6px);
}
.folder-list, .messages-list { display:flex; flex-direction:column; gap:10px; }
.folder-item, .message-item {
  border:1px solid var(--border);
  background:rgba(11,30,68,.55);
  color:var(--text);
  border-radius:16px;
  padding:14px 12px;
  text-align:left;
  cursor:pointer;
  box-shadow: none;
}
.folder-item.active, .message-item.active { outline:2px solid #5a8cff; }
.message-item.unseen .message-subject { font-weight:700; }
.message-item { width:100%; }
.message-line { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.message-subject { font-size: 15px; font-weight: 600; margin-bottom: 6px; line-height: 1.35; }
.message-from, .message-date, .muted, .small { color: var(--muted); font-size: 13px; }
.message-date { flex-shrink: 0; text-align: right; }
.empty, .detail-empty { color: var(--muted); padding: 10px; }
.mail-view h2 { margin: 0 0 8px; line-height: 1.3; }
.meta-row { margin-bottom: 8px; color: var(--muted); word-break: break-word; }
.mail-body {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(11,30,68,.35);
  min-height: 280px;
  overflow: auto;
  word-break: break-word;
}
.mail-body img { max-width: 100%; height: auto; }
.mail-body pre { white-space: pre-wrap; word-break: break-word; }
.btn {
  border:none;
  border-radius: 12px;
  background:#0f2248;
  color:#fff;
  padding:10px 16px;
  cursor:pointer;
  min-height: 42px;
}
.btn.primary { background: var(--primary); }
.btn.ghost { background: rgba(11,30,68,.42); border:1px solid var(--border); }
.btn.danger { background:#8b1e1e; color:#fff; }
.btn.icon-only { width:42px; padding:0; display:inline-flex; align-items:center; justify-content:center; }
.login-body { display:grid; place-items:center; min-height:100vh; padding: 20px; }
.login-card { width: min(420px, 100%); background: var(--panel); border:1px solid var(--border); border-radius:18px; padding:24px; }
.login-form { display:flex; flex-direction:column; gap:10px; }
.login-form input, .modal-body input, .modal-body textarea {
  width:100%; background:#07132b; color:#fff; border:1px solid var(--border); border-radius:12px; padding:12px;
}
.alert { margin: 10px 0 14px; padding: 12px; background: #35121a; border:1px solid #6d2431; border-radius:12px; color:#ffd9e1; }
.modal.hidden { display:none; }
.modal { position:fixed; inset:0; background: rgba(0,0,0,.55); display:grid; place-items:center; z-index: 90; }
.modal-card { width:min(820px, calc(100vw - 32px)); max-height: min(92vh, 980px); display:flex; flex-direction:column; background:var(--panel); border:1px solid var(--border); border-radius:18px; overflow:hidden; box-shadow: var(--shadow); }
.modal-header, .modal-footer { padding:14px 16px; border-bottom:1px solid var(--border); }
.modal-footer { border-top:1px solid var(--border); border-bottom:none; display:flex; justify-content:flex-end; gap:10px; flex-wrap: wrap; }
.modal-body { padding:16px; display:grid; gap:12px; overflow:auto; }
.icon-btn { background:none; border:none; color:#fff; font-size:28px; cursor:pointer; line-height: 1; }
.detail-header { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:12px; }
.detail-badges { display:flex; gap:8px; flex-wrap:wrap; }
.badge { display:inline-flex; align-items:center; padding:6px 10px; border-radius:999px; border:1px solid var(--border); color:var(--muted); background:rgba(11,30,68,.35); font-size:12px; }
.detail-grid { display:grid; gap:8px; margin-bottom:10px; }
.detail-actions { display:flex; gap:8px; margin:12px 0; flex-wrap:wrap; }
.compose-grid-two { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.compose-card label { display:block; margin:0 0 6px; color:var(--muted); font-size:13px; }
.editor-card, .attachment-card { border:1px solid var(--border); border-radius:14px; background:rgba(11,30,68,.25); overflow:hidden; }
.editor-toolbar { display:flex; gap:8px; flex-wrap:wrap; padding:10px; border-bottom:1px solid var(--border); background:rgba(7,21,47,.85); position: sticky; top: 0; z-index: 1; }
.toolbar-btn { border:1px solid var(--border); background:#10234b; color:#fff; border-radius:10px; padding:8px 10px; cursor:pointer; font-size:13px; }
.compose-editor { min-height:240px; padding:14px; outline:none; color:#fff; line-height: 1.5; }
.compose-editor:empty:before { content: attr(data-placeholder); color: #7f95b8; }
.hidden-field { display:none; }
.attachment-card { padding:12px; display:grid; gap:8px; }
.attachment-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.attachment-btn { display:inline-flex; width:auto; align-items:center; justify-content:center; }
.attachment-list { list-style:none; margin:0; padding:0; display:grid; gap:8px; }
.attachment-item { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px; border:1px solid var(--border); border-radius:12px; background:#0a1836; }
.attachment-item small { color:var(--muted); }
.attachment-remove { border:none; background:#3c1730; color:#ffd9f0; border-radius:10px; padding:8px 10px; cursor:pointer; }
.compose-header h3 { margin:0; }
.mobile-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 59;
}
.mobile-scrim.hidden { display:none; }
@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(280px, 340px) minmax(300px, 1fr); }
}
@media (max-width: 960px) {
  .mobile-only { display: inline-flex !important; }
  .desktop-only-inline, .desktop-only { display:none !important; }
  .topbar { padding: 12px 14px; }
  .topbar-actions { gap:8px; }
  .mailbox-pill { display:none; }
  .layout { display:block; min-height: calc(100vh - 62px); }
  .folders-panel, .messages-panel, .detail-panel {
    border-right:none;
    padding: 14px;
  }
  .folders-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 84vw);
    background: #07152f;
    z-index: 60;
    transform: translateX(-105%);
    transition: transform .24s ease;
    overflow: auto;
    box-shadow: var(--shadow);
  }
  body.show-folders .folders-panel { transform: translateX(0); }
  .messages-panel { display:block; }
  .detail-panel {
    position: fixed;
    inset: 62px 0 0 0;
    background: var(--bg);
    z-index: 50;
    overflow: auto;
    transform: translateX(100%);
    transition: transform .24s ease;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  body.show-detail .detail-panel { transform: translateX(0); }
  .sticky-head { top: 0; }
  .detail-topbar { margin: -14px -14px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  body.show-detail #messagesPanel { visibility:hidden; pointer-events:none; }
  .message-item { padding: 14px; }
  .message-line { flex-direction: column; gap: 4px; }
  .message-date { text-align:left; }
  .detail-actions .btn { flex: 1 1 calc(50% - 8px); }
  .modal { align-items: stretch; }
  .modal-card {
    width: 100vw;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .sticky-compose-head, .sticky-compose-footer {
    position: sticky;
    background: var(--panel);
    z-index: 2;
  }
  .sticky-compose-head { top: 0; }
  .sticky-compose-footer { bottom: 0; }
}
@media (max-width: 700px) {
  .compose-grid-two { grid-template-columns:1fr; }
  .topbar-actions .btn { padding: 10px 12px; }
  .detail-actions .btn { flex: 1 1 100%; }
  .toolbar-btn { font-size: 12px; padding: 8px 9px; }
  .modal-body { padding: 12px; }
}

.admin-card {
  width: min(1100px, 96vw);
}
.admin-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 22px; }
.admin-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
}
.admin-section {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}
.admin-section-wide { min-width: 0; }
.compact-head { padding: 0 0 12px; }
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.admin-form-actions {
  display: flex;
  justify-content: flex-end;
}
.admin-accounts-list {
  display: grid;
  gap: 12px;
  max-height: 60vh;
  overflow: auto;
  padding-right: 4px;
}
.account-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,.03);
}
.account-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.account-card-head h5 {
  margin: 0 0 4px;
  font-size: 16px;
}
.account-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.small-btn {
  padding: 8px 10px;
  font-size: 12px;
}
.badge-admin {
  background: rgba(67, 97, 238, .18);
  color: #c8d4ff;
}
.usage-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 13px;
}
.usage-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3a86ff 0%, #4cc9f0 100%);
}
.folder-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
}

@media (max-width: 980px) {
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .admin-accounts-list {
    max-height: none;
  }
}

@media (max-width: 700px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }
  .account-card-head,
  .usage-meta {
    flex-direction: column;
  }
  .admin-card {
    width: 100vw;
  }
}


.profile-trigger {
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.profile-meta {
  display:flex;
  flex-direction:column;
  min-width:0;
  text-align:left;
}
.profile-meta strong, .profile-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-avatar, .account-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: #0f2248;
}
.profile-avatar-fallback, .account-avatar-fallback {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
  color:#fff;
}
.profile-card { width:min(560px, calc(100vw - 32px)); }
.profile-body { gap:16px; }
.profile-preview-wrap { display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
.profile-preview-frame {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  background:#0d1c3e;
}
.profile-preview-frame img { width:100%; height:100%; object-fit:cover; }
.profile-preview-fallback {
  width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:34px; font-weight:700;
}
.profile-checkbox { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:14px; }
.account-ident { display:flex; gap:12px; align-items:center; min-width:0; }
.account-ident h5 { margin:0 0 4px; }
.account-ident .muted { white-space: normal; word-break: break-word; }
.account-avatar { width:48px; height:48px; }

@media (max-width: 700px) { .profile-meta .small { max-width: 170px; } .profile-trigger { gap:10px; } .profile-avatar { width:36px; height:36px; } }


.password-settings-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255,255,255,.03);
}

.profile-form label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.profile-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.profile-checkbox input {
  width: auto;
}
