:root {
    --bg: #f4f4f5;
    --panel: #ffffff;
    --ink: #18181b;
    --muted: #52525b;
    --line: #d4d4d8;
    --line-soft: #e4e4e7;
    --brand: #3b82f6;
    --brand-soft: #eff6ff;
    --brand-border: #60a5fa;
    --brand-hover: #2563eb;
    --danger: #b91c1c;
    --danger-hover: #7f1d1d;
}

html, body {
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
}

.app-shell {
    background: radial-gradient(circle at 0% 0%, #fafafa 0%, #f4f4f5 60%, #e4e4e7 100%);
}

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

.app-main {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
}

.app-sidebar-toggle {
    position: fixed;
    top: 0.9rem;
    right: 1rem;
    z-index: 70;
    border: 1px solid #bfdbfe;
    background: #f8fbff;
    color: #2563eb;
    border-radius: 0.85rem;
    width: 2.35rem;
    height: 2.35rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.12);
}

.app-sidebar {
    position: fixed;
    right: 1rem;
    top: 1rem;
    z-index: 60;
    width: 10rem;
    max-height: calc(100vh - 2rem);
    padding: 2.7rem 0.7rem 0.8rem;
    border-radius: 0.95rem;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.25s ease, opacity 0.22s ease;
    overflow-y: auto;
}

.app-sidebar.is-collapsed {
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
}

.app-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.46rem;
}

.app-sidebar-btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 0.72rem;
    padding: 0.58rem 0.52rem;
    background: transparent;
    color: #334155;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.app-sidebar .hidden {
    display: none !important;
}

.app-sidebar-btn:hover {
    background: #f8fbff;
    border-color: var(--brand-border);
    color: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.app-sidebar-btn.active {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: var(--brand-border);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.app-sidebar-btn-danger:hover {
    border-color: #f9a8d4;
    color: #be123c;
    box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.18);
}

.app-sidebar-submenu {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: -0.12rem;
    padding-left: 0.3rem;
}

.app-sidebar-subbtn {
    border: 1px solid transparent;
    border-radius: 0.62rem;
    background: transparent;
    color: #6b7280;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.34rem 0.38rem;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.app-sidebar-subbtn:hover {
    background: #f8fbff;
    border-color: var(--brand-border);
    color: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.app-sidebar-subbtn.active {
    background: #eff6ff;
    border-color: var(--brand-border);
    color: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.app-panel {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 0.9rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

.ui-btn {
    display: inline-block;
    border-radius: 0.7rem;
    border: 1px solid var(--brand-border);
    background: var(--brand-soft);
    color: #1e3a8a;
    padding: 0.5rem 0.76rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ui-btn:hover {
    background: #dbeafe;
    border-color: var(--brand-hover);
    color: #1d4ed8;
}

.ui-btn-secondary {
    background: #ffffff;
    color: #1e3a8a;
    border-color: #93c5fd;
}

.ui-btn-secondary:hover {
    background: #f8fbff;
    border-color: var(--brand-hover);
}

.ui-btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.ui-btn-danger:hover {
    background: #fecaca;
    border-color: #f87171;
    color: #7f1d1d;
}

.ui-btn:disabled,
.ui-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-soft {
    border: 1px solid #93c5fd;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 0.7rem;
    font-weight: 600;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-soft:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.14);
}

.btn-soft-success {
    border-color: #86efac;
    background: #dcfce7;
    color: #166534;
}

.btn-soft-success:hover {
    background: #bbf7d0;
    border-color: #4ade80;
    color: #166534;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.18);
}

.btn-soft-danger {
    border-color: #fda4af;
    background: #ffe4e6;
    color: #9f1239;
}

.btn-soft-danger:hover {
    background: #fecdd3;
    border-color: #fb7185;
    color: #9f1239;
    box-shadow: 0 0 0 2px rgba(251, 113, 133, 0.18);
}

.btn-soft-secondary {
    border-color: #cbd5e1;
    background: #f8fafc;
    color: #334155;
}

.btn-soft-secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.16);
}

.btn-soft:disabled,
.btn-soft[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn {
    display: inline-block;
    border: 1px solid var(--brand-border);
    background: #ffffff;
    color: #1e3a8a;
    border-radius: 0.7rem;
    padding: 0.5rem 0.76rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pagination-btn:hover {
    background: #eff6ff;
    border-color: var(--brand-hover);
}

nav[aria-label="Pagination"] .pagination-btn {
    border-radius: 0;
}

nav[aria-label="Pagination"] .pagination-btn:first-child {
    border-top-left-radius: 0.7rem;
    border-bottom-left-radius: 0.7rem;
}

nav[aria-label="Pagination"] .pagination-btn:last-child {
    border-top-right-radius: 0.7rem;
    border-bottom-right-radius: 0.7rem;
}

.pagination-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Grouped action button row (e.g. user table actions) */
.action-group {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.action-group .pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    margin-left: -1px;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    min-height: 2rem;
    line-height: 1;
}

.action-group .pagination-btn:first-child {
    border-top-left-radius: 0.7rem;
    border-bottom-left-radius: 0.7rem;
    margin-left: 0;
}

.action-group .pagination-btn:last-child {
    border-top-right-radius: 0.7rem;
    border-bottom-right-radius: 0.7rem;
}

.pagination-btn-danger {
    color: #dc2626;
    border-color: #fca5a5;
}

.pagination-btn-danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.filters-shell {
    margin-bottom: 1.5rem;
}

.collapse-panel {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.28s ease, opacity 0.22s ease;
}

.collapse-panel.is-open {
    max-height: 1200px;
    opacity: 1;
}

.app-footer {
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.85rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 100%);
    border-top: 1px solid #c7d2fe;
}

.app-toast-region {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-width: min(26rem, calc(100vw - 2rem));
}

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(255, 255, 255, 0.97);
    color: #0f172a;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
}

.app-toast::before {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    min-width: 1.35rem;
    font-size: 0.95rem;
    line-height: 1;
}

.app-toast-info::before {
    content: "\2139";
    color: #2563eb;
}

.app-toast-success::before {
    content: "\2713";
    color: #15803d;
}

.app-toast-warning::before {
    content: "!";
    color: #b45309;
    font-weight: 900;
}

.app-toast-error::before {
    content: "\00D7";
    color: #b91c1c;
    font-weight: 900;
}

.app-toast-message {
    flex: 1;
    font-size: 0.87rem;
    line-height: 1.45;
}

.app-toast-close {
    border: 0;
    background: transparent;
    color: #64748b;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 900px) {
    .app-main {
        padding: 4rem 0.9rem 1rem;
    }

    .app-shell input,
    .app-shell select,
    .app-shell textarea {
        font-size: 16px;
    }

    .app-shell .app-panel {
        border-radius: 0.8rem;
    }

    .app-shell .filters-shell {
        margin-bottom: 1rem;
    }

    .app-sidebar {
        left: auto;
        right: 0;
        top: 0;
        bottom: 0;
        margin: 0;
        border-radius: 0;
        width: min(10rem, 43vw);
        max-height: 100vh;
        padding-top: 2.9rem;
    }

    .app-toast-region {
        left: 0.75rem;
        bottom: 0.75rem;
    }
}
