/* Dylib激活码 Admin — clean SaaS dashboard */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --side: #ffffff;
    --text: #111827;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --line: #e5e7eb;
    --line-2: #f3f4f6;
    --brand: #2563eb;
    --brand-2: #1d4ed8;
    --brand-soft: #eff6ff;
    --green: #059669;
    --green-soft: #ecfdf5;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --amber: #d97706;
    --amber-soft: #fffbeb;
    --r: 12px;
    --r-lg: 16px;
    --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
    --shadow: 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 24px rgba(0,0,0,.06);
}

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

html { -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }

/* ── Layout ── */
.shell { display: flex; min-height: 100vh; }

.side {
    width: 220px;
    background: var(--side);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 24px;
    color: var(--text);
}

.side-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
}

.side-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    transition: background .12s, color .12s;
}

.side-link:hover { background: var(--line-2); color: var(--text); }
.side-link.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.ico { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ico svg { width: 18px; height: 18px; }

.side-foot { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }

.side-user { display: flex; gap: 10px; align-items: center; padding: 6px 8px; margin-bottom: 6px; }

.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand);
    font-size: 13px; font-weight: 700;
    display: grid; place-items: center;
}

.uname { font-size: 13px; font-weight: 600; color: var(--text); }
.urole { font-size: 11px; color: var(--text-3); }

.side-out {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; font-size: 13px; color: var(--text-2);
    border-radius: 8px;
}
.side-out:hover { background: var(--line-2); color: var(--red); }
.side-out svg { width: 16px; height: 16px; }

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

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 28px 32px 0;
    background: var(--bg);
}

.page-head h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-top: 2px;
}

.page-head p { font-size: 14px; color: var(--text-2); margin-top: 4px; }

.crumbs {
    font-size: 13px;
    color: var(--text-3);
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 4px;
}

.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--brand); }

.page-head-act { flex-shrink: 0; }

.page-content { padding: 20px 32px 40px; flex: 1; }

.mob-menu {
    display: none;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 8px;
}

/* ── Metrics ── */
.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.metric-val {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.1;
    color: var(--text);
}

.metric-label { font-size: 13px; color: var(--text-2); margin-top: 6px; }

.metric.blue .metric-val { color: var(--brand); }
.metric.green .metric-val { color: var(--green); }
.metric.amber .metric-val { color: var(--amber); }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-top {
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-top h3 { font-size: 15px; font-weight: 600; color: var(--text); }

.card-body { padding: 24px; }
.card-foot {
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    background: var(--line-2);
    font-size: 13px;
    color: var(--text-2);
}

.card-hint { font-size: 13px; color: var(--text-2); margin: -8px 0 16px; }

/* ── App cards ── */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.app-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius, 12px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: border-color .15s, box-shadow .15s;
}

.app-card:hover {
    border-color: var(--brand);
    box-shadow: 0 4px 20px rgba(0, 0, 0, .06);
}

.app-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.app-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--brand-soft);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--brand);
}

.app-card-title {
    flex: 1;
    min-width: 0;
}

.app-card-title h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text);
}

.app-card-title p {
    font-size: 13px;
    color: var(--text-2);
    margin: 0;
    line-height: 1.4;
}

.app-card-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    background: var(--line-2);
    border-radius: 8px;
}

.app-card-stat {
    text-align: center;
}

.app-card-stat b {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.app-card-stat span {
    font-size: 12px;
    color: var(--text-2);
}

.app-card-keys .keyrow {
    margin-bottom: 6px;
}

.app-card-keys .keyrow:last-child {
    margin-bottom: 0;
}

.app-card-foot {
    margin-top: auto;
    flex-wrap: wrap;
}

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

/* ── Grid ── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Forms ── */
.field { margin-bottom: 16px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

textarea { resize: vertical; min-height: 88px; }

/* ── Toggle ── */
.switch-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--line-2);
    border-radius: 8px;
    margin-bottom: 16px;
}

.switch { position: relative; width: 40px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-ui {
    position: absolute; inset: 0;
    background: #d1d5db; border-radius: 99px; cursor: pointer; transition: .2s;
}
.switch-ui::after {
    content: ""; position: absolute;
    width: 18px; height: 18px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }

.switch-text { font-size: 14px; font-weight: 500; color: var(--text); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
    line-height: 1.4;
}

.btn:hover { background: var(--brand-2); }
.btn:active { transform: scale(0.98); }

.btn.ghost {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--line-2); border-color: #d1d5db; }

.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }

.btn.sm { padding: 6px 12px; font-size: 13px; }

.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ── Tabs ── */
.tabbar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .12s;
}

.tab:hover { color: var(--text); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ── Table ── */
.tbl-wrap { overflow: auto; }

table { width: 100%; border-collapse: collapse; min-width: 640px; }

th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    background: var(--line-2);
    border-bottom: 1px solid var(--line);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }

.mono {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    color: #374151;
    word-break: break-all;
}

/* ── Tags ── */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.tag-blue { background: var(--brand-soft); color: var(--brand); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-gray { background: var(--line-2); color: var(--text-2); }
.tag-red { background: var(--red-soft); color: var(--red); }

/* ── Flash messages ── */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.flash-ok { background: var(--green-soft); color: #065f46; border: 1px solid #a7f3d0; }
.flash-err { background: var(--red-soft); color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: var(--brand-soft); color: #1e40af; border: 1px solid #bfdbfe; }
.flash-warn { background: var(--amber-soft); color: #92400e; border: 1px solid #fde68a; }

/* ── Key copy row ── */
.keyrow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--line-2);
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
}

.keyrow .lbl { color: var(--text-2); font-weight: 500; min-width: 72px; flex-shrink: 0; }
.keyrow .mono { flex: 1; }

.copy {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-2);
    flex-shrink: 0;
}
.copy:hover { border-color: var(--brand); color: var(--brand); }

.copy.sm {
    padding: 2px 8px;
    font-size: 11px;
    margin-left: 8px;
    vertical-align: middle;
}

td .mono { word-break: break-all; }

/* ── Avatar upload ── */
.avatar-upload {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 16px;
    background: var(--line-2);
    border-radius: var(--r);
    border: 1px solid var(--line);
}

.avatar-preview-wrap {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    position: relative;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    object-fit: cover;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow);
}

.avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    background: var(--surface);
    border: 2px dashed var(--line);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
}

.avatar-upload-body { flex: 1; min-width: 0; }

.avatar-pick {
    cursor: pointer;
    margin-bottom: 6px;
}

.avatar-pick input { display: none; }

.avatar-hint {
    font-size: 12px;
    color: var(--text-3);
    margin-bottom: 0;
}

.avatar-url-field { margin-top: 12px; margin-bottom: 0; }
.avatar-url-field label { font-size: 12px; font-weight: 500; color: var(--text-2); }

/* ── Button config table ── */
.cfg-table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px; }

.cfg-head, .cfg-row {
    display: grid;
    grid-template-columns: 1.2fr .9fr 1.5fr 52px 52px 36px;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
}

.cfg-head {
    background: var(--line-2);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.cfg-row { border-top: 1px solid var(--line); }
.cfg-row input, .cfg-row select { margin: 0; padding: 8px 10px; font-size: 13px; }
.cfg-row input[type=checkbox] { width: 16px; height: 16px; margin: 0 auto; display: block; accent-color: var(--brand); }

.rm {
    width: 28px; height: 28px;
    border: none; background: transparent;
    color: var(--text-3); font-size: 18px; cursor: pointer;
    border-radius: 6px;
}
.rm:hover { background: var(--red-soft); color: var(--red); }

/* ── Code ── */
.code {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 16px 18px;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 13px;
    line-height: 1.65;
    overflow: auto;
    white-space: pre-wrap;
}

/* ── Steps ── */
.steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.step {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px;
    font-size: 13px;
    color: var(--text-2);
}

.step b {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--brand);
    margin-bottom: 4px;
    letter-spacing: .02em;
}

.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-2);
    font-size: 14px;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text);
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 200;
    box-shadow: var(--shadow-md);
}

.toast.show { opacity: 1; transform: translateY(-4px); }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }

.login-left {
    background: #0f172a;
    color: #fff;
    padding: 64px 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-left h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.15;
    margin-bottom: 16px;
}

.login-left p { font-size: 16px; color: #94a3b8; line-height: 1.7; max-width: 400px; }

.login-list { margin-top: 40px; display: flex; flex-direction: column; gap: 14px; }

.login-list div {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #cbd5e1;
}

.login-list span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #3b82f6;
    flex-shrink: 0;
}

.login-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: var(--bg);
}

.login-box {
    width: 100%;
    max-width: 380px;
}

.login-box h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 6px; }
.login-box .sub { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .metrics, .steps { grid-template-columns: 1fr 1fr; }
    .g4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .side {
        position: fixed; z-index: 100;
        transform: translateX(-100%);
        transition: transform .2s;
        box-shadow: var(--shadow-md);
    }
    .side.open { transform: translateX(0); }
    .mob-menu { display: block; }
    .page-head, .page-content { padding-left: 20px; padding-right: 20px; }
    .metrics, .steps, .g2, .g3, .g4, .app-grid { grid-template-columns: 1fr; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-left { display: none; }
    .cfg-head, .cfg-row { grid-template-columns: 1fr; }
}

.announcement-editor {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
}

.announcement-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--line-2);
}

.ann-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
}

.ann-tool input[type="color"] {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.announcement-editable {
    min-height: 96px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.55;
    outline: none;
    white-space: pre-wrap;
    word-break: break-all;
}

.announcement-preview-wrap {
    padding: 10px 12px 12px;
    border-top: 1px dashed var(--line);
    background: #f6f7f9;
}

.announcement-preview-label {
    display: block;
    font-size: 12px;
    color: var(--text-3);
    margin-bottom: 8px;
}

.announcement-preview {
    width: 304px;
    max-width: 100%;
    margin: 0 auto;
    padding: 8px 6px;
    font-size: 14px;
    line-height: 1.55;
    text-align: center;
    color: var(--text-2);
    word-break: break-all;
    white-space: pre-wrap;
}
