* { box-sizing: border-box; }

:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #6b7280;
  --line: #ededed;
  --soft: #f7f7f7;
  --black: #111111;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ========== Layout ========== */
.app-shell {
  min-height: 100vh;
  display: flex;
  background: #fff;
}

.sidebar {
  width: 284px;
  border-right: 1px solid var(--line);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}

.brand-box {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #111;
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  font-size: 16px;
  color: #555;
  border-radius: 12px;
  padding: 12px 14px;
}

.nav-item:hover { background: var(--soft); }
.nav-item.active {
  background: #111;
  color: #fff;
  font-weight: 600;
}

.status-box {
  margin-top: auto;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 14px;
  padding: 14px;
}

.status-box .small { margin: 0; }

.main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 66px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #fff;
}

.topbar-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.content {
  flex: 1;
  overflow: auto;
  padding: 26px 30px;
}

/* ========== Generic Blocks ========== */
.wrap {
  max-width: 1240px;
  margin: 0 auto;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 16px;
  margin-bottom: 14px;
}

h1, h2, h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 980px) {
  .sidebar { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .admin-two-col { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px; }
}

@media (min-width: 1400px) {
  .content .wrap {
    max-width: 1320px;
  }
}

input, button, select {
  border-radius: 10px;
  border: 1px solid #d8d8d8;
  background: #fff;
  color: #111;
  padding: 10px 12px;
  font-size: 13px;
}

input {
  min-width: 230px;
}

button {
  cursor: pointer;
  font-weight: 600;
}

button.primary {
  background: #111;
  color: #fff;
  border-color: #111;
}

button.warn {
  background: #2b2b2b;
  color: #fff;
  border-color: #2b2b2b;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: top;
  font-size: 13px;
}

.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  font-weight: 700;
}

.small {
  color: var(--muted);
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
}

.list-item:hover {
  background: #fafafa;
}

.html-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fafafa;
  max-height: 420px;
  overflow: auto;
}

.mini-kpi {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.mini-kpi .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #777;
  font-weight: 700;
}

.mini-kpi .value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
}

/* ========== Admin polish ========== */
.topbar-search {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
}

.topbar-search::placeholder {
  color: #b8b8b8;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.kpi-foot {
  margin-top: 8px;
  font-size: 10px;
  color: #666;
  font-weight: 600;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: #666;
  font-weight: 700;
}

.admin-two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid #ececec;
  color: #555;
  background: #fafafa;
}

.icon-square {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #e3e3e3;
  background: #fff;
  color: #333;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}

.icon-square:hover {
  background: #f7f7f7;
  border-color: #d2d2d2;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.modal-overlay.modal-show {
  display: flex;
}

.modal-box {
  width: min(420px, 92vw);
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

/* ========== User preview UI ========== */
.user-preview-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.main-container {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.user-topbar {
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}

.user-topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.user-alias {
  font-size: 12px;
  color: #666;
  letter-spacing: 0.1px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  animation: pulse-soft 2s infinite;
}

.refresh-time {
  font-size: 10px;
  color: #c0c0c0;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.divider-v {
  width: 1px;
  height: 16px;
  background: var(--line);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #777;
}

.icon-btn:hover {
  background: var(--soft);
  color: #111;
}

.refresh-icon.spin {
  display: inline-block;
  animation: rotate-sync 0.7s linear;
}

.user-main-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  overflow: hidden;
  background: #fff;
}

.user-main-container {
  display: flex;
  height: 100%;
  border-left: 1px solid #f7f7f7;
  border-right: 1px solid #f7f7f7;
}

.user-mail-list-panel {
  width: 350px;
  max-width: 100%;
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-topline {
  padding: 14px 16px;
  border-bottom: 1px solid #f4f4f4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.panel-count {
  font-size: 10px;
  color: #c0c0c0;
}

.mail-list-scroll,
.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.mail-item {
  padding: 18px 18px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

.mail-item:hover {
  background: #fafafa;
}

.mail-item.active {
  background: #fafafa;
}

.mail-item.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #111;
}

.mail-state {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 700;
}

.mail-state.new { color: #111; }
.mail-state.read { color: #c3c3c3; }
.mail-time {
  font-size: 10px;
  color: #aaa;
}
.mail-subject {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-from {
  margin-top: 4px;
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-detail-panel {
  flex: 1;
  min-width: 0;
  background: #fff;
  overflow: hidden;
}

.detail-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 52px 28px 90px;
}

.detail-head {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.detail-title {
  font-size: 32px;
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.3px;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-from {
  font-size: 13px;
  font-weight: 600;
}

.detail-date {
  font-size: 11px;
  color: #999;
}

.detail-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.detail-card + .detail-card {
  margin-top: 16px;
}

.code-chip {
  display: inline-block;
  margin-top: 16px;
  padding: 16px 22px;
  border-radius: 18px;
  border: 1px solid #efefef;
  background: #fafafa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 34px;
  letter-spacing: 0.22em;
  font-weight: 700;
}

.detail-footer-note {
  margin-top: 18px;
  font-size: 11px;
  color: #bbb;
}

@keyframes rotate-sync {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (max-width: 900px) {
  .user-topbar-inner {
    padding: 0 14px;
  }

  .user-main-container {
    flex-direction: column;
    border-left: none;
    border-right: none;
  }

  .user-mail-list-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 42vh;
  }

  .detail-shell {
    padding: 24px 14px 60px;
  }

  .detail-title {
    font-size: 24px;
  }

  .code-chip {
    font-size: 26px;
    letter-spacing: 0.15em;
  }
}
