*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #1a1a2e;
    background: #f0f2f5;
}

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: #1a1a2e;
    color: #fff;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    padding: 0 1.5rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.sidebar a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 0.6rem 1.5rem;
    display: block;
    transition: all 0.15s;
}

.sidebar a:hover,
.sidebar a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card h3 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card .value {
    font-size: 2rem;
    font-weight: 700;
}

.card .sub {
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.25rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #666;
}

tr:hover td {
    background: #f8f9fa;
}

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

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-free { background: #e8e8e8; color: #666; }
.badge-lite { background: #dbeafe; color: #1d4ed8; }
.badge-pro { background: #fef3c7; color: #92400e; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-expired { background: #e8e8e8; color: #666; }
.badge-refunded { background: #fce7f3; color: #9d174d; }

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.btn {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-primary {
    background: #1a1a2e;
    color: #fff;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #1a1a2e;
}

.login-box {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.login-box h1 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.error-message {
    color: #dc2626;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    cursor: pointer;
    transition: 0.2s;
}

.toggle .slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .slider {
    background: #16a34a;
}

.toggle input:checked + .slider::before {
    transform: translateX(20px);
}

tr.clickable {
    cursor: pointer;
}

/* Feedback page */
.feedback-detail-header h2 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
}

.feedback-detail-meta {
    font-size: 0.85rem;
    color: #888;
}

.feedback-detail-content {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.feedback-detail-content p {
    margin: 0;
    white-space: pre-wrap;
}

.feedback-replies {
    margin: 1rem 0;
}

.feedback-replies h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 0.75rem;
}

.feedback-reply {
    padding: 0.75rem 1rem;
    background: #eef6ff;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.feedback-reply-meta {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.25rem;
}

.feedback-reply p {
    margin: 0;
    white-space: pre-wrap;
}

.feedback-reply-form {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Table wrapper for horizontal scroll on mobile */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile header (hidden on desktop) */
.mobile-header {
    display: none;
}

/* Sidebar overlay (hidden on desktop) */
.sidebar-overlay {
    display: none;
}

/* Hamburger button */
.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #1a1a2e;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

/* ===== Mobile styles (≤768px) ===== */
@media (max-width: 768px) {
    /* Layout */
    .page {
        flex-direction: column;
    }

    .content {
        padding: 1rem;
        padding-top: 0;
    }

    /* Mobile header */
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 0;
        margin-bottom: 0.5rem;
        position: sticky;
        top: 0;
        background: #f0f2f5;
        z-index: 50;
    }

    .mobile-title {
        font-weight: 700;
        font-size: 1.1rem;
        color: #1a1a2e;
    }

    /* Sidebar — off-canvas drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
    }

    .menu-open .sidebar {
        transform: translateX(0);
    }

    /* Overlay behind drawer */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 199;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .menu-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    /* Hamburger animation when open */
    .menu-open .hamburger-btn span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    .menu-open .hamburger-btn span:nth-child(2) {
        opacity: 0;
    }
    .menu-open .hamburger-btn span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* Summary cards */
    .summary-cards {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .card {
        padding: 1rem;
    }

    .card .value {
        font-size: 1.5rem;
    }

    /* Tables — horizontal scroll */
    .table-wrapper {
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    table {
        min-width: 500px;
    }

    th, td {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Buttons — bigger touch targets */
    .btn {
        padding: 0.6rem 1.25rem;
        min-height: 44px;
    }

    .btn-sm {
        padding: 0.4rem 0.75rem;
        min-height: 36px;
    }

    /* Forms — stack vertically */
    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    /* Login page mobile adjustments */
    .login-box {
        margin: 1rem;
        padding: 1.5rem;
    }

    /* Details/summary on UserDetail */
    details summary {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}
