:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #6366f1;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
}

.login-card h1 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #d97706; }

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { background: var(--bg); }

.error-msg {
    color: var(--danger);
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
    display: none;
    background: #fef2f2;
    padding: 10px;
    border-radius: 8px;
}

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

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 {
    color: #fff;
    font-size: 18px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }

.sidebar-nav a.active {
    background: rgba(99,102,241,0.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

.sidebar-nav a .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
}

.sidebar-footer .user-info { margin-bottom: 8px; }

.sidebar-footer .logout-btn {
    color: var(--sidebar-text);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 13px;
    padding: 4px 0;
}

.sidebar-footer .logout-btn:hover { color: var(--danger); }

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p { color: var(--text-muted); font-size: 14px; }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    text-align: center;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f1f5f9; color: #475569; }

/* Inline Form */
.inline-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.inline-form .form-group { margin-bottom: 0; }

/* Secret Garden - Password Gate */
.sg-gate {
    max-width: 400px;
    margin: 60px auto;
    text-align: center;
}

.sg-gate .lock-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

/* Secret Garden - Analysis Results */
.analysis-result {
    background: #f8fafc;
    border-radius: 8px;
    padding: 20px;
    margin-top: 16px;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid var(--border);
    max-height: 500px;
    overflow-y: auto;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Copy area */
.copy-area {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.copy-area textarea {
    flex: 1;
    font-family: monospace;
    font-size: 12px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: vertical;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h3 { margin-bottom: 20px; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h2, .sidebar-nav a span, .sidebar-footer .user-info { display: none; }
    .sidebar-nav a { justify-content: center; padding: 12px; }
    .main-content { margin-left: 60px; padding: 16px; }
}

/* Secret Garden - Tools specific */
textarea.monospace {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
}

/* History records */
.record-item {
    background: #f8fafc;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.record-item .record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.record-item .record-body {
    font-size: 13px;
    color: var(--text-muted);
}

/* Grid for form */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
