/* ============================================================
   Omail 2.0
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #16a34a;
    --success-soft: #f0fdf4;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Header ---------------- */
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 22px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 26px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.main-nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 13px;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 500;
    font-size: 14px;
}
.nav-link:hover { background: #f3f4f6; color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-icon { font-size: 15px; }

.user-box { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.usage-mini { color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.plan-tag {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 20px;
    background: #f3f4f6;
    color: var(--muted);
    border: 1px solid var(--border);
}
.plan-tag.pro { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.user-email { color: var(--text); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-link { color: var(--muted); }
.logout-link:hover { color: var(--danger); text-decoration: none; }

/* ---------------- Layout ---------------- */
.container {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 22px 22px 40px;
    flex: 1;
}

.app-footer {
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
    padding: 18px;
}

.page-title { font-size: 21px; font-weight: 700; margin-bottom: 4px; }
.page-desc { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.section-title { font-size: 15px; font-weight: 650; }

/* ---------------- Stats ---------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 15px 18px;
}
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-value { font-size: 23px; font-weight: 700; letter-spacing: -.4px; }
.stat-value small { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat.warn .stat-value { color: var(--warning); }
.stat.good .stat-value { color: var(--success); }

/* ---------------- Forms ---------------- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; line-height: 1.55; }
select { cursor: pointer; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { margin-bottom: 0; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-outline { background: #fff; color: var(--text); border-color: #d1d5db; }
.btn-outline:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Alerts ---------------- */
.flash-stack { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.flash-success { background: var(--success-soft); border-color: #bbf7d0; color: #166534; }
.flash-error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.flash-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.flash-info { background: var(--primary-soft); border-color: #bfdbfe; color: #1e40af; }

.notice {
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 13px;
    background: var(--primary-soft);
    border: 1px solid #dbeafe;
    color: #1e40af;
}
.notice.warn { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }

/* ---------------- Table ---------------- */
.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: auto;
}
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 13.5px;
}
table.data th {
    background: #fafbfc;
    color: var(--muted);
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafcff; }
table.data .email-cell { font-weight: 600; word-break: break-all; }
.mono { font-family: Consolas, Monaco, "Courier New", monospace; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.email-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cred-line {
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
}
.action-btns { flex-wrap: nowrap; }
.action-btns .btn { flex: 0 0 auto; }
table.data td:last-child { white-space: nowrap; }
.project-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.project-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

/* ---------------- 分页 ---------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: #fff;
}
.page-btns { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 12.5px;
    background: #fff;
}
.page-btn:hover { background: #f3f4f6; text-decoration: none; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { color: #c0c4cc; background: #fafafa; cursor: not-allowed; }
.page-gap { color: var(--muted); padding: 0 2px; }
.per-form select { width: auto; padding: 5px 8px; font-size: 12.5px; }

/* ---------------- 多项目勾选 ---------------- */
.project-check-list { display: flex; flex-wrap: wrap; gap: 8px; }
.project-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.project-check:hover { background: #f9fafb; }
.project-check input { width: auto; cursor: pointer; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-ok { background: var(--success-soft); color: #15803d; }
.badge-error { background: var(--danger-soft); color: #b91c1c; }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-gray { background: #f3f4f6; color: var(--muted); }

/* ---------------- Toolbar ---------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }
.toolbar form { display: inline-flex; gap: 8px; align-items: center; }
.search-input { width: 230px; }

.import-area textarea {
    width: 100%;
    min-height: 100px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 12.5px;
}
.import-hint { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.import-hint span { color: var(--muted); font-size: 12.5px; }

/* ---------------- Modal ---------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .48);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 18px;
}
.modal-overlay.active { display: flex; }
.modal-window {
    background: #fff;
    width: 100%;
    max-width: 1100px;
    height: 84vh;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-window.small { max-width: 480px; height: auto; max-height: 88vh; }
.modal-header {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: #fafbfc;
    flex-shrink: 0;
}
.modal-title { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 6px;
}
.modal-close:hover { background: #eef0f4; color: var(--text); }
.modal-body { display: flex; flex: 1; overflow: hidden; }
.modal-body.padded { padding: 18px; display: block; overflow-y: auto; }

/* ---------------- Mail viewer ---------------- */
.mail-list-pane {
    width: 340px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: #fafbfc;
    flex-shrink: 0;
}
.mail-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.mail-item:hover { background: #f3f4f6; }
.mail-item.active { background: var(--primary-soft); border-left: 3px solid var(--primary); }
.mail-item.unread .mail-subject { font-weight: 700; color: var(--primary); }
.mail-sender {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}
.mail-sender .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-date { font-size: 11px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.mail-subject { font-size: 13px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-preview {
    font-size: 12px;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mail-detail-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #fff; min-width: 0; }
.mail-detail-header { padding: 15px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.detail-subject { font-size: 17px; font-weight: 650; margin-bottom: 7px; word-break: break-word; }
.detail-meta { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mail-detail-content { flex: 1; overflow-y: auto; padding: 20px; }

.empty-state {
    height: 100%;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13.5px;
    text-align: center;
    padding: 22px;
}
.empty-state.error { color: var(--danger); flex-direction: column; gap: 8px; }

/* ---------------- Auth ---------------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 15% 15%, #dbeafe 0, transparent 42%),
                radial-gradient(circle at 85% 85%, #e0e7ff 0, transparent 45%),
                #f4f6fb;
    padding: 22px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .10);
    padding: 30px 30px 26px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-title { font-size: 20px; font-weight: 700; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-card .btn { width: 100%; padding: 10px; font-size: 14.5px; }

/* ---------------- Projects / Shares ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.list-item:last-child { border-bottom: none; }
.list-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list-title { font-weight: 600; }
.list-sub { color: var(--muted); font-size: 12px; }
.color-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

.share-url {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}
.share-url input { font-family: Consolas, Monaco, monospace; font-size: 12px; flex: 1 1 auto; min-width: 0; }

details.inline-form { margin-top: 8px; }
details.inline-form summary { cursor: pointer; color: var(--primary); font-size: 13px; }

/* ---------------- Admin ---------------- */
.log-table td { font-size: 12.5px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 980px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr 1fr; }
    .header-inner { gap: 12px; }
    .user-email { display: none; }
    .nav-link span:last-child { display: none; }
    .nav-link { padding: 8px 10px; }
}

@media (max-width: 640px) {
    .container { padding: 14px 12px 30px; }
    .header-inner { padding: 0 12px; height: 56px; }
    .brand-text { display: none; }
    .stats { grid-template-columns: 1fr 1fr; gap: 9px; }
    .stat { padding: 12px; }
    .stat-value { font-size: 19px; }
    .usage-mini { display: none; }
    .modal-window { height: 92vh; }
    .modal-body { flex-direction: column; }
    .mail-list-pane { width: 100%; height: 38%; border-right: none; border-bottom: 1px solid var(--border); }
    .mail-detail-pane { height: 62%; }
    .settings-grid { grid-template-columns: 1fr; }
    .search-input { width: 100%; }
    .toolbar form { width: 100%; }
}
