/* ── TomSkill Design v2 ── */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-bg: #eff6ff;
    --accent: #818cf8;
    --sidebar-bg: #ffffff;
    --sidebar-text: #64748b;
    --sidebar-text-hover: #1f2937;
    --sidebar-active: #2563eb;
    --border: #dbe3ee;
    --border-light: #edf2f7;
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-primary: 0 2px 8px rgba(37, 99, 235, 0.25);
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 60px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
}

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

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

a { color: inherit; }

/* ═══════════════════════════════════════════════════════
   SIDEBAR — Dark theme
   ═══════════════════════════════════════════════════════ */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: width 0.2s ease;
    border-right: 1px solid var(--border);
    box-shadow: none;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-brand { padding: 18px 10px; justify-content: center; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-version,
.sidebar.collapsed .sidebar-link-text,
.sidebar.collapsed .sidebar-section-label { display: none; }
.sidebar.collapsed .sidebar-nav { padding: 0 8px; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px 16px;
    text-decoration: none; color: var(--text);
    border-bottom: 1px dashed var(--border);
    transition: all 0.2s ease;
}
.sidebar-brand:hover {
    background: var(--surface-2);
    border-bottom-color: var(--primary);
}
.sidebar-logo {
    width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent), var(--primary));
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sidebar-brand:hover .sidebar-logo {
    transform: scale(1.08) rotate(-3deg);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.sidebar-brand-text { font-size: 14px; font-weight: 700; letter-spacing: -0.3px; }
.sidebar-version {
    font-size: 9px; font-weight: 600; color: var(--text-muted);
    background: var(--bg); border: 1px solid var(--border);
    padding: 1px 5px; border-radius: 4px;
    transition: all 0.2s ease;
}
.sidebar-brand:hover .sidebar-version {
    border-color: var(--primary);
    color: var(--primary);
}

.sidebar-nav { padding: 8px; flex: 1; overflow-y: auto; }

.sidebar-section-label {
    padding: 18px 12px 6px;
    font-size: 10px; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1px;
}

.sidebar-divider {
    height: 1px; background: linear-gradient(90deg, var(--border-light), transparent);
    margin: 8px 12px;
}

.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    color: var(--sidebar-text);
    text-decoration: none; font-size: 13px; font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    margin-bottom: 1px;
    position: relative;
}
.sidebar-link::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 0; border-radius: 2px;
    background: var(--primary);
    transition: height 0.2s ease;
}
.sidebar-link:hover {
    background: var(--surface-2);
    color: var(--sidebar-text-hover);
    padding-left: 14px;
}
.sidebar-link:hover::before { height: 16px; }
.sidebar-link-active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}
.sidebar-link-active::before { height: 20px; }
.sidebar-link-active:hover { background: var(--primary-light); color: var(--primary); padding-left: 14px; }

.sidebar-link-icon {
    font-size: 15px; display: inline-flex;
    align-items: center; justify-content: center;
    width: 20px; flex-shrink: 0;
}

/* Sidebar User */
.sidebar-user {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    border-top: 1px dashed var(--border);
    transition: padding 0.2s;
}
.sidebar.collapsed .sidebar-user { padding: 10px 8px; justify-content: center; }
.sidebar.collapsed .sidebar-user-meta,
.sidebar.collapsed .sidebar-user-logout { display: none; }
.sidebar-user-info {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; flex: 1; min-width: 0;
    border-radius: var(--radius-sm); padding: 4px;
    transition: background 0.15s;
}
.sidebar-user-info:hover { background: var(--surface-2); }
.sidebar-user-avatar {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
    transition: transform 0.2s ease;
}
.sidebar-user-info:hover .sidebar-user-avatar { transform: scale(1.05); }
.sidebar-user-meta { min-width: 0; }
.sidebar-user-name {
    display: block; font-size: 12px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 10px; color: var(--sidebar-text); text-transform: capitalize;
}
.sidebar-user-logout {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--radius-xs);
    color: var(--text-muted); text-decoration: none;
    transition: all 0.2s ease; flex-shrink: 0;
}
.sidebar-user-logout:hover {
    background: var(--error-bg); color: var(--error);
    transform: rotate(90deg);
}

.sidebar-toggle {
    padding: 14px; text-align: center; cursor: pointer;
    border-top: 1px dashed var(--border);
    color: var(--text-muted); font-size: 12px;
    transition: all 0.2s ease; user-select: none;
}
.sidebar-toggle:hover { color: var(--primary); background: var(--surface-2); }
.sidebar-toggle svg { transition: transform 0.25s ease; }

/* ═══════════════════════════════════════════════════════
   PAGE CONTAINER
   ═══════════════════════════════════════════════════════ */
.page-container {
    margin-left: var(--sidebar-width);
    max-width: 1480px;
    padding: 24px 28px 48px;
    min-height: 100vh;
    transition: margin-left 0.2s ease;
}
.page-container.sidebar-collapsed-mode { margin-left: var(--sidebar-collapsed-width); }

/* ═══════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════ */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }

/* ═══════════════════════════════════════════════════════
   SKILL PAGE HEADER / TABS
   ═══════════════════════════════════════════════════════ */
.skill-page-header {
    margin-bottom: 0;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 28px 0;
    margin-left: -24px;
    margin-right: -24px;
    margin-top: -24px;
}
.breadcrumb {
    display: flex; align-items: center; gap: 6px;
    color: var(--text-muted);
    font-size: 12px; font-weight: 500;
    margin-bottom: 16px; flex-wrap: wrap;
}
.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
}
.breadcrumb a:hover { background: var(--primary-bg); }
.breadcrumb-sep { display: inline-flex; color: var(--text-muted); opacity: 0.4; }
.skill-title-row {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 20px; flex-wrap: wrap;
}
.skill-title-main {
    display: flex; align-items: flex-start; gap: 16px; min-width: 0;
}
.skill-title-icon {
    width: 52px; height: 52px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 38px; flex-shrink: 0;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border: 1px solid #c7d2fe;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}
.skill-title-main h1 {
    font-size: 24px; font-weight: 700; color: var(--text);
    line-height: 1.2; margin: 0; letter-spacing: -0.3px;
}
.skill-title-main p {
    max-width: 760px; margin-top: 6px;
    color: var(--text-secondary); font-size: 13px; line-height: 1.5;
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions .btn {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.page-tabs {
    display: flex; align-items: end; gap: 0;
    margin-top: 20px;
    padding: 0;
    border-bottom: none;
}
.page-tab {
    padding: 10px 20px 12px;
    border: 0;
    border-bottom: 2.5px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px; font-weight: 500;
    display: inline-flex; align-items: center; gap: 7px;
    margin-bottom: 0;
    box-shadow: none;
    transition: all 0.2s ease;
    position: relative;
}
.page-tab:hover { color: var(--text); background: rgba(0,0,0,0.02); }
.page-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
    font-weight: 600;
}
.page-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 2.5px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}
.tab-count {
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 11px; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
}
.page-tab.active .tab-count {
    background: var(--primary-light);
    color: var(--primary);
}

/* ═══════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════ */
.card {
    background: var(--surface); border: 1px solid var(--border-light);
    border-radius: var(--radius); padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    margin-bottom: 16px;
}
.card-interactive {
    cursor: pointer;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.card-interactive:hover {
    box-shadow: var(--shadow-md);
    border-color: #c7d2fe;
    transform: translateY(-2px);
}
.card h2 {
    font-size: 15px; font-weight: 600; color: var(--text);
    margin-bottom: 18px; display: flex; align-items: center; gap: 8px;
}
.card h2::before {
    content: ''; width: 3px; height: 16px;
    background: linear-gradient(180deg, var(--primary), #818cf8);
    border-radius: 2px;
    flex-shrink: 0;
}
.card-subtitle {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    margin: -12px 0 20px;
}

/* ═══════════════════════════════════════════════════════
   SKILL WORKSPACE
   ═══════════════════════════════════════════════════════ */
.skill-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: start;
    padding-top: 24px;
}
.skill-main { min-width: 0; }
.skill-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    position: sticky;
    top: 20px;
}
.rail-card {
    padding: 18px;
    margin-bottom: 0;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.rail-title {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.kv-list {
    display: flex; flex-direction: column; gap: 14px;
    font-size: 13px;
}
.kv-list div,
.settings-grid div {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; min-width: 0;
}
.kv-list span,
.settings-grid span {
    color: var(--text-secondary); flex-shrink: 0;
}
.kv-list strong,
.settings-grid strong {
    color: var(--text); font-weight: 600; text-align: right;
    min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 24px; padding: 0 9px;
    border-radius: var(--radius-xs);
    font-size: 12px; font-weight: 700;
    line-height: 1; white-space: nowrap;
}
.badge-dot::before {
    content: ''; width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-neutral { background: var(--surface-3); color: var(--text-secondary); }
.stats-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; margin-bottom: 16px;
}
.stats-value {
    font-family: var(--font-mono);
    font-size: 26px; line-height: 1; font-weight: 700;
    color: var(--text);
}
.stats-success { color: var(--success); }
.stats-label {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
}
.mini-bars {
    height: 36px; display: flex; align-items: end; gap: 3px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 3px;
}
.mini-bars span {
    flex: 1; min-width: 4px;
    background: linear-gradient(180deg, var(--primary), #a5b4fc);
    border-radius: 2px 2px 0 0;
    opacity: 0.7;
    transition: all 0.2s ease;
}
.mini-bars span:hover { opacity: 1; transform: scaleY(1.05); transform-origin: bottom; }
.caller-list { display: flex; flex-direction: column; gap: 4px; }
.caller-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; min-width: 0;
    padding: 7px 10px; border-radius: var(--radius-xs);
    transition: background 0.15s ease;
}
.caller-row:hover { background: var(--surface-2); }
.caller-row span:nth-child(2) {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.caller-row strong {
    font-family: var(--font-mono);
    font-size: 11px; color: var(--text-muted);
}
.avatar-mini {
    width: 24px; height: 24px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-bg), #e0e7ff);
    color: var(--primary);
    font-size: 10px; font-weight: 700; flex-shrink: 0;
    border: 1px solid #c7d2fe;
}
.empty-compact {
    color: var(--text-muted);
    font-size: 13px;
}
.form-meta-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 240px);
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}
.inline-field-row {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin-bottom: 18px;
}
.inline-field-row label {
    margin: 0; display: flex; align-items: center; gap: 9px;
}
.section-title-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 6px;
}
.editor-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--surface-2);
    margin-bottom: 16px;
}
.upload-panel {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--surface);
    transition: all 0.2s ease;
}
.upload-panel:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.06);
}
.upload-panel label {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 8px; display: block;
}
.compact-form-grid { margin-top: 4px; }
.form-footer {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; margin-top: 20px; padding-top: 18px;
    border-top: 1px solid var(--border-light);
}
.compact-error {
    display: inline-flex;
    padding: 8px 12px;
    margin: 0 0 8px;
}
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.settings-grid div {
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    transition: border-color 0.15s;
}
.settings-grid div:hover { border-color: var(--border); }
.settings-grid span { font-size: 11px; color: var(--text-muted); }
.settings-grid strong { font-size: 13px; }
.settings-grid div {
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.doc-viewer {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.75;
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════
   KPI CARDS
   ═══════════════════════════════════════════════════════ */
.kpi-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 16px; margin-bottom: 24px;
}
.kpi-card {
    padding: 20px;
    position: relative; overflow: hidden;
}
.kpi-card::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
}
.kpi-card:nth-child(1)::after { background: var(--text-muted); }
.kpi-card:nth-child(2)::after { background: var(--success); }
.kpi-card:nth-child(3)::after { background: var(--primary); }
.kpi-card:nth-child(4)::after { background: var(--error); }
.kpi-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.kpi-card-label {
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.8px;
}
.kpi-card-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.kpi-card:nth-child(1) .kpi-card-icon { background: var(--surface-3); }
.kpi-card:nth-child(2) .kpi-card-icon { background: var(--success-bg); }
.kpi-card:nth-child(3) .kpi-card-icon { background: var(--primary-light); }
.kpi-card:nth-child(4) .kpi-card-icon { background: var(--error-bg); }
.kpi-card-value {
    font-size: 30px; font-weight: 700; letter-spacing: -1px;
    color: var(--text); margin-bottom: 4px;
}
.kpi-card-value--success { color: var(--success); }
.kpi-card-value--primary { color: var(--primary); }
.kpi-card-value--danger { color: var(--error); }
.kpi-card-sub { font-size: 12px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════
   SECTION CARDS (Dashboard live/recent)
   ═══════════════════════════════════════════════════════ */
.section-card { padding: 0; overflow: hidden; }
.section-card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border-light);
    font-size: 14px; font-weight: 600; color: var(--text);
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-2);
}
.section-card-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.section-card-dot--live { background: var(--primary); animation: pulse-dot 2s infinite; }
.section-card-dot--done { background: var(--success); }
.section-card-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-bottom: 1px solid var(--border-light);
    font-size: 13px; text-decoration: none; color: inherit;
    transition: background 0.1s;
}
.section-card-row:last-child { border-bottom: none; }
.section-card-row:hover { background: var(--surface-2); }
.section-card-row-icon { font-size: 16px; }
.section-card-row-name { color: var(--text); font-weight: 500; }
.section-card-row-id {
    color: var(--text-muted); font-family: var(--font-mono);
    font-size: 11px; margin-left: 6px;
}

/* ═══════════════════════════════════════════════════════
   SKILL GRID
   ═══════════════════════════════════════════════════════ */
.skill-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.skill-card {
    padding: 22px; text-decoration: none; color: inherit;
    display: flex; align-items: center; gap: 16px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}
.skill-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235,0.08);
}
.skill-card-icon {
    font-size: 36px; flex-shrink: 0;
    width: 52px; height: 52px; border-radius: 12px;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
}
.skill-card-body { flex: 1; min-width: 0; }
.skill-card-name { font-size: 15px; font-weight: 600; color: var(--text); }
.skill-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.skill-card-meta { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.skill-meta-tag {
    font-size: 10.5px; font-weight: 600; padding: 2px 8px;
    border-radius: 4px; letter-spacing: 0.2px;
}
.skill-meta-version { background: var(--primary-light); color: var(--primary); }
.skill-meta-category { background: #fef3c7; color: #92400e; }
.skill-meta-runtime { background: #dcfce7; color: #166534; }

/* ═══════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════ */
.btn, button {
    padding: 8px 16px; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; font-weight: 600;
    transition: all 0.15s ease; display: inline-flex; align-items: center;
    justify-content: center; gap: 6px; text-decoration: none;
    line-height: 1.4; font-family: var(--font);
}
.btn:active, button:active { transform: scale(0.97); }
.btn:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
    background: var(--primary); color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235,0.25);
    transition: all 0.15s ease;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 16px rgba(37, 99, 235,0.3);
    transform: translateY(-1px);
}
.btn-secondary {
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-secondary);
    box-shadow: none;
    transition: all 0.15s ease;
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-2); border-color: var(--primary); color: var(--primary);
}
.btn-danger {
    background: var(--surface); border: 1px solid var(--border);
    color: var(--error);
}
.btn-danger:hover:not(:disabled) {
    background: var(--error-bg); border-color: #fecaca;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 5px 10px; font-size: 11px; border-radius: var(--radius-xs); }
.btn-group { display: flex; gap: 10px; margin-top: 20px; }

/* ═══════════════════════════════════════════════════════
   FILTER TABS
   ═══════════════════════════════════════════════════════ */
.filter-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-btn {
    font-size: 12px; padding: 7px 16px; border-radius: 20px;
    font-weight: 500;
}
.filter-btn .count { opacity: 0.6; margin-left: 4px; font-weight: 400; }

/* ═══════════════════════════════════════════════════════
   SEARCH & TOOLBAR
   ═══════════════════════════════════════════════════════ */
.search-wrap { position: relative; flex: 1; max-width: 320px; }
.search-wrap svg {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--text-muted);
}
.search-wrap input { padding-left: 36px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════
   TASK TABLE
   ═══════════════════════════════════════════════════════ */
.task-table-wrap { padding: 0; overflow: hidden; }
.task-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.task-table th {
    background: var(--surface-2); font-weight: 600; color: var(--text-muted);
    text-align: left; padding: 12px 16px;
    border-bottom: 2px solid var(--border);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
}
.task-table td { padding: 14px 16px; }
.task-table tbody tr { border-bottom: 1px solid var(--border-light); }
.task-table tbody tr:last-child { border-bottom: none; }
.task-table tbody tr:hover { background: var(--surface-2); }
.task-table td a { color: var(--primary); text-decoration: none; font-weight: 600; }
.task-table td a:hover { text-decoration: underline; }
.task-table .task-name { color: var(--text); font-weight: 500; }
.task-table .task-name span { display: block; }
.task-table .task-name small {
    display: block; margin-top: 3px;
    color: var(--text-muted); font-weight: 500; font-size: 11px;
}
.task-table .task-time { color: var(--text-muted); font-size: 12px; }
.task-actions { display: flex; gap: 6px; }
.skill-history-table { min-width: 820px; }

/* ═══════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════ */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 6px; margin-top: 24px;
}
.pagination a, .pagination span { font-size: 13px; }

/* ═══════════════════════════════════════════════════════
   TASK DETAIL
   ═══════════════════════════════════════════════════════ */
.detail-grid {
    display: grid; grid-template-columns: 100px 1fr;
    gap: 14px 24px; font-size: 14px;
}
.detail-label { color: var(--text-muted); font-weight: 500; font-size: 12px; }
.detail-value { color: var(--text); font-weight: 500; }
.detail-value-row { display: flex; align-items: center; gap: 10px; }

/* ═══════════════════════════════════════════════════════
   TIMELINE
   ═══════════════════════════════════════════════════════ */
.timeline-wrap {
    position: relative; padding-left: 32px;
}
.timeline-wrap::before {
    content: ''; position: absolute; left: 11px; top: 6px; bottom: 6px;
    width: 2px; background: var(--border); border-radius: 1px;
}
.timeline-step {
    position: relative; padding: 10px 0;
    font-size: 13.5px; display: flex; align-items: center; gap: 10px;
}
.timeline-step::before {
    content: ''; position: absolute; left: -21px; top: 14px;
    width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid #fff; z-index: 1;
    background: var(--border);
}
.timeline-step--done { color: var(--success); }
.timeline-step--done::before { background: var(--success); }
.timeline-step--active { color: var(--primary); font-weight: 600; }
.timeline-step--active::before {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235,0.15);
    animation: pulse-ring 2s infinite;
}
.timeline-step-icon { font-size: 14px; }

/* ═══════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════ */
.progress-wrap { margin-top: 16px; }
.progress-bar {
    height: 6px; background: var(--border-light);
    border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8, #a78bfa);
    border-radius: 4px; transition: width 0.6s ease;
}
.progress-text { font-size: 12px; color: var(--text-muted); margin-top: 8px; text-align: center; }

/* ═══════════════════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════════════════ */
label, .form-label {
    display: block; margin-bottom: 6px; font-weight: 600;
    color: var(--text-secondary); font-size: 12px;
    letter-spacing: 0.01em;
}
textarea, input[type="text"], input[type="search"], input[type="tel"], input[type="url"],
input[type="date"], input[type="number"], input[type="email"], input[type="password"], select {
    width: 100%; padding: 10px 12px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-size: 13px;
    transition: all 0.15s ease;
    font-family: var(--font);
}
textarea { resize: vertical; font-family: var(--font-mono); }
textarea:focus, input:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.input-sm { width: 120px; padding: 9px 14px; font-size: 14px; text-align: center; }

/* ═══════════════════════════════════════════════════════
   TABLE EDITOR
   ═══════════════════════════════════════════════════════ */
.editor-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.editor-table th {
    background: var(--surface-2); font-weight: 600; color: var(--text-muted);
    text-align: left; padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
}
.editor-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-light); }
.editor-table tbody tr:hover td { background: var(--surface-2); }
.editor-table .row-num {
    width: 32px; text-align: center;
    color: var(--text-muted); font-size: 12px; font-weight: 500;
}
.editor-table input {
    width: 100%; border: 1px solid transparent; padding: 8px 10px; font-size: 13px;
    border-radius: var(--radius-xs); background: transparent; color: var(--text);
    transition: all 0.15s; font-family: var(--font);
}
.editor-table input:hover { border-color: var(--border); }
.editor-table input:focus {
    border-color: var(--primary); background: var(--surface);
    outline: none; box-shadow: 0 0 0 2px rgba(37, 99, 235,0.08);
}
.editor-table .del-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px; padding: 4px 8px;
    border-radius: 6px; transition: all 0.12s;
}
.editor-table .del-btn:hover { background: var(--error-bg); color: var(--error); }
.editor-toolbar { display: flex; gap: 8px; align-items: center; margin-top: 14px; }

/* ═══════════════════════════════════════════════════════
   DROP ZONE
   ═══════════════════════════════════════════════════════ */
.drop-zone {
    border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
    padding: 24px 16px; text-align: center; cursor: pointer;
    background: var(--surface-2); transition: all 0.2s ease;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary); background: var(--primary-bg);
    transform: translateY(-1px);
}
.drop-zone.has-file {
    border-color: var(--success); background: var(--success-bg);
    border-style: solid;
}
.drop-zone .icon { font-size: 32px; margin-bottom: 10px; }
.drop-zone .text { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.drop-zone .hint { color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.file-selected {
    margin-top: 8px; font-size: 12px; color: var(--success);
    display: flex; align-items: center; gap: 5px; font-weight: 500;
    padding: 6px 10px; background: var(--success-bg);
    border-radius: var(--radius-xs); border: 1px solid #bbf7d0;
}

/* ═══════════════════════════════════════════════════════
   FORM LAYOUT
   ═══════════════════════════════════════════════════════ */
.form-two-col { display: grid; grid-template-columns: minmax(0, 480px) 1fr; gap: 24px; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-col { display: flex; flex-direction: column; gap: 16px; }

/* ═══════════════════════════════════════════════════════
   STATUS PILLS
   ═══════════════════════════════════════════════════════ */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.01em;
}
.pill::before {
    content: ''; width: 6px; height: 6px;
    border-radius: 50%; flex-shrink: 0;
}
.pill-queued { background: #fef3c7; color: #92400e; }
.pill-queued::before { background: #f59e0b; }
.pill-processing { background: #dbeafe; color: #1e40af; }
.pill-processing::before { background: #3b82f6; animation: pulse-dot 1.5s infinite; }
.pill-completed { background: #dcfce7; color: #166534; }
.pill-completed::before { background: #22c55e; }
.pill-failed { background: #fef2f2; color: #991b1b; }
.pill-failed::before { background: #ef4444; }
.pill-cancelled { background: var(--surface-3); color: var(--text-secondary); }
.pill-cancelled::before { background: #94a3b8; }
.pill-awaiting_input { background: #ede9fe; color: #5b21b6; }
.pill-awaiting_input::before { background: #8b5cf6; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ═══════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    z-index: 200; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.modal-content {
    background: var(--surface); border-radius: var(--radius); padding: 28px;
    width: 540px; max-height: 80vh;
    box-shadow: var(--shadow-md);
}
.modal-content h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }

/* ═══════════════════════════════════════════════════════
   MESSAGES & HELPERS
   ═══════════════════════════════════════════════════════ */
.error {
    background: var(--error-bg); border: 1px solid #fecaca;
    color: var(--error); padding: 12px 16px;
    border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
}
.success {
    background: var(--success-bg); border: 1px solid #a7f3d0;
    color: var(--success); padding: 12px 16px;
    border-radius: var(--radius-sm); font-size: 13px;
}
.info-box {
    background: var(--info-bg); border: 1px solid #bfdbfe;
    color: var(--info); padding: 12px 16px;
    border-radius: var(--radius-sm); font-size: 13px;
}
.hint { color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.text-muted { color: var(--text-secondary); font-size: 13px; }
.text-mono { font-family: var(--font-mono); font-size: 12px; }
.code-block {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 18px;
    font-size: 12.5px; font-family: var(--font-mono);
    white-space: pre-wrap; max-height: 200px; overflow: auto;
}
.error-block {
    background: var(--error-bg); border: 1px solid #fecaca;
    border-radius: var(--radius); padding: 14px 18px;
    font-size: 12.5px; color: #991b1b;
    white-space: pre-wrap; max-height: 300px; overflow: auto;
    font-family: var(--font-mono); line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════
   FILE LIST
   ═══════════════════════════════════════════════════════ */
.file-list { list-style: none; }
.file-list li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 0; border-bottom: 1px solid var(--border-light);
}
.file-list li:last-child { border-bottom: none; }
.file-list .file-info { display: flex; align-items: center; gap: 12px; }
.file-list .file-icon { font-size: 22px; }
.file-list .file-name { font-size: 14px; color: var(--text); font-weight: 500; }
.file-list .file-size { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.download-link {
    padding: 6px 14px; background: var(--surface); color: var(--text-secondary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600; text-decoration: none;
    transition: all 0.15s ease; display: inline-flex; align-items: center; gap: 4px;
}
.download-link:hover {
    background: var(--surface-2); border-color: var(--primary); color: var(--primary);
}

/* ═══════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state.compact { padding: 38px 20px; }
.empty-state .icon { font-size: 44px; margin-bottom: 14px; }
.empty-state p { font-size: 14px; font-weight: 500; }
.empty-state .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ═══════════════════════════════════════════════════════
   LOADING BAR
   ═══════════════════════════════════════════════════════ */
.loading-bar {
    position: fixed; top: 0; left: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    z-index: 9999; width: 0;
    transition: width 0.3s ease;
}
.loading-bar--active { width: 70%; }
.loading-bar--done { width: 100%; opacity: 0; transition: width 0.15s ease, opacity 0.3s ease; }

/* ═══════════════════════════════════════════════════════
   SPINNER & ANIMATIONS
   ═══════════════════════════════════════════════════════ */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.spinner-dark {
    border-color: rgba(37, 99, 235,0.2);
    border-top-color: var(--primary);
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.3s ease-out; }

@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235,0.4); }
    70% { box-shadow: 0 0 0 8px rgba(37, 99, 235,0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235,0); }
}

/* ═══════════════════════════════════════════════════════
   COPY BUTTON
   ═══════════════════════════════════════════════════════ */
.copy-btn {
    padding: 4px 12px; font-size: 11px; font-weight: 600;
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: var(--surface); color: var(--text-secondary);
    cursor: pointer; transition: all 0.12s;
}
.copy-btn:hover { background: var(--border-light); border-color: #d1d5db; }

/* ═══════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════ */
@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════
   HTMX & ALPINE
   ═══════════════════════════════════════════════════════ */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }
[x-cloak] { display: none !important; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */
/* 移动端顶栏 + 抽屉导航(桌面隐藏) */
.mobile-topbar { display: none; }
.mobile-nav-overlay { display: none; }

@media (max-width: 768px) {
    .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 200;
        padding: 10px 16px; background: var(--surface-1, #fff);
        border-bottom: 1px solid var(--border, #e2e8f0);
    }
    .mobile-menu-btn {
        background: none; border: 1px solid var(--border, #e2e8f0);
        border-radius: 8px; padding: 6px 12px; font-size: 16px; cursor: pointer;
    }
    .mobile-topbar-brand { font-weight: 700; text-decoration: none; color: inherit; }
    .mobile-nav-overlay {
        display: block; position: fixed; inset: 0;
        background: rgba(0,0,0,0.4); z-index: 300;
    }
    .sidebar {
        display: flex; position: fixed; top: 0; left: 0; bottom: 0; z-index: 301;
        transform: translateX(-100%); transition: transform 0.25s ease;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .page-container { margin-left: 0 !important; padding: 20px 16px; }
    .btn-group { flex-direction: column; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .form-two-col { grid-template-columns: 1fr; }
    .upload-grid { grid-template-columns: 1fr; }
    .modal-content { width: 92vw; padding: 20px; }
    .skill-workspace { grid-template-columns: 1fr; padding-top: 16px; }
    .skill-rail { order: 2; position: static; }
    .skill-page-header { margin-left: 0; margin-right: 0; margin-top: 0; border-radius: var(--radius) var(--radius) 0 0; }
    .skill-title-row { align-items: stretch; }
    .skill-title-main { align-items: flex-start; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .page-tabs { gap: 18px; overflow-x: auto; }
    .page-tab { white-space: nowrap; }
    .form-meta-grid { grid-template-columns: 1fr; }
    .form-footer { flex-direction: column; align-items: stretch; }
    .form-footer .btn-primary { width: 100%; }
    .settings-grid { grid-template-columns: 1fr; }
    .editor-table { min-width: 720px; }
    .editor-panel > div[style*="overflow-x:auto"] { overflow-x: auto !important; }
    .task-table-wrap { overflow-x: auto; }
    .task-table { min-width: 760px; }
}

/* ── Auth pages ─────────────────────────────────────────── */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #eef2ff 50%, #f1f5f9 100%);
}
.auth-card {
    width: 400px; background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px; padding: 40px;
    box-shadow: var(--shadow-md);
}
.auth-logo {
    width: 48px; height: 48px; background: linear-gradient(135deg, #818cf8, var(--primary));
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 22px; margin: 0 auto 16px;
}
.auth-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.auth-link { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }
.auth-link a { color: var(--primary); text-decoration: none; font-weight: 600; }
