:root {
    --bg-dark: #0f1115;
    --bg-panel: rgba(21, 24, 33, 0.6);
    --bg-panel-hover: rgba(27, 31, 42, 0.8);
    --line: rgba(255, 255, 255, 0.1);
    
    --text-main: #d7dae1;
    --text-muted: #8b93a5;
    --text-dark: #5f6779;
    
    --accent: #7dd3a0;
    --accent-dim: rgba(42, 69, 54, 0.5);
    --accent-glow: rgba(125, 211, 160, 0.3);
    
    --neon-blue: #7aa8e0;
    --neon-purple: #c98fd0;
    --warning: #e0b96a;
    --error: #e08a7a;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

/* Background Effects */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.4;
    animation: float 20s infinite ease-in-out alternate;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(122, 168, 224, 0.2) 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    border-radius: 16px;
}

/* Sidebar */
.sidebar {
    width: 260px;
    margin: 20px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
}

.brand {
    padding: 30px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand span {
    color: var(--accent);
}

.logo {
    width: 40px;
    height: 40px;
    background-image: url('logo.jpg');
    background-size: cover;
    background-position: center;
    border-radius: 10px;
    box-shadow: 0 0 20px var(--accent-glow);
}

.nav-menu {
    flex: 1;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid rgba(125, 211, 160, 0.2);
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--line);
}

.balance-card {
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.balance-card .label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.balance-card h3 {
    font-size: 20px;
    font-family: var(--font-mono);
    color: var(--accent);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px 20px 20px 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 30px;
    margin-bottom: 24px;
}

.top-header h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(0,0,0,0.3);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--line);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 var(--accent-glow); }
    70% { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* Dashboard Cards */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 24px;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.2);
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-main);
    margin-bottom: 8px;
}

.stat-details {
    font-size: 13px;
    color: var(--text-dark);
}

.section-title {
    margin: 0 0 20px;
}

.section-title h2 {
    font-size: 18px;
    font-weight: 600;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.service-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.service-card:hover {
    background: rgba(255,255,255,0.03);
    border-color: var(--accent-dim);
}

.service-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.service-title {
    font-weight: 600;
    font-size: 16px;
}

.service-code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.available { background: var(--accent-dim); color: var(--accent); }
.badge.maintenance { background: rgba(224, 185, 106, 0.2); color: var(--warning); }

.service-price {
    font-family: var(--font-mono);
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 16px;
}

.service-meta {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.service-meta span {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 4px;
}

/* Forms */
.form-container {
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
}

.form-container h2 {
    margin-bottom: 24px;
    font-size: 20px;
}

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

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

.muted {
    color: var(--text-dark);
    font-size: 12px;
    font-weight: normal;
}

input, select, textarea {
    width: 100%;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--line);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: #8eebb4;
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.15);
}

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

/* Tables */
.table-container {
    padding: 24px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-responsive {
    overflow-x: auto;
}

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

.modern-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(0,0,0,0.2);
}

.modern-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: top;
}

.modern-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

.modern-table code {
    font-family: var(--font-mono);
    color: var(--neon-blue);
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.status-success { background: rgba(125, 211, 160, 0.1); color: var(--accent); border: 1px solid var(--accent-dim); }
.status-failed { background: rgba(224, 138, 122, 0.1); color: var(--error); border: 1px solid rgba(224, 138, 122, 0.3); }
.status-partial { background: rgba(224, 185, 106, 0.1); color: var(--warning); border: 1px solid rgba(224, 185, 106, 0.3); }
.status-processing, .status-queued { background: rgba(122, 168, 224, 0.1); color: var(--neon-blue); border: 1px solid rgba(122, 168, 224, 0.3); }

/* Result Box */
.result-box {
    margin-top: 24px;
    padding: 16px;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--line);
}
.result-box pre {
    font-family: var(--font-mono);
    font-size: 13px;
    overflow-x: auto;
    color: var(--text-main);
    white-space: pre-wrap;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-panel-hover);
    border: 1px solid var(--line);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* =========================================
   LOGIN SCREEN
========================================= */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    background: transparent;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-logo img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 20px;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0,255,255,0.2);
}

.login-box h2 {
    margin-bottom: 5px;
    color: var(--text-primary);
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.login-box form {
    width: 100%;
}

.login-error {
    color: var(--error);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 15px;
    min-height: 20px;
}

/* =========================================
   FLOATING SAVE BAR
========================================= */
.floating-save-bar {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
    visibility: hidden;
    display: flex;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1500;
    pointer-events: none; /* Allows clicking through the empty space */
}

.floating-save-bar.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.save-bar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-radius: 50px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 255, 255, 0.2), 0 0 0 1px rgba(0, 255, 255, 0.1);
    gap: 20px;
    pointer-events: auto; /* Make the actual bar clickable */
}

.save-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 500;
}

.save-info svg {
    color: var(--accent);
}

.btn-glow {
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 15px rgba(0, 255, 255, 0.4); }
    50% { box-shadow: 0 0 25px rgba(0, 255, 255, 0.7); }
    100% { box-shadow: 0 0 15px rgba(0, 255, 255, 0.4); }
}

.text-center { text-align: center; }
.loading-state { color: var(--text-dark); padding: 40px; font-style: italic; }


/* Radio Buttons for Stock Status */
.radio-group {
    display: flex;
    gap: 12px;
    font-size: 13px;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-main);
}
.radio-label input[type="radio"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    padding: 0;
}

.disabled-link {
    pointer-events: none;
    opacity: 0.4;
    text-decoration: line-through;
    filter: grayscale(100%);
}

.stock-badge {
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 12px;
    margin-left: auto;
}

.stock-badge-large {
    font-size: 14px;
    color: var(--accent);
    font-weight: normal;
    margin-left: 10px;
    vertical-align: middle;
}

@media (max-width: 900px) {
    .app-container { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: static; margin: 10px; }
    .grid-2 { grid-template-columns: 1fr; }
    .main-content { padding: 10px; }
}

/* --- MODERN DARK LOGIN --- */
#login-screen {
    background: linear-gradient(135deg, #0b0f19 0%, #111827 40%, #0f172a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}

#login-screen::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 60%);
    top: -150px;
    left: -150px;
    border-radius: 50%;
    z-index: -1;
}

#login-screen::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 60%);
    bottom: -100px;
    right: -100px;
    border-radius: 50%;
    z-index: -1;
}

.login-card.modern-light {
    background: #1e293b;
    border-radius: 24px;
    padding: 40px;
    width: 420px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    z-index: 10;
}

.modern-heading {
    font-size: 1.8rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 5px;
}

.modern-subtitle {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-bottom: 30px;
}

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

.modern-form label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.modern-form .form-control {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 14px 16px;
    width: 100%;
    color: #f8fafc;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.modern-form .form-control:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.input-with-icon {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: #94a3b8;
}

.captcha-hint {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 8px;
    margin-bottom: 12px;
}

.captcha-container {
    display: flex;
    gap: 12px;
    align-items: center;
}

.captcha-image {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.btn-refresh-captcha {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s;
}

.btn-refresh-captcha:hover {
    background: #1e293b;
    color: #f8fafc;
}

.btn-modern-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px;
    width: 100%;
    font-weight: 600;
    font-size: 1.05rem;
    margin-top: 25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-modern-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

/* =========================================
   CUSTOM MODAL
========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.custom-modal {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.05);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-overlay.active .custom-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.custom-modal h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-modal p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.custom-modal .input-group input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--line);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.custom-modal .input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(125, 211, 160, 0.15);
}

.custom-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

.custom-modal .btn {
    padding: 10px 20px;
    font-weight: 500;
}
