:root {
    --primary-color: #159137;
    --primary-hover: #10702a;
    --secondary-color: #1a1a1a;
    --bg-color: #ffffff;
    --surface-color: #f8f9fa;
    --text-color: #1a1a1a;
    --text-muted: #666666;
    --border-color: #eeeeee;
    --card-bg: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.2);
    --navbar-height: 4.5rem;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* --- Navbar --- */
.navbar {
    background: var(--primary-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    height: var(--navbar-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    /* Ensure container fills height for centering */
}

.brand {
    display: flex;
    align-items: center;
    height: 100%;
}

.brand a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none !important;
    color: white !important;
    transition: var(--transition);
}

.brand a img {
    transition: var(--transition);
}

.brand a:hover img {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.brand a:hover span {
    opacity: 0.9;
}

.brand span {
    text-decoration: none !important;
    transition: var(--transition);
}

.brand span {
    background: linear-gradient(135deg, #fff 0%, #a8e6cf 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    /* EXPLICITLY FLEX ON DESKTOP */
    align-items: center;
    gap: 0.5rem;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-links .user-greeting {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-links a.btn-primary {
    background: var(--primary-color);
    color: white;
}

.nav-links a.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* --- Mobile Toggle (Hidden on Desktop) --- */
.mobile-toggle {
    display: none !important;
}

/* --- Main Layout --- */
main {
    flex: 1;
    padding: 2.5rem 0;
}

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

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--secondary-color);
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 2rem;
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white !important;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 8px 20px rgba(21, 145, 55, 0.2);
}

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-color) !important;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #fff;
    border-color: var(--primary-color);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color) !important;
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white !important;
}

/* --- Portal Service Grid --- */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 2rem;
}

.service-card {
    position: relative;
    overflow: hidden;
}

.service-icon {
    width: 60px;
    height: 60px;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    transition: var(--transition);
}

.service-card:hover .service-icon {
    background: var(--primary-color);
    color: white;
}

.service-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--secondary-color);
}

.service-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex: 1;
}

.service-card.locked::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: grayscale(1);
    z-index: 5;
}

.lock-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #1a1a1a;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* --- Table --- */
/* --- Table --- */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--surface-color);
    text-align: left;
    padding: 1.2rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

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

tr:hover td {
    background: #fcfcfc;
}

/* --- Dashboard Stats --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.stat-info h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-info .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--secondary-color);
}

/* --- Charts Section --- */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.chart-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    min-height: 400px;
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

/* --- Footer --- */
.footer {
    background: #f1f5f9;
    /* Professional Gray */
    padding: 4rem 0;
    margin-top: 5rem;
    border-top: 1px solid var(--border-color);
    color: var(--secondary-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.footer-brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--secondary-color);
    text-decoration: none;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 600px;
}

/* --- Helper Classes --- */
.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.rounded-full {
    border-radius: 9999px !important;
}

/* Transitions */
.fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== FORM STYLES ========== */
.form-container {
    max-width: 900px;
    margin: 0 auto;
}

.cron-form,
.standard-form {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 3rem;
    border: 1px solid var(--border-color);
}

.form-section {
    margin-bottom: 3rem;
}

.form-section:last-of-type {
    margin-bottom: 0;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 1.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.section-title::before {
    content: '';
    width: 4px;
    height: 1.5rem;
    background: var(--primary-color);
    border-radius: 2px;
}

.form-row {
    margin-bottom: 1.5rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

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

.form-field {
    display: flex;
    flex-direction: column;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 0.6rem;
}

.required {
    color: #dc2626;
    font-weight: 700;
}

.form-input,
.form-control {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: white;
}

.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(21, 145, 55, 0.1);
}

.form-input-mono {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 20px;
    padding-right: 2.5rem;
}

.form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.form-actions {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.form-actions .btn {
    min-width: 180px;
    padding: 0.85rem 2rem;
    font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    :root {
        --navbar-height: 4rem;
    }

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

    .page-header h1 {
        font-size: 2rem;
    }

    .mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        /* Cleaner look without box */
        color: white;
        width: 44px;
        /* Larger touch target */
        height: 44px;
        border-radius: 50%;
        /* Rounded touch target */
        cursor: pointer;
        transition: var(--transition);
        margin-right: -10px;
        /* Align neatly to right edge */
    }

    .mobile-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        flex-direction: column;
        background: var(--primary-color);
        padding: 1.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        gap: 1rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        z-index: 1000;
    }

    .nav-links.show {
        display: flex;
        animation: fadeIn 0.2s ease-out;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        display: block;
        width: 100%;
        text-align: center;
        background: rgba(255, 255, 255, 0.05);
        padding: 1rem;
    }

    .nav-links .user-greeting {
        display: block;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    /* Mobile Dropdown Overrides */
    .dropdown {
        display: block;
        /* Stack vertically */
        width: 100%;
    }

    .dropdown-toggle {
        justify-content: center;
        /* Center text */
        width: 100%;
        background: rgba(255, 255, 255, 0.05);
        /* Match other mobile links */
        padding: 1rem;
    }

    .dropdown-menu {
        position: static;
        /* Flow naturally */
        width: 100%;
        transform: none !important;
        /* Disable centering transform */
        background: rgba(0, 0, 0, 0.1);
        /* Darker background for nesting */
        box-shadow: none;
        border: none;
        padding: 0;
        margin: 0;
        border-radius: 0;
        opacity: 1;
        /* Always visible to layout but hidden by height/display if needed, but we use .show */
        visibility: visible;
        /* Override default visibility hidden */
        display: none;
        /* Hide by default on mobile */
    }

    .dropdown-menu.show {
        display: flex;
        /* Show as flex column */
        transform: none !important;
        animation: none;
    }

    .dropdown-menu a {
        padding-left: 2rem;
        /* Indent sub-items */
        text-align: left;
        /* Align text left or center? */
        background: transparent;
        color: white !important;
        /* Ensure visibility on dark mobile menu */
    }

    .dropdown-menu a:hover {
        background: rgba(255, 255, 255, 0.05);
        color: white !important;
        transform: none;
    }

    .dropdown-menu::before {
        display: none;
        /* Hide arrow on mobile */
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    /* Form responsive styles */
    .cron-form,
    .standard-form {
        padding: 2rem 1.5rem;
    }

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

    .form-actions {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .form-actions .btn {
        width: 100%;
        min-width: unset;
    }
}

@media (max-width: 480px) {

    .cron-form,
    .standard-form {
        padding: 1.5rem 1rem;
    }

    .section-title {
        font-size: 1rem;
    }
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #ef4444;
}

.modal-body {
    padding-bottom: 1rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* --- Action Dropdowns --- */
.action-dropdown {
    position: relative;
    display: inline-block;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--surface-color);
    color: var(--primary-color);
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    z-index: 100;
    display: none;
    flex-direction: column;
    padding: 0.5rem 0;
    margin-top: 0.25rem;

    /* Default hidden state */
    visibility: hidden;
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    display: flex;
    /* Always layout for transition */
}

/* Fix for Admin Panel "Portal" Dropdowns cloned by JS */
.portal-dropdown-menu {
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    display: flex !important;
    /* Reset positioning context if needed, though JS sets top/left */
}

.dropdown-menu.show {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    display: flex;
    animation: fadeIn 0.1s ease-out;
}

.dropdown-menu button,
.dropdown-menu a {
    background: none;
    border: none;
    text-align: left;
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-color);
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: var(--transition);
}

.dropdown-menu button:hover,
.dropdown-menu a:hover {
    background: var(--surface-color);
    color: var(--primary-color);
}

.dropdown-menu button.text-danger:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* --- Navbar Dropdown --- */
.dropdown {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    right: auto;
    width: 200px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    /* Animation start state: centered X, pushed down Y */
    transform: translateX(-50%) translateY(10px);
    visibility: hidden;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* Show class for JS toggle */
.dropdown-menu.show {
    visibility: visible;
    opacity: 1;
    /* Active state: centered X, normal Y */
    transform: translateX(-50%) translateY(0);
}

.dropdown-toggle svg {
    margin-top: 2px;
    /* Optical alignment for chevron */
}

.dropdown-menu a {
    color: var(--secondary-color) !important;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: flex-start;
    text-decoration: none;
    /* Ensure no underline */
}

.dropdown-menu a:hover {
    background: var(--surface-color);
    color: var(--primary-color) !important;
    transform: translateX(4px);
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    right: auto;
    width: 12px;
    height: 12px;
    background: white;
    /* Rotation + centering offset */
    transform: translateX(-50%) rotate(45deg);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-left: 1px solid rgba(0, 0, 0, 0.05);
}