/* =========================
   LAYOUT WRAPPER
========================= */

.panel-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    background: var(--bg);
}

/* =========================
   SIDEBAR (DESKTOP)
========================= */

.panel-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #0f172a 0%, #172554 100%);
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-sidebar::-webkit-scrollbar {
    width: 6px;
}

.panel-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}

/* =========================
   BRAND
========================= */

.brand-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
}

.brand-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.brand-subtitle {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

/* =========================
   USER SIDEBAR
========================= */

.sidebar-user {
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-top {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    flex-shrink: 0;
}

.user-name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.user-email {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
    word-break: break-word;
}

.user-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.user-meta-list {
    display: grid;
    gap: 6px;
}

.user-meta-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.84);
}

.user-meta-item span {
    flex: 0 0 auto;
}

.user-meta-item strong {
    color: #fff;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
    max-width: 60%;
}

/* =========================
   SIDEBAR LOGOUT AS MENU
========================= */

.sidebar-logout-form {
    margin: 0;
}

.panel-nav-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: rgba(255, 255, 255, 0.84);
    transition: 0.2s ease;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
}

.panel-nav-button:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
}

.panel-nav-button-logout {
    color: #fecaca;
}

.panel-nav-button-logout:hover {
    background: rgba(239, 68, 68, 0.16);
    color: #ffffff;
}

/* =========================
   NAVIGATION
========================= */

.panel-nav {
    display: grid;
    gap: 6px;
}

.panel-nav a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    transition: 0.2s ease;
}

.panel-nav a:hover {
    background: rgba(255, 255, 255, 0.10);
}

.panel-nav a.is-active {
    background: #fff;
    color: #0f172a;
}

/* =========================
   MAIN AREA
========================= */

.panel-main {
    padding: 24px;
    min-width: 0;
}

/* =========================
   MOBILE TOPBAR
========================= */

.mobile-topbar {
    display: none;
    margin-bottom: 16px;
}

.mobile-topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.mobile-brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.mobile-brand-text {
    min-width: 0;
}

.mobile-brand-text strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--text);
}

.mobile-brand-text span {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
    word-break: break-word;
}

/* =========================
   HAMBURGER BUTTON
========================= */

.mobile-menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* =========================
   MOBILE DROPDOWN MENU
========================= */

.management-mobile-menu {
    display: none;
    margin-bottom: 16px;
}

.management-mobile-menu.is-open {
    display: block;
}

.management-mobile-menu-inner {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.management-mobile-menu-inner a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--text);
    font-weight: 600;
    transition: 0.2s ease;
}

.management-mobile-menu-inner a:hover {
    background: #eef4ff;
    color: var(--primary);
}

.management-mobile-menu-inner a.is-active {
    background: var(--primary);
    color: #fff;
}

.management-mobile-logout-form {
    margin: 0;
}

.management-mobile-logout-btn {
    width: 100%;
}

/* =========================
   HEADER PANEL
========================= */

.panel-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px) auto;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.panel-heading h1 {
    margin: 0;
    font-size: 1.7rem;
    line-height: 1.2;
    color: var(--text);
}

.panel-heading p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.panel-header-profile {
    min-width: 0;
}

.panel-profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    min-width: 0;
}

.panel-profile-photo-wrap {
    position: relative;
    width: 54px;
    height: 54px;
    flex-shrink: 0;
}

.panel-profile-photo,
.panel-profile-avatar-fallback {
    width: 54px;
    height: 54px;
    border-radius: 50%;
}

.panel-profile-photo {
    object-fit: cover;
    display: block;
    background: #e2e8f0;
    border: 2px solid #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.10);
}

.panel-profile-photo.is-hidden {
    display: none;
}

.panel-profile-avatar-fallback {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}

.panel-profile-avatar-fallback.is-visible {
    display: inline-flex;
}

.panel-profile-info {
    min-width: 0;
}

.panel-profile-info strong,
.panel-profile-info span {
    display: block;
}

.panel-profile-info strong {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.4;
}

.panel-profile-info span {
    margin-top: 2px;
    font-size: 0.82rem;
    color: var(--muted);
    word-break: break-word;
}

.panel-profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.panel-badge-role {
    background: var(--primary-soft);
    color: var(--primary);
}

.panel-badge-status.is-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.panel-badge-status.is-inactive {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.panel-header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.desktop-logout-form {
    margin: 0;
}

.desktop-logout-btn {
    width: auto;
    min-width: 112px;
    padding: 0 18px;
}

/* =========================
   CONTENT
========================= */

.panel-content {
    width: 100%;
}

/* =========================
   MOBILE RESPONSIVE
========================= */

@media (max-width: 1024px) {
    .panel-shell {
        grid-template-columns: 1fr;
    }

    .panel-sidebar {
        display: none;
    }

    .panel-main {
        padding: 16px;
    }

    .mobile-topbar {
        display: block;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .panel-header {
        grid-template-columns: 1fr;
    }

    .panel-header-profile {
        order: 2;
    }

    .panel-header-actions {
        order: 3;
        justify-content: flex-start;
    }

    .desktop-logout-form {
        display: none;
    }
}

@media (max-width: 600px) {
    .panel-main {
        padding: 12px;
    }

    .mobile-topbar-inner {
        padding: 12px 14px;
    }

    .panel-heading h1 {
        font-size: 1.3rem;
    }

    .panel-heading p {
        font-size: 0.9rem;
    }

    .panel-profile-card {
        padding: 12px 14px;
    }

    .panel-profile-photo-wrap {
        width: 48px;
        height: 48px;
    }

    .panel-profile-photo,
    .panel-profile-avatar-fallback {
        width: 48px;
        height: 48px;
    }
}

/* =========================
   FORM FIX (TRANSACTIONS) - IMPROVED
========================= */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    line-height: 1.3;
}

/* INPUT BASE FIX */
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 0.9rem;
    color: var(--text);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

/* FIX: biar tidak “ngecil aneh” seperti di screenshot */
.form-group input[type="number"] {
    appearance: textfield;
}

/* TEXTAREA */
.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

/* FOCUS STATE */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

/* BUTTON FIX (biar konsisten & tidak gepeng di mobile) */
.lead-card-actions {
    flex-wrap: wrap;
    gap: 10px;
}

.lead-action-btn {
    min-height: 42px;
}

/* =========================
   MOBILE OPTIMIZATION (KRUSIAL)
========================= */

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* cegah zoom di Android */
    }
}

.form-helper-text {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: #6b7280;
}