* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft Yahei", sans-serif;
    background: #eef2ff;
    color: #0f172a;
}

body,
.card,
.table,
.topbar,
.sidebar,
.modal,
.btn,
.input,
.textarea,
.select {
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-root {
    min-height: 100vh;
}

.layout {
    display: flex;
    min-height: 100vh;
    height: 100vh;
}

.sidebar {
    width: 240px;
    background: linear-gradient(160deg, #0f172a, #1e293b);
    color: #e5e7eb;
    padding: 24px 16px;
    transition: width 0.2s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 72px;
    padding: 20px 10px;
}

.sidebar h1 {
    font-size: 18px;
    margin: 0 0 24px;
    letter-spacing: 0.5px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 18px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    border-radius: 10px;
    padding: 6px 8px;
    cursor: pointer;
}

.sidebar.collapsed h1 {
    display: none;
}

.nav-item {
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.nav-item.active {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.3);
}

.nav-label {
    display: inline;
}

.nav-short {
    display: none;
    font-weight: 600;
}

.nav-icon {
    margin-right: 8px;
}

.nav-short .nav-icon {
    margin-right: 0;
}

.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar.collapsed .nav-short {
    display: inline;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 8px;
}

.content {
    flex: 1;
    padding: 28px 32px;
    background: #f8fafc;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: #fff;
    padding: 14px 18px;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-only {
    display: none;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.card {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    border: 1px solid #e2e8f0;
}

.card h3 {
    margin: 0 0 8px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.table th,
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    font-size: 14px;
}

.table th {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
}

.table .btn {
    margin-right: 6px;
    margin-bottom: 4px;
}

.pagination {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.pagination .btn {
    margin-right: 6px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.btn {
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.btn .icon {
    margin-right: 6px;
}

.notfound-card {
    max-width: 420px;
    text-align: center;
}

.notfound-title {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #0f172a;
}

.notfound-actions {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.filter-row {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 13px;
    color: #64748b;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
}

.logout-btn {
    width: 100%;
    background: rgba(239, 68, 68, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fee2e2;
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
}

.sidebar.collapsed .logout-btn .nav-label {
    display: none;
}

.sidebar.collapsed .logout-btn .nav-short {
    display: inline;
}

.sidebar.collapsed .logout-btn {
    justify-content: center;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 250;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: #cbd5f5;
    color: #1f2937;
}

.btn-ghost {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #1f2937;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.input,
.textarea,
.select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #cbd5f5;
    font-size: 14px;
    background: #fff;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.textarea {
    min-height: 90px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.form-row-2 {
    grid-template-columns: 1fr 2fr;
}

.form-row-3 {
    grid-template-columns: 1fr 2fr 2fr;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #374151;
}

.inline-row {
    display: grid;
    grid-template-columns: 2fr 2fr auto;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 200;
}

.modal {
    width: min(760px, 96vw);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
    padding: 20px 22px;
    max-height: 90vh;
    overflow: auto;
}

@media (max-width: 900px) {
    .sidebar {
        width: 72px;
        padding: 20px 10px;
    }

    .sidebar h1 {
        display: none;
    }

    .sidebar .nav-label {
        display: none;
    }

    .sidebar .nav-short {
        display: inline;
    }

    .sidebar .nav-item {
        justify-content: center;
    }

    .content {
        padding: 20px 18px;
    }
}

@media (max-width: 768px) {
    .layout {
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(80vw, 280px);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 300;
        padding: 22px 16px;
    }

    .sidebar .nav-label {
        display: inline;
    }

    .sidebar .nav-short {
        display: none;
    }

    .sidebar .nav-item {
        justify-content: flex-start;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: min(80vw, 280px);
        padding: 22px 16px;
    }

    .sidebar.collapsed h1 {
        display: block;
    }

    .sidebar.collapsed .nav-label {
        display: inline;
    }

    .sidebar.collapsed .nav-short {
        display: none;
    }

    .sidebar.collapsed .nav-item {
        justify-content: flex-start;
        padding: 10px 12px;
    }

    .mobile-only {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .content {
        padding: 16px 14px;
    }

    .form-row,
    .form-row-2,
    .form-row-3,
    .filter-row,
    .inline-row,
    .rule-row {
        grid-template-columns: 1fr;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .login-card {
        width: min(92vw, 360px);
        padding: 20px;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-body {
    margin-top: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.form-section-title {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    background: #fff;
}

.rule-row {
    grid-template-columns: 1fr 2fr 1fr;
}

.rule-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.rule-item {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin-top: 12px;
    background: #f9fafb;
}

.rule-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.rule-item-actions {
    display: flex;
    gap: 6px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5f5;
    transition: 0.2s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.2s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: #2563eb;
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 360px;
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.login-card h2 {
    margin-top: 0;
}

.muted {
    color: #6b7280;
    font-size: 13px;
}

.status {
    margin-top: 12px;
    font-size: 13px;
}
