* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; background:#f0f2f5; min-height:100vh; color:#333; }

/* ===== White Card: Title + Search Bar + Buttons ===== */
.app-card { max-width:1360px; margin:12px auto 20px; padding:22px 20px 18px; background:#fff; border-radius:12px; box-shadow:0 1px 4px rgba(0,0,0,0.08); }
.app-title { text-align:center; font-size:26px; font-weight:700; color:#007AFF; margin-bottom:16px; letter-spacing:-0.4px; }

/* ===== Toolbar (inside card) ===== */
.app-toolbar { display:flex; gap:10px; align-items:center; }
.app-toolbar input[type="text"] { flex:1; min-width:240px; height:44px; padding:0 18px; border:1.5px solid #d1d5db; border-radius:8px; font-size:15px; outline:none; transition:.2s; background:#fff; }
.app-toolbar input:focus { border-color:#007AFF; box-shadow:0 0 0 3px rgba(0,122,255,0.08); }

.btn { height:44px; padding:0 22px; border:none; border-radius:8px; font-size:15px; font-weight:600; cursor:pointer; transition:.15s; white-space:nowrap; letter-spacing:0.2px; display:inline-flex; align-items:center; justify-content:center; }
.btn-search { background:#007AFF; color:#fff; }
.btn-search:hover { background:#0066dd; }
.btn-import { background:#17a2b8; color:#fff; }
.btn-import:hover { background:#138496; }
.btn-buy { background:#007AFF; color:#fff; text-decoration:none; }
.btn-buy:hover { background:#0066dd; }
.btn-clear { background:#dc3545; color:#fff; }
.btn-clear:hover { background:#c82333; }
.btn:disabled { opacity:0.5; cursor:not-allowed; }

/* ===== Main Layout - Default 2 columns, 3 when accounts exist ===== */
.main-container { max-width:1400px; margin:0 auto 24px; padding:0 20px; display:grid; grid-template-columns:340px 1fr; gap:18px; height:calc(100vh - 170px); min-height:550px; transition:grid-template-columns .3s; }
.main-container.has-accounts { grid-template-columns:200px 360px 1fr; }

/* ===== Panel Account (Left) ===== */
.panel-account { background:#fff; border:2px solid #007AFF; border-radius:10px; overflow:hidden; display:flex; flex-direction:column; }
.account-list { flex:1; overflow-y:auto; }
.account-item { padding:12px 16px; cursor:pointer; border-bottom:1px solid #f0f0f0; font-size:14px; color:#333; transition:.15s; word-break:break-all; line-height:1.45; }
.account-item:hover { background:#f5f9ff; }
.account-item.active { background:#e8f2ff; font-weight:600; color:#007AFF; border-left:3px solid #007AFF; }
.account-item .acc-email { font-size:13px; color:#555; margin-top:2px; }
.account-item .acc-remove { float:right; color:#dc2626; font-size:13px; cursor:pointer; opacity:0; transition:.15s; line-height:1.45; }
.account-item:hover .acc-remove { opacity:1; }

/* ===== Panel Mails (Middle) ===== */
.panel-mails { background:#fff; border:1px solid #ddd; border-radius:10px; overflow:hidden; display:flex; flex-direction:column; }
.mails-header { padding:12px 16px; border-bottom:1px solid #eee; display:flex; justify-content:space-between; align-items:center; font-size:14px; color:#888; flex-shrink:0; }
.mails-header:empty { display:none; }
.mails-header #currentAccountLabel { font-weight:600; color:#333; font-size:15px; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:220px; }
.mail-list { flex:1; overflow-y:auto; }
.mail-item { padding:14px 16px; border-bottom:1px solid #f5f5f5; cursor:pointer; transition:.12s; }
.mail-item:hover { background:#f8faff; }
.mail-item.active { background:#e8f2ff; border-left:3px solid #007AFF; }
.mail-item .subject { font-size:15px; font-weight:500; color:#222; margin-bottom:4px; word-break:break-word; line-height:1.4; display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden; }
.mail-item .meta { font-size:13px; color:#aaa; }

/* ===== Panel Preview (Right) ===== */
.panel-preview { background:#fff; border:1px solid #ddd; border-radius:10px; overflow:hidden; display:flex; flex-direction:column; }
.preview-body { flex:1; overflow-y:auto; position:relative; padding:12px; }
.preview-body iframe { width:100%; height:100%; border:none; border-radius:6px; }
.preview-body .email-body-text { padding:24px; font-size:15px; line-height:1.85; color:#333; white-space:pre-wrap; word-wrap:break-word; }

.empty-hint { display:flex; align-items:center; justify-content:center; height:100%; color:#bbb; font-size:15px; text-align:center; padding:24px; }
.error-msg { padding:24px 16px; color:#dc2626; font-size:15px; text-align:left; line-height:1.6; }

/* ===== Pagination ===== */
.pagination { display:flex; gap:5px; justify-content:center; padding:12px; border-top:1px solid #f0f0f0; flex-shrink:0; }
.pagination a,.pagination span { display:inline-block; padding:7px 14px; border-radius:6px; font-size:14px; text-decoration:none; color:#555; border:1px solid #e0e0e0; }
.pagination a:hover { background:#f0f0f0; }
.pagination .current { background:#007AFF; color:#fff; border-color:#007AFF; }

/* ===== Admin Styles (keep existing) ===== */
.admin-wrap { max-width:1200px; margin:0 auto; padding:20px; }
.admin-nav { background:#fff; border-bottom:1px solid #e5e7eb; padding:0 20px; display:flex; gap:4px; justify-content:center; flex-wrap:wrap; }
.admin-nav a { display:block; padding:14px 20px; font-size:14px; color:#555; text-decoration:none; border-bottom:2px solid transparent; transition:.15s; }
.admin-nav a:hover { color:#007AFF; background:#f8faff; }
.admin-nav a.active { color:#007AFF; border-bottom-color:#007AFF; font-weight:500; }
.admin-card { background:#fff; border:1px solid #e5e7eb; border-radius:12px; padding:20px; margin-bottom:16px; }
.admin-card h3 { font-size:16px; font-weight:600; margin-bottom:16px; }
.stats-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:12px; margin-bottom:20px; }
.stat-card { background:#fff; border:1px solid #e5e7eb; border-radius:10px; padding:16px; text-align:center; }
.stat-card .num { font-size:28px; font-weight:700; color:#007AFF; }
.stat-card .label { font-size:13px; color:#888; margin-top:4px; }

table.data { width:100%; border-collapse:collapse; font-size:13px; }
table.data th { text-align:left; padding:10px 12px; border-bottom:2px solid #e5e7eb; font-weight:600; color:#555; white-space:nowrap; }
table.data td { padding:10px 12px; border-bottom:1px solid #f0f0f0; }
table.data tr:hover { background:#f8faff; }

.form-group { margin-bottom:12px; }
.form-group label { display:block; font-size:13px; font-weight:500; color:#555; margin-bottom:4px; }
.form-group input,.form-group select,.form-group textarea { width:100%; height:36px; padding:0 12px; border:1px solid #d1d5db; border-radius:8px; font-size:13px; outline:none; }
.form-group textarea { height:auto; padding:8px 12px; }
.form-group input:focus { border-color:#007AFF; box-shadow:0 0 0 3px rgba(0,122,255,0.08); }
.form-inline { display:flex; gap:8px; align-items:flex-end; flex-wrap:wrap; }

.modal-overlay { display:none; position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.4); z-index:100; align-items:center; justify-content:center; }
.modal-overlay.show { display:flex; }
.modal-box { background:#fff; border-radius:12px; padding:24px; max-width:520px; width:90%; max-height:80vh; overflow-y:auto; }
.modal-box h3 { font-size:16px; font-weight:600; margin-bottom:16px; }

.tag { display:inline-block; font-size:11px; padding:2px 8px; border-radius:4px; font-weight:500; }
.tag-blue { background:#e8f2ff; color:#007AFF; }
.tag-green { background:#e6f7e6; color:#16a34a; }
.tag-red { background:#fee; color:#dc2626; }
.tag-gray { background:#f0f0f0; color:#888; }

.toast { position:fixed; bottom:24px; right:24px; padding:12px 20px; border-radius:8px; color:#fff; font-size:13px; z-index:200; display:none; }
.toast-success { background:#16a34a; }
.toast-error { background:#dc2626; }

@media (max-width:900px) {
    .main-container { grid-template-columns:150px 1fr; height:auto; }
    .panel-preview { display:none; }
    .app-toolbar { flex-wrap:wrap; }
}
@media (max-width:600px) {
    .main-container { grid-template-columns:1fr; }
    .panel-account { display:none; }
}
