/* ============================================================
 * 在线印章生成器 页面样式
 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --red: #d93025;
    --red-dark: #b3261e;
    --border: #e5e7eb;
    --bg: #f6f7f9;
    --text: #333;
    --muted: #888;
    --panel: #fff;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ---------- 顶部 ---------- */
.topbar {
    background: #fff;
    border-bottom: 2px solid var(--red);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.topbar h1 {
    font-size: 22px;
    color: var(--red);
    font-weight: 700;
    letter-spacing: 1px;
}
 .notice {
    color: var(--red);
    font-size: 13px;
    text-align: center;
    padding: 6px 16px;
    background: #fff5f5;
    border-top: 1px solid #fbe3e3;
}
.warn-icon { font-weight: 700; margin-right: 4px; }

.wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 20px 40px;
}

/* ---------- 类型模板栏 ---------- */
.tplbar {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.tpl-label {
    font-weight: 700;
    white-space: nowrap;
    line-height: 30px;
    color: var(--red);
}
.tpl-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tpl-item {
    border: 1px solid var(--border);
    background: #fafafa;
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.tpl-item:hover { border-color: var(--red); color: var(--red); }
.tpl-item.active {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* ---------- 主布局 ---------- */
.layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.panel {
    flex: 0 0 460px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.preview-col {
    flex: 1;
    min-width: 320px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

/* ---------- Tab 标签 ---------- */
.tabs {
    display: flex;
    flex-wrap: wrap;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
}
.tab {
    border: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    color: #666;
    border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--red); }
.tab.active {
    color: var(--red);
    font-weight: 700;
    border-bottom-color: var(--red);
    background: #fff;
}

/* ---------- 表单 ---------- */
.tab-pane { display: none; padding: 16px; }
.tab-pane.active { display: block; }
.row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.row label {
    min-width: 92px;
    text-align: right;
    color: #555;
    font-size: 13px;
}
.row label.wide { min-width: 92px; }
.row input[type="text"],
.row input[type="number"],
.row select {
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
}
.row input[type="text"] { flex: 1; min-width: 120px; }
.row input[type="number"] { width: 80px; }
.row select { min-width: 90px; }
.row input[type="text"]:focus,
.row input[type="number"]:focus,
.row select:focus { border-color: var(--red); }
.row input[type="color"] {
    width: 42px; height: 30px;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 2px;
    cursor: pointer;
    background: #fff;
}
.row input[type="range"] { flex: 1; min-width: 100px; accent-color: var(--red); }
.tip { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.aging-box { border-left: 3px solid var(--red); padding-left: 10px; margin: 6px 0; }

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
}
.checkbox input { accent-color: var(--red); }

.btn-mini {
    border: 1px solid var(--red);
    color: var(--red);
    background: #fff;
    border-radius: 5px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}
.btn-mini:hover { background: #fff1f0; }

.swatches { gap: 6px; padding-left: 100px; }
.swatch {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
    cursor: pointer;
}
.swatch:hover { transform: scale(1.15); }

.hidden { display: none !important; }

/* ---------- 预览 ---------- */
.preview-box { text-align: center; }
.preview-title { text-align: left; font-weight: 700; margin-bottom: 8px; color: #555; }
.preview-canvas-wrap {
    position: relative;
    display: inline-block;
    width: 240px;
    height: 240px;
    border: 1px dashed #ddd;
    border-radius: 8px;
    background: repeating-conic-gradient(#f2f2f2 0% 25%, #fff 0% 50%) 50% / 20px 20px;
}
.preview-canvas-wrap canvas {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
}
.wm {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    pointer-events: none;
    user-select: none;
    color: rgba(127,127,127,.45);
    font-size: 17px;
    letter-spacing: 2px;
}
.wm span {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.wm span:nth-child(1) { transform: rotate(45deg); }
.wm span:nth-child(2) { transform: rotate(45deg); }
.wm span:nth-child(3) { transform: rotate(45deg); }
.wm span:nth-child(4) { transform: rotate(45deg); }

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}
.btn {
    border: none;
    border-radius: 7px;
    padding: 11px 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    background: var(--red);
    color: #fff;
    transition: background .15s;
}
.btn:hover { background: var(--red-dark); }
.btn.ghost {
    background: #fff;
    color: var(--red);
    border: 1px solid var(--red);
}
.btn.ghost:hover { background: #fff1f0; }

.toast {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #8a6d1a;
    font-size: 13px;
}
.toast.error { background: #fdecea; border-color: #f5c6cb; color: #a33; }
.toast.ok { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }

/* ---------- 历史记录 ---------- */
.history {
    margin-top: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}
.history h2 { font-size: 17px; margin-bottom: 12px; color: var(--red); }
.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.hist-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    background: #fafafa;
}
.hist-item img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    background: repeating-conic-gradient(#f2f2f2 0% 25%, #fff 0% 50%) 50% / 12px 12px;
    border-radius: 4px;
}
.hist-title {
    font-size: 12px;
    color: #555;
    margin-top: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hist-time { font-size: 11px; color: var(--muted); }
.hist-actions { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.hist-actions button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
}
.hist-actions button:hover { border-color: var(--red); color: var(--red); }
.hist-actions button.del:hover { border-color: #c33; color: #c33; }

/* ---------- 页脚 ---------- */
.footer {
    margin-top: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
}
.footer h2 { font-size: 17px; margin-bottom: 10px; color: var(--red); }
.footer ol { padding-left: 20px; color: #555; font-size: 13px; }
.footer li { margin-bottom: 6px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .panel { flex: 1 1 auto; width: 100%; }
    .preview-col { width: 100%; }
}

/* ============ v3 移动端适配 ============ */
@media (max-width: 480px) {
    .modal { width: 92vw; max-width: 360px; }
    .user-area { right: 2px; }
    .topbar h1 { font-size: 18px; }
}

/* ============ v2 后台系统：用户区 / 公告 / 登录弹窗 ============ */
.topbar-inner { position: relative; }
.user-area { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; z-index: 5; }
.user-area .user-name { color: #d93025; font-weight: 700; }
.user-area .user-link { display: inline-block; color: #d93025; background: #fff; border: 1px solid #d93025; padding: 4px 14px; border-radius: 16px; text-decoration: none; cursor: pointer; line-height: 1.4; }
.user-area .user-link:hover { background: #d93025; color: #fff; }
.announce { background: #fff8e1; color: #8a6d1a; border-top: 1px solid #ffe082; padding: 8px 16px; font-size: 13px; text-align: center; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal { width: 360px; background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #eef0f2; }
.modal-head h3 { font-size: 15px; color: #444; }
.modal-close { border: none; background: none; font-size: 20px; color: #999; cursor: pointer; }
.modal-body { padding: 16px 18px 8px; }
.modal-foot { padding: 12px 18px 16px; display: flex; align-items: center; justify-content: space-between; }
.modal-foot .btn { min-width: 110px; }
.auth-switch { font-size: 13px; color: #d93025; cursor: pointer; }
.auth-err { background: #fdecea; border: 1px solid #f5c6cb; color: #a33; font-size: 12px; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; }
.modal .row { margin-bottom: 10px; }
.modal .row label { display: block; font-size: 13px; color: #555; margin-bottom: 4px; }
.modal .row input { width: 100%; padding: 9px 11px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px; outline: none; }
.modal .row input:focus { border-color: #d93025; }

/* ============ v4 授权码/次数配额 ============ */
.quota { margin: 10px 0 6px; padding: 8px 12px; background: #eef6ff; border: 1px solid #cfe4f7; border-radius: 6px; color: #1a5a9e; font-size: 13px; text-align: center; }
.quota.quota-warn { background: #fff3e0; border-color: #ffd8a8; color: #b25d0e; }
.auth-code-box { padding: 6px 16px 4px; border-top: 1px dashed #e5e5e5; margin-top: 4px; }
.auth-sep { text-align: center; color: #999; font-size: 12px; margin: 8px 0; position: relative; }
.auth-sep span { background: #fff; padding: 0 10px; }
.auth-code-box .row { margin-bottom: 8px; }
.auth-code-box .btn { width: 100%; }
.auth-tip { color: #999; font-size: 12px; margin: 8px 0 0; line-height: 1.5; }
.user-name.code-badge { color: #2e7d32; font-size: 12px; }

/* ---------------- 备案 ---------------- */
.beian-bar { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #eee; font-size: 12px; color: #999; }
.beian-bar a { color: #999; text-decoration: none; margin-right: 18px; }
.beian-bar a:hover { color: #d93025; text-decoration: underline; }
