/* ========================================
   CSS Variables & Theme
   ======================================== */
:root {
    --bg-primary: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fa;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.1);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.15);
    --primary: #3b82f6;
    --primary-light: rgba(102,126,234,0.1);
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --header-bg: rgba(255,255,255,0.8);
    --modal-bg: #ffffff;
    --input-bg: #f9fafb;
    --input-border: #e0e0e0;
    --btn-secondary-bg: #e5e7eb;
    --btn-secondary-text: #374151;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #273548;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.5);
    --primary-light: rgba(102,126,234,0.15);
    --header-bg: rgba(15,23,42,0.85);
    --modal-bg: #1e293b;
    --input-bg: #0f172a;
    --input-border: #334155;
    --btn-secondary-bg: #334155;
    --btn-secondary-text: #e2e8f0;
}

/* ========================================
   Reset & Base
   ======================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}
a { color: var(--primary); text-decoration: none; }

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 2px;
}
button:focus-visible, a:focus-visible, .nav-card:focus-visible {
    border-radius: var(--radius-xs);
}

/* ========================================
   Dashboard Layout
   ======================================== */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 40px;
}

/* ========================================
   Top Bar
   ======================================== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-top: 14px;
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
}
.top-bar-left { display: flex; align-items: center; }
.logo-text {
    font-size: 22px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    padding-left: 18px;
}

/* Search */
.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 420px;
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--input-border);
    border-radius: 24px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.25s;
}
.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}
.search-dropdown {
    position: absolute;
    top: 46px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    max-height: 360px;
    overflow-y: auto;
}
.search-dropdown.show { display: block; }
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: var(--bg-card-hover); }
.search-result-item .sr-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    flex-shrink: 0;
}
.search-result-item .sr-info { flex: 1; min-width: 0; }
.search-result-item .sr-name { font-size: 14px; font-weight: 500; }
.search-result-item .sr-url { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-item .sr-group { font-size: 11px; color: var(--text-secondary); background: var(--primary-light); padding: 2px 8px; border-radius: 4px; white-space: nowrap; }

/* Top bar right */
.top-bar-right { display: flex; align-items: center; gap: 8px; }
#btnAddGroup { width: 26px; height: 26px; font-size: 12px; }

/* Intranet/Extranet toggle */
.net-toggle {
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; font-size: 12px; user-select: none;
}
.form-group .net-toggle {
    display: flex; margin-bottom: 0;
    font-size: 12px; font-weight: normal; color: inherit;
}
.net-toggle input { display: none; }
.net-toggle-slider {
    width: 34px; height: 20px;
    background: #94a3b8;
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}
.net-toggle-slider::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.net-toggle input:checked + .net-toggle-slider { background: #667eea; }
.net-toggle input:checked + .net-toggle-slider::after { transform: translateX(14px); }
.net-toggle-label { color: var(--text-secondary); }
.net-toggle input:checked ~ .net-toggle-label { color: #667eea; font-weight: 600; }
.btn-icon {
    width: 38px; height: 38px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}
.btn-icon:hover {
    background: var(--primary-light);
    border-color: #667eea;
    color: #667eea;
    transform: scale(1.05);
}
.btn-icon:active { transform: scale(0.95); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-icon:disabled:hover { background: var(--bg-card); border-color: var(--border-color); color: var(--text-primary); transform: none; }

.user-menu { position: relative; }
.btn-user {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 18px 7px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.btn-user:hover { background: var(--bg-card-hover); }
.user-dropdown {
    position: absolute;
    top: 44px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    padding: 6px 0;
    display: none;
    z-index: 200;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 13px;
    transition: background 0.15s;
}
.user-dropdown a:hover { background: var(--bg-card-hover); }

/* ========================================
   Group Panel
   ======================================== */
.group-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
    transition: box-shadow 0.3s;
    animation: panelIn 0.3s ease-out;
}
.group-panel:hover { box-shadow: var(--shadow-hover); }
@keyframes panelIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.group-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(102,126,234,0.04) 0%, rgba(118,75,162,0.04) 100%);
}
.group-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.group-header-left > i {
    color: #667eea;
    font-size: 18px;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(102,126,234,0.1);
    border-radius: 10px;
    flex-shrink: 0;
}
.group-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.group-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.group-header:hover .group-actions {
    opacity: 1;
    visibility: visible;
}
.btn-action {
    width: 28px; height: 28px;
    font-size: 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.15s;
}
.btn-action:hover { color: #667eea; }
.btn-action:hover i { font-weight: 900; }
.btn-action:disabled { opacity: 0.2; cursor: not-allowed; }
.btn-action:disabled:hover { color: #94a3b8; }
.group-body { padding: 18px 20px; }
.group-empty {
    text-align: center;
    padding: 36px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ========================================
   Card Grid
   ======================================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

/* Nav Card — 横向布局: 左1/3图标 + 右2/3名称+描述 */
.nav-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    position: relative;
    user-select: none;
    animation: cardIn 0.3s ease-out backwards;
    min-height: 64px;
}
.nav-card:nth-child(1) { animation-delay: 0.02s; }
.nav-card:nth-child(2) { animation-delay: 0.04s; }
.nav-card:nth-child(3) { animation-delay: 0.06s; }
.nav-card:nth-child(4) { animation-delay: 0.08s; }
.nav-card:nth-child(5) { animation-delay: 0.10s; }
.nav-card:nth-child(6) { animation-delay: 0.12s; }
.nav-card:nth-child(7) { animation-delay: 0.14s; }
.nav-card:nth-child(8) { animation-delay: 0.16s; }
@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.nav-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: #667eea40;
}
.nav-card:active { transform: translateY(-1px) scale(0.98); }

/* 左侧图标区域 — 1/3 */
.card-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.nav-card:hover .card-icon { transform: scale(1.06); }
.card-icon img { width: 100%; height: 100%; object-fit: cover; }

/* 右侧信息区域 — 2/3 */
.card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-desc {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* Sort mode — card shake */
@keyframes cardShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-4px); }
    30% { transform: translateX(4px); }
    45% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
    75% { transform: translateX(-1.5px); }
    90% { transform: translateX(1.5px); }
}
.card-shake { animation: cardShake 0.3s ease-in-out 1; }
.sort-mode .nav-card { cursor: grab; transition: opacity 0.15s, transform 0.15s; }
.sort-mode .nav-card:active { cursor: grabbing; }
.sort-mode .nav-card:hover { transform: none; box-shadow: var(--shadow); border-color: #667eea; }
.sort-mode .nav-card.drag-over {
    border-color: #667eea;
    background: rgba(102,126,234,0.08);
    box-shadow: 0 0 0 2px rgba(102,126,234,0.4), 0 4px 12px rgba(102,126,234,0.15);
    transform: scale(1.03);
}
.sort-mode .nav-card.dragging { opacity: 0.35; transform: scale(0.92); box-shadow: 0 0 0 3px rgba(102,126,234,0.5); }

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}
.empty-state i {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.3;
}
.empty-state h3 { margin-bottom: 8px; font-size: 18px; color: var(--text-primary); }
.empty-state p { font-size: 14px; }

/* ========================================
   Loading Skeleton
   ======================================== */
.skeleton {
    background: linear-gradient(90deg, var(--border-color) 25%, transparent 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-xs);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-card {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
}
.skeleton-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    margin: 16px auto 10px;
}
.skeleton-text {
    width: 60%;
    height: 12px;
    margin: 0 auto;
}
.btn-loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}
.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease-out;
    pointer-events: all;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
}
.toast:hover { opacity: 0.9; }
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }
.toast.toast-info { background: var(--primary); }
.toast.removing { animation: toastOut 0.25s ease-in forwards; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ========================================
   Context Menu
   ======================================== */
.context-menu {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 150px;
    padding: 6px 0;
    display: none;
    animation: menuIn 0.15s ease-out;
}
@keyframes menuIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.context-menu.show { display: block; }
.context-menu .menu-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    transition: background 0.15s;
}
.context-menu .menu-item i { width: 16px; text-align: center; }
.context-menu .menu-item:hover { background: var(--bg-card-hover); }
.context-menu .menu-item.danger { color: var(--danger); }
.context-menu .menu-item.danger:hover { background: rgba(239,68,68,0.08); }

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayIn 0.2s;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background: var(--modal-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 28px;
    max-width: 500px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
    width: 34px; height: 34px;
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Form Elements
   ======================================== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.captcha-row { display: flex; gap: 8px; align-items: center; }
.captcha-row .form-input { flex: 1; }

/* Icon Picker */
.icon-picker-wrapper { position: relative; }
.icon-picker-trigger {
    width: 48px; height: 48px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.icon-picker-trigger:hover {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}
.icon-picker-dropdown {
    display: none;
    position: absolute; top: 56px; left: 0; z-index: 1000;
    width: 100%; max-height: 280px;
    overflow-y: auto;
    background: var(--modal-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}
.icon-picker-dropdown:not(.show) { display: none; }
.icon-picker-dropdown.show { display: grid; }
.icon-picker-item {
    width: 32px; height: 32px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: var(--text-primary);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-picker-item:hover {
    background: var(--primary-light);
    border-color: #667eea40;
    color: var(--primary);
}
.icon-picker-item.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

select.form-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 8px center; background-repeat: no-repeat; background-size: 20px; padding-right: 32px; }

.bg-mode-selector { display: flex; gap: 16px; }
.bg-mode-option {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    cursor: pointer; font-size: 13px;
}
.bg-mode-option input { display: none; }
.bg-mode-preview {
    width: 80px; height: 56px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background-color: var(--bg-card);
    background-image: repeating-linear-gradient(45deg, #667eea33 0, #667eea33 4px, transparent 4px, transparent 8px);
    transition: border-color 0.2s;
}
.bg-mode-option input:checked + .bg-mode-preview { border-color: #667eea; }
.fill-preview { background-size: cover; background-repeat: no-repeat; }
.tile-preview { background-size: auto; background-repeat: repeat; }
.adapt-preview { background-size: contain; background-repeat: no-repeat; background-position: center; }

.sortable-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border-color); border-radius: var(--radius); overflow: hidden; }
.sortable-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    cursor: default;
    transition: background 0.15s;
}
.sortable-item:last-child { border-bottom: none; }
.sortable-item.drag-over { background: var(--primary-light); border-bottom-color: #667eea; }
.sortable-item.dragging { opacity: 0.4; }
.sortable-item.is-new { background: #eef2ff; font-weight: 600; }
.sortable-item.is-editing { background: #fef3c7; }
.sortable-handle {
    cursor: grab; color: var(--text-secondary); font-size: 14px;
    padding: 2px 4px; line-height: 1;
}
.sortable-handle:active { cursor: grabbing; }
.sortable-name { flex: 1; font-size: 14px; }
.sortable-badge {
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    background: #667eea; color: #fff;
}
.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.color-row input[type="color"] {
    width: 42px; height: 42px;
    border: 2px solid var(--input-border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    padding: 2px;
}

/* Buttons */
.btn {
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--primary-gradient); color: #fff; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 14px; font-size: 12px; }

/* ========================================
   Password Toggle
   ======================================== */
.pwd-wrapper { position: relative; }
.pwd-wrapper .form-input { padding-right: 44px; }
.pwd-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.pwd-toggle:hover { color: var(--text-primary); background: var(--bg-card-hover); }

/* Login-specific */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.login-card {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.25);
    padding: 44px 40px 36px;
    width: 400px;
    max-width: 92vw;
    backdrop-filter: blur(20px);
}
.login-card h1 { text-align: center; color: #333; margin: 0 0 6px; font-size: 28px; font-weight: 700; }
.login-card .subtitle { text-align: center; color: #999; margin: 0 0 32px; font-size: 14px; }
.error-msg {
    display: none;
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-xs);
    background: #fef2f2;
    color: #dc2626;
    font-size: 13px;
    border: 1px solid #fecaca;
}
.login-card .demo-info {
    margin-top: 24px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #888;
    text-align: center;
    line-height: 1.8;
}
.login-card .demo-info strong { color: #555; }

/* ========================================
   Responsive — Tablet (≤768px)
   ======================================== */
@media (max-width: 768px) {
    .dashboard { padding: 0 12px 20px; }
    .top-bar {
        flex-wrap: wrap; gap: 8px;
        padding: 8px 0; margin-top: 6px; margin-bottom: 14px;
    }
    .top-bar .search-wrapper { order: 3; max-width: 100%; flex-basis: 100%; }
    .top-bar-right { gap: 4px; }
    .logo-text { font-size: 20px; padding-left: 4px; }
    .btn-user { padding: 6px 10px; font-size: 12px; }
    .btn-user span { display: none; }
    .net-toggle-label { display: none; }

    .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
    .nav-card { padding: 8px 10px; gap: 8px; min-height: 56px; }
    .card-icon { width: 38px; height: 38px; min-width: 38px; font-size: 17px; border-radius: 10px; }
    .card-name { font-size: 12px; }
    .card-desc { font-size: 10px; }

    .group-body { padding: 12px; }
    .group-header { padding: 10px 14px; }
    .group-header h3 { font-size: 14px; }
    .group-header-left { gap: 8px; }
    .group-header-left > i { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }

    .modal-content { max-width: 94%; padding: 22px 18px; }
    .modal-header { margin-bottom: 16px; }
    .modal-header h3 { font-size: 16px; }
    .modal-actions { gap: 8px; }

    .toast-container { left: 12px; right: 12px; }
    .toast { max-width: 100%; }

    .settings-page { padding: 10px 0 30px; }
    .settings-card { padding: 20px 16px; margin-bottom: 14px; }
}

/* ========================================
   Responsive — Phone (≤480px)
   ======================================== */
@media (max-width: 480px) {
    .dashboard { padding: 0 8px 16px; }
    .top-bar {
        padding: 6px 0; margin-top: 4px; margin-bottom: 10px;
        gap: 6px;
    }
    .logo-text { font-size: 17px; padding-left: 2px; }
    .search-input { font-size: 13px; padding: 8px 12px 8px 34px; }
    .search-icon { font-size: 12px; left: 10px; }

    .card-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .nav-card {
        padding: 8px; gap: 6px; min-height: 52px;
        flex-direction: column; align-items: flex-start;
    }
    .card-icon { width: 32px; height: 32px; min-width: 32px; font-size: 14px; border-radius: 8px; }
    .card-name { font-size: 11px; }
    .card-desc { font-size: 10px; }

    .group-body { padding: 8px; }
    .group-header { padding: 8px 10px; }
    .group-header h3 { font-size: 13px; }
    .group-header-left > i { width: 28px; height: 28px; font-size: 13px; border-radius: 6px; }
    .group-actions { opacity: 1; visibility: visible; }

    .btn-action { width: 24px; height: 24px; font-size: 11px; }

    .modal-overlay { align-items: flex-end; }
    .modal-content {
        max-width: 100%; width: 100%; max-height: 95vh;
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 18px 12px;
    }
    .modal-header { margin-bottom: 12px; }
    .modal-header h3 { font-size: 15px; }
    .modal-actions { flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 12px; }
    .modal-actions .btn { width: 100%; text-align: center; }

    .toast-container { top: 8px; left: 8px; right: 8px; gap: 6px; }
    .toast { padding: 10px 14px; font-size: 13px; }

    .bg-mode-selector { gap: 8px; }
    .bg-mode-preview { width: 60px; height: 44px; }

    .settings-page { padding: 6px 0 20px; }
    .settings-card { padding: 16px 12px; margin-bottom: 10px; border-radius: var(--radius-sm); }
    .settings-card h3 { font-size: 15px; margin-bottom: 14px; }

    .login-card { padding: 28px 18px 24px; }
    .login-card h1 { font-size: 24px; }
    .login-card .subtitle { margin-bottom: 24px; }

    .context-menu { min-width: 130px; }
    .context-menu .menu-item { padding: 8px 12px; font-size: 12px; gap: 8px; }

    .user-dropdown { top: 36px; right: -8px; }

    .search-result-item { padding: 10px 12px; gap: 8px; }
    .search-result-item .sr-icon { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
    .search-result-item .sr-name { font-size: 13px; }
    .search-result-item .sr-url { font-size: 11px; }

    .sortable-item { padding: 8px 10px; gap: 6px; }
    .sortable-name { font-size: 13px; }
}

/* ========================================
   Responsive — Small Phone (≤380px)
   ======================================== */
@media (max-width: 380px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .nav-card { padding: 6px; gap: 4px; min-height: 46px; }
    .card-icon { width: 28px; height: 28px; min-width: 28px; font-size: 12px; border-radius: 6px; }
    .card-name { font-size: 10px; }
    .card-desc { font-size: 9px; }
    .group-header { padding: 6px 8px; }
    .group-header h3 { font-size: 12px; }
}
