/* ================= BASE ================= */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family-base);
    background: var(--color-bg);
    color: var(--color-text);
}

a { text-decoration: none; color: inherit; }

/* ================= LAYOUT ================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    padding: var(--space-5);
    flex-shrink: 0;
}

.sidebar-header {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: var(--space-6);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.sidebar-link {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.04);
}

.sidebar-link:hover {
    background: rgba(255,255,255,.10);
}

.sidebar-link.danger {
    color: #fecaca;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ================= MOBILE MENU BUTTON ================= */
.mobile-menu-btn {
    display: none;
}

/* ================= TOPBAR ================= */
.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
    gap: var(--space-4);
}

.topbar-left,
.topbar-center,
.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.topbar-left { min-width: 220px; }
.topbar-center { flex: 1; justify-content: center; }
.topbar-right { min-width: 220px; justify-content: flex-end; }

.topbar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.brand-name {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.brand-slogan {
    font-size: var(--font-size-md);
    color: var(--color-text-muted);
    font-weight: 600;
}

/* ================= USER ================= */
.user-block {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-avatar {
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}

/* ================= CONTENT ================= */
.page-content {
    padding: var(--space-6);
}

.page-header {
    margin-bottom: var(--space-5);
}

.page-header h1 {
    margin: 0 0 6px;
}

.page-header p {
    margin: 6px 0 0;
    color: var(--color-text-muted);
}

/* ================= CARDS ================= */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

/* ================= TABLE ================= */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
}

/* ================= BUTTONS ================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-sm {
    padding: 8px 12px;
    font-size: var(--font-size-sm);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-warning {
    background: var(--color-warning);
    color: #fff;
}

.btn-warning:hover {
    background: #b45309;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.btn-full {
    width: 100%;
}

button.btn,
a.btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    text-decoration: none;
}

button.btn-warning,
a.btn-warning {
    background-color: #d97706 !important;
    color: #ffffff !important;
}

button.btn-warning:hover,
a.btn-warning:hover {
    background-color: #b45309 !important;
    color: #ffffff !important;
}

button.btn-success,
a.btn-success {
    background-color: #16a34a !important;
    color: #ffffff !important;
}

button.btn-success:hover,
a.btn-success:hover {
    background-color: #15803d !important;
    color: #ffffff !important;
}

button.btn-danger,
a.btn-danger {
    background-color: #dc2626 !important;
    color: #ffffff !important;
}

button.btn-danger:hover,
a.btn-danger:hover {
    background-color: #b91c1c !important;
    color: #ffffff !important;
}

/* ================= ACTIONS ================= */
.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form {
    display: inline-block;
    margin: 0;
}

/* ================= ALERTS ================= */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* ================= FORMS ================= */
.form-card {
    max-width: 900px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 18px 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    margin-bottom: 8px;
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.form-control {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-md);
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

select.form-control[multiple] {
    min-height: 140px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}

/* ================= LOGIN ================= */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

/* ================= ROLES PERMISSIONS ================= */
.permission-group {
    margin-bottom: 24px;
    padding: 18px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.permission-group-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--color-text);
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 12px 16px;
}

.permission-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
}

.permission-item input[type="checkbox"] {
    margin-top: 3px;
}

.permission-item small {
    color: var(--color-text-muted);
}

/* ================= OMNI PROJECTS HUB ================= */
.omni-projects-hub {
    padding: 8px 0 32px;
}

.omni-projects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 26px;
}

.omni-projects-header h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 900;
    color: #0f172a;
}

.omni-projects-header p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 14px;
}

.omni-projects-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 24px;
}

.omni-project-card {
    background: #ffffff !important;
    border: 1px solid #dbe3ef !important;
    border-radius: 22px !important;
    padding: 24px !important;
    min-height: 330px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.10) !important;
    display: flex;
    flex-direction: column;
    transition: 0.2s ease;
}

.omni-project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 42px rgba(15, 23, 42, 0.16) !important;
}

.omni-project-card-top {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.omni-project-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    flex-shrink: 0;
}

.omni-project-card h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    color: #0f172a;
}

.omni-project-card span {
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
}

.omni-project-desc {
    color: #334155;
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 18px;
    flex: 1;
}

.omni-project-status {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.omni-badge {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.omni-badge.active {
    background: #dcfce7;
    color: #166534;
}

.omni-badge.disabled {
    background: #e5e7eb;
    color: #374151;
}

.omni-badge.maintenance {
    background: #fef3c7;
    color: #92400e;
}

.omni-project-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.omni-project-actions .btn,
.omni-project-actions button {
    width: 100%;
    border-radius: 12px;
}

.omni-project-actions form {
    grid-column: span 2;
    margin: 0;
}

.projects-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.projects-toolbar input,
.projects-toolbar select {
    max-width: 260px;
}

.projects-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.stat-card span {
    display: block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
}

.stat-card strong {
    font-size: 22px;
    font-weight: 900;
    color: #0f172a;
}

.project-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
}

.project-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
}

.project-modal iframe {
    width: 100%;
    height: 100%;
}

.project-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 26px;
    cursor: pointer;
}

.project-launch-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    z-index: 9999;
    padding: 32px;
}

.project-launch-box {
    position: relative;
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.project-launch-box iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.project-launch-close {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
}

.omni-recent-projects {
    margin-bottom: 34px;
}

.omni-section-header {
    margin: 28px 0 16px;
}

.omni-section-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
    color: #0f172a;
}

.omni-section-header p {
    margin: 5px 0 0;
    color: #64748b;
    font-size: 14px;
}

/* ================= RESPONSIVE TABLET ================= */
@media (max-width: 1100px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
    }

    .topbar-left,
    .topbar-center,
    .topbar-right {
        width: 100%;
        justify-content: center;
    }

    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ================= RESPONSIVE MOBILE ================= */
@media (max-width: 768px) {
    .app-shell {
        flex-direction: row;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        overflow-y: auto;
        z-index: 2000;
        transition: left .25s ease;
        box-shadow: 0 0 30px rgba(0,0,0,.35);
    }

    .sidebar.open {
        left: 0;
    }

    .app-main {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        padding-left: 70px;
    }

    .mobile-menu-btn {
        position: fixed;
        top: 14px;
        left: 14px;
        width: 46px;
        height: 46px;
        border: none;
        border-radius: 12px;
        background: var(--color-primary);
        color: #fff;
        font-size: 22px;
        z-index: 2100;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 10px 24px rgba(0,0,0,.25);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .table {
        display: block;
        overflow-x: auto;
    }

    .permission-grid {
        grid-template-columns: 1fr;
    }

    .omni-projects-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .omni-projects-grid {
        grid-template-columns: 1fr;
    }

    .omni-project-actions {
        grid-template-columns: 1fr;
    }

    .omni-project-actions form {
        grid-column: span 1;
    }

    .projects-toolbar {
        flex-direction: column;
    }

    .projects-toolbar input,
    .projects-toolbar select {
        max-width: 100%;
    }
}