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

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #1e293b;
    --bg-input: #2d3748;
    --border: #334155;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --blue: #3b82f6;
    --blue-hover: #2563eb;
    --purple: #8b5cf6;
    --purple-hover: #7c3aed;
    --green: #22c55e;
    --red: #ef4444;
    --red-hover: #dc2626;
    --orange: #f59e0b;
    --sidebar-width: 240px;
}

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

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-header h1 {
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Sidebar Layout */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1a1a2e 0%, #15152a 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
}

.nav-links {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
}

.nav-links li a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
    border-left-color: var(--blue);
}

.nav-links li a.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue);
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-user span {
    font-size: 0.875rem;
    font-weight: 600;
}

.sidebar-user small {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: capitalize;
}

/* Main Content */
.content {
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--blue);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.card-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.card-icon.green { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.card-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--orange); }

.card-body h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

.card-body p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.card-link {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.card-link:hover {
    color: var(--blue);
    text-decoration: none;
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: rgba(59, 130, 246, 0.03);
}

.table code {
    background: var(--bg-input);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.text-center {
    text-align: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-active { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge-inactive { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge-blocked { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge-master { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.badge-reseller_master { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.badge-reseller { background: rgba(245, 158, 11, 0.15); color: var(--orange); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--blue);
    color: #fff;
}

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

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

.btn-secondary:hover {
    background: #3d4a60;
}

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

.btn-danger:hover {
    background: var(--red-hover);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

.btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* URL Copy */
.url-copy {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.url-input {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    width: 200px;
    cursor: text;
}

/* Forms */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
}

.form {
    max-width: 640px;
}

.form-group {
    margin-bottom: 1rem;
}

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

.form-group select {
    cursor: pointer;
}

.form-group input[readonly] {
    opacity: 0.8;
}

/* Code display */
.code-display label {
    margin-bottom: 0.375rem;
}

.code-value {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--blue);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    font-family: monospace;
}

/* File Upload */
.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--blue);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
    white-space: nowrap;
}

.file-input-label:hover {
    background: var(--blue-hover);
}

.file-input-label svg {
    flex-shrink: 0;
}

.file-input-name {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    word-break: break-all;
}

.current-file {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.current-file code {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    word-break: break-all;
}

.form-hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Inline form */
.inline-form {
    display: inline;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.actions {
    white-space: nowrap;
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

/* Public Page */
.public-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a0a2e 50%, var(--bg-secondary) 100%);
    padding: 1rem;
}

.public-container {
    width: 100%;
    max-width: 480px;
}

.public-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.public-card h1 {
    font-size: 1.35rem;
    margin-bottom: 1rem;
}

.download-info {
    margin-bottom: 1.5rem;
}

.info-row {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.75rem;
    line-height: 1.5;
}

.download-action {
    margin-top: 1.5rem;
}

.countdown {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.public-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

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

.error-message {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Install Page */
.install-card {
    max-width: 560px;
}

.install-log {
    list-style: none;
    text-align: left;
    margin: 1rem 0;
}

.install-log li {
    padding: 0.375rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.install-log li::before {
    content: "✓ ";
    color: var(--green);
}

.install-actions {
    margin-top: 1.5rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.collapsed {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
        padding: 1rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .url-copy {
        flex-direction: column;
        align-items: stretch;
    }

    .url-input {
        width: 100%;
    }

    .sidebar-header h2 {
        pointer-events: auto;
    }
}

@media (min-width: 769px) {
    .sidebar-header h2 {
        pointer-events: none;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Icon */
.icon-preview {
    margin-top: 0.5rem;
}

.icon-preview img {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    border: 2px solid var(--border);
    object-fit: cover;
    background: var(--bg-input);
}

.icon-preview-current {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    border: 2px solid var(--border);
    object-fit: cover;
    background: var(--bg-input);
    margin-top: 0.25rem;
}

.table-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.title-with-icon {
    display: flex;
    align-items: center;
}

/* Downloads table */
.downloads-table th {
    font-size: 0.7rem;
    white-space: nowrap;
}

.icon-cell {
    width: 52px;
    text-align: center;
}

.dl-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.dl-icon-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    border: 1px solid var(--border);
}

.title-cell {
    min-width: 160px;
}

.dl-title {
    font-weight: 600;
    font-size: 0.875rem;
}

.dl-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
    line-height: 1.3;
}

.cell-muted {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.owner-cell {
    font-size: 0.8125rem;
    white-space: nowrap;
}

.owner-cell small {
    color: var(--text-muted);
}

.badge-code {
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue);
    font-family: monospace;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.code-copy-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 92px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.18);
    color: #60a5fa;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    white-space: nowrap;
}

.code-copy-pill:hover {
    background: rgba(59, 130, 246, 0.28);
}

.code-copy-pill:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.code-copy-icon {
    font-size: 14px;
    line-height: 1;
    opacity: 0.9;
}

/* Summary cards */
.summary-cards {
    margin-bottom: 1rem;
}

.card-stat {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
}

.card-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.card-stat-value.blue { color: var(--blue); }
.card-stat-value.green { color: var(--green); }
.card-stat-value.red { color: var(--red); }
.card-stat-value.gray { color: var(--text-muted); }

.card-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.public-icon-wrap {
    text-align: center;
    margin-bottom: 0.75rem;
}

.public-icon {
    width: 96px;
    height: 96px;
    border-radius: 20px;
    object-fit: cover;
    border: 2px solid var(--border);
    background: var(--bg-input);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Selection */
::selection {
    background: rgba(59, 130, 246, 0.3);
}
