* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #c7d2fe;
    --success: #22c55e;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --max-width: 768px;
    --transition: all 0.2s ease;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; min-height: 100vh; }

.login-page { position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%); z-index: 1000; }
.login-container { background: white; border-radius: var(--radius-lg); padding: 40px 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-logo { width: 72px; height: 72px; margin: 0 auto 20px; background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%); border-radius: 18px; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3); }
.login-logo svg { width: 40px; height: 40px; stroke: white; }
.login-title { text-align: center; font-size: 26px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.login-subtitle { text-align: center; font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 14px 16px; border: 2px solid var(--border-color); border-radius: var(--radius-md); font-size: 15px; transition: var(--transition); background: var(--bg-secondary); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-group input::placeholder { color: var(--text-muted); }
.captcha-row { display: flex; gap: 12px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-display { min-width: 110px; height: 48px; background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); border: 2px solid var(--border-color); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); overflow: hidden; }
.captcha-display svg { width: 100%; height: 100%; }
.captcha-display:hover { border-color: var(--primary); }
.login-btn { width: 100%; padding: 16px; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); color: white; border: none; border-radius: var(--radius-md); font-size: 16px; font-weight: 600; cursor: pointer; transition: var(--transition); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4); }
.login-btn:active { transform: translateY(0); }

.app-container { min-height: 100vh; padding-bottom: 80px; max-width: var(--max-width); margin: 0 auto; background: var(--bg-primary); box-shadow: var(--shadow-lg); }
.app-header { background: white; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 100; }
.header-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.header-right { display: flex; align-items: center; gap: 16px; }
.admin-name { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.logout-btn { color: var(--danger); text-decoration: none; font-size: 14px; font-weight: 500; padding: 8px 16px; border-radius: var(--radius-sm); transition: var(--transition); }
.logout-btn:hover { background: var(--danger-light); }
.alert { padding: 14px 18px; margin: 16px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }

.app-main { padding: 20px 16px; }
.tool-selector { display: flex; gap: 10px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
.tool-btn { padding: 10px 20px; background: white; border: 2px solid var(--border-color); border-radius: 25px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: var(--transition); color: var(--text-secondary); flex-shrink: 0; }
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }

.stats-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: var(--radius-md); padding: 20px 16px; text-align: center; border: 1px solid var(--border-color); transition: var(--transition); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }
.stat-value { font-size: 32px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; font-weight: 500; }

.card { background: white; border-radius: var(--radius-md); border: 1px solid var(--border-color); margin-bottom: 16px; overflow: hidden; transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); background: linear-gradient(to bottom, #fafbfc, #f8fafc); }
.card-header h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; margin: 0; }
.card-body { padding: 20px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px 14px; border: 2px solid var(--border-color); border-radius: var(--radius-md); font-size: 14px; transition: var(--transition); background: var(--bg-secondary); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 20px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: var(--transition); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-secondary { background: var(--bg-primary); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }

.filter-bar { background: white; padding: 16px; border-radius: var(--radius-md); margin-bottom: 16px; border: 1px solid var(--border-color); }
.filter-bar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { padding: 10px 14px; border: 2px solid var(--border-color); border-radius: var(--radius-md); font-size: 14px; min-width: 110px; transition: var(--transition); background: white; }
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--primary); }

.list-container { background: white; border-radius: var(--radius-md); border: 1px solid var(--border-color); overflow: hidden; }
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-color); transition: var(--transition); }
.list-item:hover { background: #fafbfc; }
.list-item:last-child { border-bottom: none; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; color: var(--text-primary); }
.item-meta { font-size: 13px; color: var(--text-muted); }
.item-actions { display: flex; gap: 8px; margin-left: 16px; flex-wrap: wrap; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--text-muted); }
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.5; }

.status-normal { color: var(--success); font-weight: 500; }
.status-expired { color: var(--warning); font-weight: 500; }
.status-disabled { color: var(--danger); font-weight: 500; }

.item-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.code-wrapper { display: flex; align-items: center; gap: 8px; }
.code-value { font-family: 'Courier New', monospace; font-size: 16px; font-weight: 700; color: var(--text-primary); letter-spacing: 1px; }
.btn-copy { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: none; background: var(--bg-primary); border-radius: 6px; cursor: pointer; transition: var(--transition); color: var(--text-muted); }
.btn-copy:hover { background: var(--primary-light); color: var(--primary); }
.btn-copy.copied { background: var(--success-light); color: var(--success); }
.device-id { font-family: 'Courier New', monospace; font-size: 14px; font-weight: 600; color: var(--text-primary); word-break: break-all; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.5px; }
.badge-group { display: flex; gap: 6px; flex-wrap: wrap; }
.badge-unused { background: #dcfce7; color: #166534; }
.badge-used { background: #fee2e2; color: #991b1b; }
.badge-normal { background: #dcfce7; color: #166534; }
.badge-expired { background: #fef3c7; color: #92400e; }
.badge-disabled { background: #fee2e2; color: #991b1b; }
.badge-permanent { background: #dbeafe; color: #1e40af; }
.badge-trial { background: #fce7f3; color: #9d174d; }
.badge-yearly { background: #e0e7ff; color: #3730a3; }
.badge-monthly { background: #fef3c7; color: #92400e; }
.item-details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; }
.detail-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.detail-label { color: var(--text-muted); min-width: 50px; flex-shrink: 0; }
.detail-value { color: var(--text-primary); font-weight: 500; }
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger) !important; }
.code-item, .member-item { align-items: flex-start; padding: 16px 20px; }
.code-item .item-actions, .member-item .item-actions { align-items: flex-start; margin-top: 4px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); }

.backup-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.backup-actions .btn { flex: 1; min-width: 120px; }

.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.info-item { background: var(--bg-primary); padding: 16px; border-radius: var(--radius-md); border: 1px solid var(--border-color); transition: var(--transition); }
.info-item:hover { border-color: var(--primary-light); }
.info-item label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.info-item span { font-weight: 600; font-size: 15px; color: var(--text-primary); }

.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--max-width); background: white; border-top: 1px solid var(--border-color); display: flex; justify-content: space-around; padding: 10px 0 8px; z-index: 100; box-shadow: 0 -4px 12px rgba(0,0,0,0.05); }
.nav-item { display: flex; flex-direction: column; align-items: center; padding: 8px 16px; color: var(--text-muted); text-decoration: none; font-size: 11px; font-weight: 500; transition: var(--transition); border-radius: var(--radius-md); }
.nav-item svg { width: 24px; height: 24px; margin-bottom: 4px; }
.nav-item:hover { color: var(--primary); }
.nav-item.active { color: var(--primary); background: linear-gradient(to bottom, var(--primary-light), transparent); }

.settings-menu { background: white; border-radius: var(--radius-md); border: 1px solid var(--border-color); margin-bottom: 16px; overflow: hidden; }
.settings-menu-title { font-size: 14px; font-weight: 600; color: var(--text-muted); padding: 12px 16px; background: var(--bg-primary); border-bottom: 1px solid var(--border-color); text-transform: uppercase; letter-spacing: 0.5px; }
.settings-menu a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-size: 15px; font-weight: 500; color: var(--text-primary); text-decoration: none; transition: var(--transition); border-bottom: 1px solid var(--border-color); }
.settings-menu a:last-child { border-bottom: none; }
.settings-menu a:hover { background: var(--bg-primary); }
.settings-menu a.active { background: var(--primary); color: white; }
.settings-menu a:active { background: var(--primary-dark); }
.settings-menu a svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.7; }
.settings-menu a.active svg { opacity: 1; }
.settings-menu a .menu-text { flex: 1; }
.settings-menu a .menu-arrow { opacity: 0.4; }
.settings-menu.hidden { display: none; }

.section-divider { height: 1px; background: var(--border-color); margin: 16px 0; }

.color-badge { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: middle; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.color-badge-sm { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
select option:disabled { color: #999; background: #f5f5f5; }

.switch { position: relative; display: inline-block; width: 48px; height: 26px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: var(--transition); border-radius: 26px; }
.switch-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: var(--transition); border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.switch input:checked + .switch-slider { background-color: var(--primary); }
.switch input:checked + .switch-slider:before { transform: translateX(22px); }
.switch input:focus + .switch-slider { box-shadow: 0 0 0 3px var(--primary-light); }

.hidden { display: none !important; }

@media (max-width: 480px) {
    .stats-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat-card { padding: 12px 8px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 11px; }
    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .info-grid { grid-template-columns: 1fr; }
    .item-actions { margin-left: 12px; }
    .btn-sm { padding: 6px 10px; font-size: 12px; }
    .backup-actions { flex-direction: column; }
    .backup-actions .btn { width: 100%; }
    .item-details { grid-template-columns: 1fr; }
    .code-item, .member-item { flex-direction: column; }
    .code-item .item-actions, .member-item .item-actions { margin-left: 0; margin-top: 12px; width: 100%; }
    .code-value { font-size: 14px; }
    .device-id { font-size: 12px; }
    .tool-selector { gap: 6px; padding-bottom: 6px; }
    .tool-btn { padding: 8px 14px; font-size: 13px; }
    .page-header h2 { font-size: 18px; }
    .page-header h2 svg { width: 20px; height: 20px; }
    .card-header h3 { font-size: 15px; }
    .card-header h3 svg { width: 16px; height: 16px; }
    .filter-bar select, .filter-bar input { min-width: 80px; padding: 8px 10px; font-size: 13px; }
    .filter-bar .btn-sm { padding: 8px 12px; }
    .list-item { padding: 12px 16px; }
    .item-title { font-size: 14px; }
    .item-meta { font-size: 12px; }
    .detail-row { font-size: 12px; }
    .detail-label { min-width: 40px; }
    .badge { padding: 3px 8px; font-size: 10px; }
}
