* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f5f5f5;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: #1a73e8;
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
}

.header .spacer { flex: 1; }

.header select {
  max-width: 250px;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.header button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.header button:hover {
  background: rgba(255,255,255,0.35);
}

/* Layout */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: none;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar.visible {
  display: flex;
}

.sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  color: #999;
  padding: 14px 16px 8px;
  letter-spacing: 0.5px;
}

.sidebar .folder-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.sidebar .folder-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.sidebar .folder-item:hover {
  background: #f0f0f0;
}

.sidebar .folder-item.active {
  background: #e8f0fe;
  border-left-color: #1a73e8;
  font-weight: 600;
  color: #1a73e8;
}

/* Content */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* Toolbar */
.toolbar {
  padding: 10px 20px;
  display: none;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  background: #fafafa;
}

.toolbar.visible {
  display: flex;
}

.toolbar .pagination {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar .pagination button {
  background: #fff;
  border: 1px solid #ddd;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s;
}

.toolbar .pagination button:hover:not(:disabled) {
  background: #f0f0f0;
}

.toolbar .pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

.toolbar .pagination span {
  font-size: 12px;
  color: #666;
}

/* Email list */
.email-list-wrap {
  flex: 1;
  overflow-y: auto;
}

.email-list {
  list-style: none;
}

.email-item {
  padding: 12px 20px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.1s;
}

.email-item:hover {
  background: #f8f9fa;
}

.email-item.unread {
  background: #e8f0fe;
}

.email-item.unread:hover {
  background: #d2e3fc;
}

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

.email-item .email-from {
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-item.unread .email-from {
  font-weight: 700;
}

.email-item .email-date {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
}

.email-item .email-subject {
  color: #444;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-item.unread .email-subject {
  color: #1a1a1a;
  font-weight: 600;
}

/* Email view */
.email-view {
  display: none;
  flex-direction: column;
  height: 100%;
}

.email-view.visible {
  display: flex;
}

.email-view .ev-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.email-view .ev-back {
  background: none;
  border: none;
  color: #1a73e8;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
  margin-bottom: 8px;
}

.email-view .ev-back:hover {
  text-decoration: underline;
}

.email-view .ev-subject {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

.email-view .ev-meta {
  font-size: 13px;
  color: #666;
}

.email-view .ev-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  line-height: 1.6;
}

.email-view .ev-body iframe {
  width: 100%;
  border: none;
  min-height: 400px;
}

.email-view .ev-attachments {
  font-size: 13px;
  color: #555;
  border-top: 1px solid #e0e0e0;
  padding: 12px 20px;
  flex-shrink: 0;
}

/* Status */
.status {
  padding: 60px 20px;
  text-align: center;
  color: #888;
  font-size: 15px;
}

.status.error {
  color: #d93025;
}

/* Add account form */
.add-form-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.add-form-overlay.visible {
  display: flex;
}

.add-form {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.add-form h2 {
  font-size: 18px;
  margin-bottom: 20px;
}

.add-form .field {
  margin-bottom: 14px;
}

.add-form label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
  font-weight: 500;
}

.add-form input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.add-form input:focus {
  outline: none;
  border-color: #1a73e8;
}

.add-form .form-row {
  display: flex;
  gap: 12px;
}

.add-form .form-row .field {
  flex: 1;
}

.add-form .form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.add-form button {
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid #ddd;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

.add-form button.primary {
  background: #1a73e8;
  color: #fff;
  border-color: #1a73e8;
}

.add-form button.primary:hover {
  background: #1557b0;
}

.add-form button:not(.primary):hover {
  background: #f0f0f0;
}

.delete-btn {
  background: none;
  border: none;
  color: #d93025;
  cursor: pointer;
  font-size: 13px;
}

.delete-btn:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .sidebar { width: 160px; }
  .header h1 { font-size: 15px; }
  .email-view .ev-subject { font-size: 16px; }
}
