:root {
    --bg-primary: #fdfbf7;
    --bg-secondary: #f8f5ef;
    --bg-tertiary: #f0ebe0;
    --bg-card: #ffffff;
    --border-color: #e5e0d5;
    --text-primary: #2d2a24;
    --text-secondary: #6b6658;
    --text-muted: #9c9688;
    --accent-primary: #7c6fd6;
    --accent-hover: #9289e0;
    --accent-success: #34a853;
    --accent-warning: #f59e0b;
    --accent-danger: #dc3545;
    --accent-cyan: #0891b2;
    --font-display: 'Outfit', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(45, 42, 36, 0.08);
    --shadow-md: 0 4px 20px rgba(45, 42, 36, 0.12);
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-card: #16161f;
    --border-color: #2a2a3a;
    --text-primary: #e8e8ed;
    --text-secondary: #8888a0;
    --text-muted: #555566;
    --accent-primary: #6366f1;
    --accent-hover: #818cf8;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-cyan: #22d3ee;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-display);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 32px;
    color: var(--accent-primary);
}

.logo span {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    margin-bottom: 4px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-links a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-links a.active {
    background: linear-gradient(135deg, var(--accent-primary), #5b50c9);
    color: white;
    box-shadow: 0 4px 15px rgba(124, 111, 214, 0.3);
}

.nav-links svg {
    flex-shrink: 0;
}

.user-info {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.3s ease;
}

.user-info span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.logout-btn {
    color: var(--accent-danger);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    text-align: center;
}

.logout-btn:hover {
    background: rgba(220, 53, 69, 0.1);
}

main {
    min-height: 100vh;
    padding: 32px;
    transition: margin-left 0.3s ease, background-color 0.3s ease;
}

main.with-sidebar {
    margin-left: var(--sidebar-width);
}

.alert {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: rgba(52, 168, 83, 0.15);
    border: 1px solid rgba(52, 168, 83, 0.3);
    color: var(--accent-success);
}

.alert-error {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: var(--accent-danger);
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(124, 111, 214, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(8, 145, 178, 0.08) 0%, transparent 50%),
        var(--bg-primary);
    transition: background 0.3s ease;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header svg {
    color: var(--accent-primary);
    margin-bottom: 16px;
}

.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.auth-footer p {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 111, 214, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent-primary), #5b5ac9);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 111, 214, 0.35);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-primary + .btn-secondary {
    margin-top: 12px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 4px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: rgba(124, 111, 214, 0.15);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.accent {
    background: rgba(8, 145, 178, 0.15);
    color: var(--accent-cyan);
}

.stat-icon.success {
    background: rgba(52, 168, 83, 0.15);
    color: var(--accent-success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-content {
    padding: 20px 24px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 16px;
}

.domain-list {
    list-style: none;
}

.domain-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.domain-list li:last-child {
    border-bottom: none;
}

.domain-name {
    font-weight: 500;
    color: var(--accent-primary);
}

.domain-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.filters {
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 280px;
    position: relative;
}

.search-input svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.search-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.filters select {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    min-width: 160px;
    transition: all 0.2s ease;
}

.credentials-list table,
.api-keys-list table,
.small-table {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.credentials-list th,
.credentials-list td,
.api-keys-list th,
.api-keys-list td,
.small-table th,
.small-table td {
    padding: 16px 20px;
    text-align: left;
    transition: background-color 0.3s ease;
}

.credentials-list th,
.api-keys-list th,
.small-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.credentials-list tr,
.api-keys-list tr,
.small-table tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease, border-color 0.3s ease;
}

.credentials-list tr:hover,
.api-keys-list tr:hover,
.small-table tr:hover {
    background: var(--bg-tertiary);
}

.credentials-list tr:last-child,
.api-keys-list tr:last-child {
    border-bottom: none;
}

.domain-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.domain-cell .domain {
    font-weight: 600;
    color: var(--accent-primary);
}

.domain-cell .notes {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.password-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-cell .password {
    font-family: var(--font-mono);
    letter-spacing: 0.1em;
}

.copy-btn {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.copy-btn.copied {
    color: var(--accent-success);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.btn-icon.danger:hover {
    background: rgba(220, 53, 69, 0.15);
    color: var(--accent-danger);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin: 20px;
    animation: slideUp 0.3s ease;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    font-size: 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal form {
    padding: 24px;
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.toggle-password:hover {
    color: var(--text-primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn-primary,
.form-actions .btn-secondary {
    flex: 1;
}

.api-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.api-info-card h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.api-info-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.9375rem;
}

.api-endpoint {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 12px;
    transition: background-color 0.3s ease;
}

.api-endpoint code {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    font-size: 0.875rem;
}

.api-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.limit-reached {
    color: var(--accent-warning);
    font-size: 0.875rem;
}

.api-key-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-key {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.3s ease;
}

.domain-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.domain-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.domain-bar .domain-name {
    flex: 0 0 120px;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-container {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.domain-bar .domain-count {
    flex: 0 0 40px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.heatmap {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4px;
    margin-bottom: 12px;
}

.heatmap-cell {
    aspect-ratio: 1;
    background: var(--accent-primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-family: var(--font-mono);
    color: white;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.3s ease;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 1;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-bar {
    width: 100px;
    height: 8px;
    background: linear-gradient(90deg, rgba(124, 111, 214, 0.2), var(--accent-primary));
    border-radius: 4px;
}

.ip-list {
    list-style: none;
}

.ip-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.ip-list li:last-child {
    border-bottom: none;
}

.ip-address {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--accent-cyan);
}

.ip-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.small-table th,
.small-table td {
    padding: 10px 12px;
    text-align: left;
}

.small-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.badge {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.admin {
    background: rgba(124, 111, 214, 0.2);
    color: var(--accent-primary);
}

.badge.user {
    background: rgba(107, 102, 88, 0.15);
    color: var(--text-secondary);
}

.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 0 4px;
}

.trend-bar {
    flex: 1;
    background: linear-gradient(180deg, var(--accent-primary), rgba(124, 111, 214, 0.3));
    border-radius: 4px 4px 0 0;
    position: relative: 4px;
    transition:;
    min-height all 0.3s ease;
}

.trend-bar:hover {
    background: linear-gradient(180deg, var(--accent-cyan), rgba(8, 145, 178, 0.3));
}

.trend-count {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6875rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.trend-bar:hover .trend-count {
    opacity: 1;
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.settings-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.user-row:last-child {
    border-bottom: none;
}

.user-row .user-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-row .user-info-item .username {
    font-weight: 600;
    color: var(--text-primary);
}

.user-row .user-info-item .role {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 16px;
    }
    
    main.with-sidebar {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .search-input {
        min-width: 100%;
    }
    
    .credentials-list table,
    .api-keys-list table {
        display: block;
        overflow-x: auto;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
