:root {
    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-soft: #f8f8ff;
    --text: #1d1b2f;
    --muted: #7a7698;
    --line: #e6e5f2;
    --accent: #6b3ef0;
    --accent-soft: #ece5ff;
    --shadow: 0 18px 45px rgba(66, 49, 125, 0.08);
    --shadow-soft: 0 12px 24px rgba(89, 64, 170, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top right, #f1edff 0%, var(--bg) 45%, #f7f8fc 100%);
    color: var(--text);
}

.app-shell { display: grid; min-height: 100vh; }
.app-shell-authenticated { grid-template-columns: 192px minmax(0, 1fr); }
.app-shell-anonymous { grid-template-columns: 1fr; }

.sidebar {
    background: rgba(255, 255, 255, 0.9);
    border-right: 1px solid rgba(107, 62, 240, 0.08);
    backdrop-filter: blur(14px);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: grid; justify-items: start; gap: 8px; }
.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background: linear-gradient(145deg, var(--accent), #8a67f3);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.brand-title,
.brand-subtitle {
    margin: 0;
    text-align: left;
    line-height: 1.2;
}

.brand-title { font-size: 0.84rem; font-weight: 700; }
.brand-subtitle { font-size: 0.65rem; color: var(--muted); }

.sidebar nav {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    color: #5e5985;
    text-decoration: none;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
}

.nav-icon {
    width: 18px;
    height: 18px;
    text-align: center;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-icon-svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-label {
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--accent);
    background: rgba(107, 62, 240, 0.08);
}

.nav-link.active {
    color: #fff;
    background: linear-gradient(160deg, #6b3ef0, #8f70f6);
    box-shadow: var(--shadow-soft);
}

.sidebar-signout { margin-top: auto; }

.btn-glass {
    border: 1px solid rgba(107, 62, 240, 0.2);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.6);
    color: var(--accent);
    font-weight: 600;
    backdrop-filter: blur(10px);
}

.content { padding: 26px; }

.topbar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.topbar-eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 500;
}

.topbar-title {
    margin: 4px 0 0;
    font-size: 1.4rem;
    font-weight: 800;
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

.icon-action {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(107, 62, 240, 0.2);
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.95), rgba(239, 230, 255, 0.8));
    color: var(--accent);
    display: grid;
    place-items: center;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(87, 64, 158, 0.12);
}

.content-body { display: grid; gap: 18px; }

.panel,
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 20px 24px;
}

.page-tools {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.page-tools p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.btn,
.form-control,
.form-select { border-radius: 14px; }

.btn-dark {
    border: none;
    background: linear-gradient(135deg, #5f37df, #8b69f5);
}

.table-wrap {
    overflow: hidden;
    padding: 20px 24px;
}

.table { margin-bottom: 0; }
.table thead th {
    border-bottom: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody td {
    border-color: #efedf8;
    vertical-align: middle;
    font-weight: 500;
}

.table tbody tr {
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.table tbody tr[data-detail-row] { cursor: pointer; }


.section-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    padding: 12px;
}

.table tbody tr[data-edit-url] {
    cursor: pointer;
}

.table tbody tr[data-detail-row]:hover {
    background-color: #faf8ff;
    transform: translateX(2px);
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
}

.bento-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 30px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.bento-card h3 { margin-top: 0; font-size: 1rem; color: var(--muted); }
.bento-card .metric { font-size: 2rem; font-weight: 800; }

.bento-card.primary {
    background: linear-gradient(145deg, #ffffff 0%, #f1ebff 100%);
}

.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }

.progress-track {
    margin-top: 14px;
    height: 10px;
    border-radius: 999px;
    background: rgba(107, 62, 240, 0.1);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #6b3ef0, #9b7eff);
    box-shadow: 0 0 24px rgba(107, 62, 240, 0.45);
}

.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(24, 17, 54, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.detail-drawer {
    position: fixed;
    top: 16px;
    right: 16px;
    bottom: 16px;
    width: min(620px, calc(100vw - 28px));
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.52);
    background: rgba(255, 255, 255, 0.76);
    backdrop-filter: blur(18px);
    box-shadow: 0 26px 55px rgba(20, 15, 40, 0.26);
    padding: 20px;
    transform: translateX(108%);
    transition: transform 0.3s ease;
    z-index: 30;
}

.detail-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.password-eye-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    color: #1d4ed8;
}

.password-eye-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.password-eye-icon,
.password-eye-icon * {
    pointer-events: none;
}

.password-eye-icon.is-hidden {
    color: #1d4ed8;
}

.password-eye-icon.is-visible {
    color: #dc2626;
}

.detail-title { margin: 0; font-size: 1.2rem; }
.detail-subtitle { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }

.detail-form {
    margin-top: 16px;
    max-height: calc(100vh - 170px);
    overflow: auto;
    padding-right: 12px;
}

.drawer-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.detail-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: calc(100vh - 210px);
    overflow: auto;
}

.detail-grid div {
    background: rgba(240, 233, 255, 0.54);
    border: 1px solid rgba(107, 62, 240, 0.12);
    border-radius: 18px;
    padding: 12px 14px;
}

.detail-grid dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.detail-grid dd { margin: 4px 0 0; font-weight: 600; }


.product-features-panel .detail-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.feature-create-form,
.feature-inline-form {
    background: rgba(240, 233, 255, 0.4);
    border: 1px solid rgba(107, 62, 240, 0.16);
    border-radius: 14px;
    padding: 14px;
}

.feature-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feature-item {
    border: 1px solid rgba(107, 62, 240, 0.16);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.74);
}

.feature-item-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    cursor: pointer;
}

.feature-item-summary:focus-visible {
    outline: 2px solid rgba(107, 62, 240, 0.45);
    outline-offset: 1px;
}

.feature-item-text {
    flex: 1;
}

.feature-item-internal {
    font-size: 0.85rem;
    color: var(--muted);
}

.feature-item-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

.feature-item-status {
    min-width: 28px;
}

.status-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
}

.status-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.status-icon-active svg {
    stroke: #198754;
}

.status-icon-active svg circle {
    fill: rgba(25, 135, 84, 0.18);
}

.status-icon-inactive svg {
    stroke: #8b8f9c;
}

.status-icon-inactive svg circle {
    fill: rgba(139, 143, 156, 0.18);
}

.feature-item-actions {
    margin-left: auto;
}

.feature-delete-btn {
    color: #8b8f9c;
    padding: 0;
    border: 0;
    line-height: 0;
}

.feature-delete-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.feature-delete-btn:hover {
    color: #dc3545;
}

.feature-edit-panel {
    display: none !important;
    max-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    transition: max-height 220ms ease;
}

.feature-edit-panel > .feature-inline-form {
    margin: 0;
    padding: 0;
}

.feature-edit-panel.is-open {
    display: block !important;
    max-height: 1000px;
}

.feature-edit-panel.is-open > .feature-inline-form {
    margin: 0 10px 10px;
    padding: 14px;
}

.feature-edit-panel .form-label,
.feature-edit-panel .form-check-label {
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
}

.feature-edit-panel .feature-active-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 0 !important;
    padding-left: 0;
}

.feature-edit-panel .feature-active-row .form-check-input {
    margin: 0;
    position: static;
}

.feature-edit-panel .feature-active-row .form-check-label {
    margin-bottom: 0;
}

.detail-open .detail-overlay {
    opacity: 1;
    pointer-events: auto;
}

.detail-open .detail-drawer {
    transform: translateX(0);
}

@media (max-width: 1024px) {
    .app-shell-authenticated { grid-template-columns: 1fr; }
    .sidebar {
        flex-direction: row;
        align-items: center;
        padding: 10px;
        gap: 10px;
    }

    .sidebar nav {
        grid-auto-flow: column;
        overflow: auto;
        flex: 1;
    }

    .nav-link {
        justify-content: center;
        padding: 0 14px;
    }

    .sidebar-signout { margin-top: 0; }

    .bento-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .span-4, .span-6, .span-8 { grid-column: span 1; }
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
}

.confirm-modal.is-open {
    display: flex;
}

.confirm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(19, 16, 43, 0.48);
    backdrop-filter: blur(4px);
}

.confirm-modal-card {
    position: relative;
    background: #fff;
    border-radius: 20px;
    border: 1px solid rgba(107, 62, 240, 0.16);
    box-shadow: 0 25px 60px rgba(49, 34, 104, 0.25);
    width: min(92vw, 440px);
    padding: 24px;
}

.confirm-modal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.confirm-modal-message {
    margin: 10px 0 0;
    color: var(--muted);
}

.confirm-modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

body.confirm-open {
    overflow: hidden;
}

.detail-content {
    overflow-x: hidden;
}
