/* ============================================================
   DeviceManager — 设计系统（深色主题）
   ============================================================ */
:root {
    --bg: #0d1117;
    --bg-panel: #151b23;
    --bg-elevated: #1c232e;
    --bg-hover: #1f2733;
    --border: #2b3542;
    --border-strong: #3d4857;
    --text: #c9d1d9;
    --text-dim: #8b949e;
    --text-bright: #f0f6fc;
    --accent: #2f81f7;
    --accent-hover: #3f8ef8;
    --accent-soft: rgba(47, 129, 247, 0.13);
    --green: #3fb950;
    --green-soft: rgba(63, 185, 80, 0.13);
    --amber: #d29922;
    --amber-soft: rgba(210, 153, 34, 0.14);
    --red: #f85149;
    --red-soft: rgba(248, 81, 73, 0.13);
    --purple: #bc8cff;
    --purple-soft: rgba(188, 140, 255, 0.15);
    --cyan: #39c5cf;
    --cyan-soft: rgba(57, 197, 207, 0.13);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    --transition: 0.16s ease;
}

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

html { scrollbar-color: #3d4857 transparent; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(47, 129, 247, 0.35); }

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

input, select, textarea, button { font-family: inherit; font-size: 14px; }
input::placeholder, textarea::placeholder { color: #6e7781; }

/* ============================================================
   通用组件
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    background: none;
    color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-elevated); border-color: var(--border); color: var(--text-bright); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: rgba(248, 81, 73, 0.35); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 81, 73, 0.2); }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { color: var(--text-bright); background: var(--bg-hover); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2.5px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}
.badge-blue   { background: var(--accent-soft); color: #79b8ff; }
.badge-green  { background: var(--green-soft);  color: #56d364; }
.badge-amber  { background: var(--amber-soft);  color: #e3b341; }
.badge-red    { background: var(--red-soft);    color: #ff7b72; }
.badge-purple { background: var(--purple-soft); color: #d2a8ff; }
.badge-cyan   { background: var(--cyan-soft);   color: #56d4dd; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    margin: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text);
}
.chip-muted { color: var(--text-dim); font-style: italic; border-style: dashed; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-bright);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.field textarea { resize: vertical; min-height: 90px; font-family: var(--font-mono); font-size: 12.5px; }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.18);
}
.field .hint { font-size: 12px; color: var(--text-dim); margin-top: 5px; }

.input-icon { position: relative; }
.input-icon > span {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 14px;
    pointer-events: none;
}
.input-icon > input { padding-left: 36px; }

.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; }
.select-wrap::after {
    content: "";
    position: absolute;
    right: 13px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--text-dim);
    border-bottom: 1.5px solid var(--text-dim);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

/* 表格 */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-elevated);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid rgba(43, 53, 66, 0.55);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg-hover); }

.mono { font-family: var(--font-mono); font-size: 12.8px; }
.text-dim { color: var(--text-dim); }
.text-bright { color: var(--text-bright); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }

/* 统计卡 */
.stats-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
    flex: 1;
    min-width: 170px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    opacity: 0.9;
}
.stat-card .stat-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.2;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    opacity: 0.25;
}

/* 空状态 */
.empty-state { text-align: center; padding: 64px 20px; }
.empty-state .empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-state .empty-title { font-size: 16px; color: var(--text-bright); margin-bottom: 6px; }
.empty-state .empty-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 18px; }

/* 分页 */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 20px; }
.pagination button {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
}
.pagination button:hover:not(:disabled):not(.active) { background: var(--bg-hover); border-color: var(--border-strong); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* 代码块 */
.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: #7ee787;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

/* Toast */
.toast-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    max-width: 420px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 13.5px;
    animation: toastIn 0.25s ease;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1, 4, 9, 0.68);
    backdrop-filter: blur(3px);
    z-index: 900;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 48px 20px;
    animation: fadeIn 0.18s ease;
}
.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 540px;
    max-width: 100%;
    animation: modalIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.modal-sm { width: 420px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15.5px; color: var(--text-bright); font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    transition: all var(--transition);
}
.modal-close:hover { color: var(--text-bright); background: var(--bg-hover); }
.modal-body { padding: 22px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 复选框组 */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-item { position: relative; }
.checkbox-item input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox-item label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.checkbox-item label:hover { border-color: var(--border-strong); }
.checkbox-item input:checked + label {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: #79b8ff;
}
.checkbox-item input:disabled + label { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   认证页
   ============================================================ */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(1000px 500px at 15% -10%, rgba(47, 129, 247, 0.09), transparent 60%),
        radial-gradient(800px 400px at 100% 110%, rgba(63, 185, 80, 0.07), transparent 60%),
        var(--bg);
}
.auth-card {
    display: flex;
    width: 920px;
    max-width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.auth-form { flex: 1.15; padding: 48px 44px; }
.auth-intro {
    flex: 1;
    padding: 48px 40px;
    background: linear-gradient(165deg, rgba(47, 129, 247, 0.08), rgba(188, 140, 255, 0.05)), var(--bg-elevated);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #1c5fb8);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(47, 129, 247, 0.35);
    flex-shrink: 0;
}
.brand-name { font-size: 19px; font-weight: 700; color: var(--text-bright); letter-spacing: 0.3px; }
.brand-sub { font-size: 11px; color: var(--text-dim); letter-spacing: 1.5px; text-transform: uppercase; }
.auth-title { font-size: 22px; font-weight: 700; color: var(--text-bright); margin-bottom: 6px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-dim); margin-bottom: 28px; }
.auth-intro h2 { font-size: 20px; color: var(--text-bright); margin-bottom: 10px; }
.auth-intro > p { font-size: 13.5px; color: var(--text-dim); margin-bottom: 30px; line-height: 1.65; }
.feature-list { display: flex; flex-direction: column; gap: 22px; }
.feature-item { display: flex; gap: 14px; align-items: flex-start; }
.feature-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.feature-item h3 { font-size: 14px; color: var(--text-bright); margin-bottom: 3px; }
.feature-item p { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }
.auth-footer { text-align: center; margin-top: 26px; font-size: 13px; color: var(--text-dim); }
.auth-footer a { color: var(--accent); }

@media (max-width: 820px) {
    .auth-intro { display: none; }
    .auth-form { padding: 36px 26px; }
}

/* ============================================================
   应用外壳（侧边栏 + 顶栏 + 内容）
   ============================================================ */
.app-body { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.sidebar-brand .brand-name { font-size: 15.5px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-section {
    font-size: 10.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 14px 12px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13.5px;
    transition: all var(--transition);
    border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-bright); }
.nav-item.active {
    background: var(--accent-soft);
    color: #79b8ff;
    border-left-color: var(--accent);
}
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item.active .nav-icon { filter: none; }

.sidebar-footer { padding: 14px 12px; border-top: 1px solid var(--border); }
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
}
.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.user-chip .user-email { font-size: 12px; color: var(--text); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .user-role { font-size: 10.5px; color: var(--text-dim); }

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

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 58px;
    padding: 0 28px;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h1 { font-size: 16.5px; font-weight: 650; color: var(--text-bright); }
.topbar .topbar-sub { font-size: 12.5px; color: var(--text-dim); }
.topbar-spacer { flex: 1; }

.content { flex: 1; padding: 26px 28px 48px; max-width: 1440px; width: 100%; }

.page-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 20px; }

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.toolbar input, .toolbar select {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-bright);
    padding: 8px 12px;
    outline: none;
    transition: border-color var(--transition);
    font-size: 13px;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }
.toolbar input { width: 200px; }
.toolbar select { padding-right: 30px; appearance: none; cursor: pointer; }

/* 详情页 */
.detail-header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.detail-header h2 { font-size: 20px; font-family: var(--font-mono); color: var(--text-bright); font-weight: 650; }
.back-link { font-size: 13px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 5px; margin-bottom: 14px; }
.back-link:hover { color: var(--text-bright); }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.info-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 18px; }
.info-card .info-label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.info-card .info-value { font-size: 14.5px; color: var(--text-bright); word-break: break-all; }
.info-card .info-value.mono { font-size: 13px; }

.section-title {
    font-size: 13px;
    font-weight: 650;
    color: var(--text-bright);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin: 26px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border);
}
.timeline-item { position: relative; padding: 0 0 20px 18px; }
.timeline-item::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 2px solid var(--accent);
}
.timeline-item .tl-time { font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); }
.timeline-item .tl-title { font-size: 13.5px; color: var(--text-bright); margin: 2px 0 4px; }
.timeline-item .tl-detail { font-size: 12.5px; color: var(--text-dim); }
.timeline-item .tl-detail .code-block { margin-top: 8px; }

/* 类型卡片 */
.types-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.type-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; transition: border-color var(--transition), transform var(--transition); }
.type-card:hover { border-color: var(--border-strong); }
.type-card .type-name { font-size: 16px; font-weight: 650; color: var(--text-bright); display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.type-card .type-desc { font-size: 13px; color: var(--text-dim); min-height: 20px; margin-bottom: 14px; }
.type-meta { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; padding-top: 12px; border-top: 1px solid rgba(43, 53, 66, 0.6); }
.type-meta .meta-row { display: flex; align-items: center; gap: 8px; }
.type-meta .meta-label { color: var(--text-dim); width: 64px; flex-shrink: 0; }

/* 弹窗中的只读预览 */
.field-preview {
    background: var(--bg);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
}
.field-preview .preview-row { display: flex; gap: 8px; padding: 3px 0; }
.field-preview .preview-label { color: var(--text-dim); flex-shrink: 0; }

/* 变更 diff */
.diff-box { display: flex; flex-direction: column; gap: 4px; }
.diff-line { font-family: var(--font-mono); font-size: 12px; padding: 4px 10px; border-radius: 5px; }
.diff-before { background: var(--red-soft); color: #ff7b72; }
.diff-after { background: var(--green-soft); color: #56d364; }
.diff-same { color: var(--text-dim); }

/* 响应式 */
@media (max-width: 900px) {
    .sidebar { width: 64px; }
    .sidebar .brand-name, .sidebar .brand-sub, .nav-item span, .nav-section, .user-chip .user-info { display: none; }
    .nav-item { justify-content: center; padding: 10px; }
    .user-chip { justify-content: center; padding: 8px; }
    .content { padding: 20px 16px 40px; }
}
