:root {
    --app-bg: #f5f7fb;
    --card-bg: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-muted: #94a3b8;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #ccfbf1;
    --accent-amber: #f59e0b;
    --text: #182235;
    --muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius-lg: 18px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

a {
    text-decoration: none;
}

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

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: 280px;
    padding: 24px 18px;
    background: var(--sidebar-bg);
    color: #ffffff;
    transform: translateX(0);
    transition: transform 0.2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.brand-mark,
.login-logo {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--accent), var(--accent-amber));
    color: #ffffff;
    font-weight: 800;
}

.brand-title {
    font-size: 17px;
    font-weight: 800;
}

.brand-subtitle {
    color: var(--sidebar-muted);
    font-size: 13px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 11px 13px;
    border-radius: 14px;
    color: #cbd5e1;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.11);
    color: #ffffff;
}

.sidebar-link.active {
    box-shadow: inset 3px 0 0 var(--accent-amber);
}

.app-main {
    width: 100%;
    min-width: 0;
    margin-left: 280px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 88px;
    padding: 18px 32px;
    background: rgba(245, 247, 251, 0.9);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.75);
}

.topbar-title h1,
.hero-panel h2,
.section-heading h3 {
    margin: 0;
    letter-spacing: 0;
}

.topbar-title h1 {
    font-size: 28px;
    font-weight: 800;
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-search {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    color: var(--muted);
}

.quick-search input {
    width: 100%;
    border: 0;
    outline: 0;
    color: var(--text);
}

.btn-accent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.22);
}

.btn-accent:hover {
    background: var(--accent-dark);
    color: #ffffff;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    font-weight: 700;
}

.logout-form {
    margin: 0;
}

.avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.app-content {
    padding: 28px 32px 18px;
}

.hero-panel,
.panel-card,
.stat-card {
    background: var(--card-bg);
    border: 1px solid rgba(229, 231, 235, 0.85);
    box-shadow: var(--shadow);
}

.hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px;
    border-radius: var(--radius-lg);
}

.hero-panel h2 {
    max-width: 760px;
    font-size: 30px;
    font-weight: 800;
}

.hero-panel p {
    max-width: 760px;
    margin: 10px 0 0;
    color: var(--muted);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 999px;
    background: #fff7ed;
    color: #b45309;
    font-weight: 800;
    white-space: nowrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 22px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius-md);
}

.stat-card p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.stat-card strong {
    font-size: 27px;
    font-weight: 800;
}

.stat-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    font-size: 22px;
}

.stat-icon.teal { background: #ccfbf1; color: #0f766e; }
.stat-icon.amber { background: #fef3c7; color: #b45309; }
.stat-icon.green { background: #dcfce7; color: #15803d; }
.stat-icon.slate { background: #e2e8f0; color: #334155; }
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.violet { background: #ede9fe; color: #6d28d9; }

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 18px;
    margin-top: 22px;
}

.users-grid {
    grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.25fr);
}

.client-view-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    gap: 18px;
}

.client-profile-card {
    grid-column: 1 / -1;
}

.panel-card {
    padding: 24px;
    border-radius: var(--radius-lg);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-heading h3 {
    font-size: 22px;
    font-weight: 800;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    font-weight: 700;
}

.quick-action:hover {
    border-color: rgba(15, 118, 110, 0.35);
    background: #f0fdfa;
    color: var(--accent-dark);
}

.dashboard-link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 22px;
}

.dashboard-link-card h3 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 800;
}

.dashboard-link-card p {
    margin: 0;
    color: var(--muted);
}

.timeline-list {
    display: grid;
    gap: 16px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: 12px;
}

.timeline-item > span {
    width: 12px;
    height: 12px;
    margin-top: 6px;
    border-radius: 50%;
    background: #cbd5e1;
}

.timeline-item.done > span {
    background: var(--accent);
}

.timeline-item strong {
    display: block;
    margin-bottom: 3px;
}

.timeline-item p {
    margin: 0;
    color: var(--muted);
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 32px 28px;
    color: var(--muted);
    font-size: 14px;
}

.auth-body {
    background:
        radial-gradient(circle at 20% 20%, rgba(15, 118, 110, 0.16), transparent 32%),
        radial-gradient(circle at 80% 10%, rgba(245, 158, 11, 0.18), transparent 28%),
        var(--app-bg);
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: min(100%, 430px);
    padding: 34px;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
    border-radius: 18px;
}

.login-card h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
}

.login-card p {
    margin: 8px 0 26px;
    color: var(--muted);
}

.login-form .form-control,
.login-form .input-group-text {
    min-height: 48px;
    border-color: var(--border);
}

.login-form .input-group-text {
    background: #f8fafc;
    color: var(--muted);
}

.admin-form .form-control,
.admin-form .form-select {
    min-height: 48px;
    border-color: var(--border);
    border-radius: 14px;
}

.user-table {
    margin-bottom: 0;
}

.user-table th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.role-badge {
    border-radius: 999px;
    padding: 7px 10px;
}

.role-badge.admin {
    background: #fef3c7;
    color: #92400e;
}

.role-badge.user {
    background: #ccfbf1;
    color: #115e59;
}

.blocked-badge {
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    padding: 7px 10px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(160px, 220px) minmax(140px, 190px) auto;
    gap: 12px;
    margin-bottom: 18px;
}

.catalog-filter {
    grid-template-columns: minmax(240px, 1fr) minmax(150px, 220px) auto;
}

.items-filter {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 210px) minmax(160px, 210px) minmax(160px, 210px) minmax(130px, 170px) auto;
}

.orders-filter,
.payments-filter {
    grid-template-columns: minmax(180px, 1fr) repeat(4, minmax(130px, 170px)) auto;
}

.filter-bar .form-control,
.filter-bar .form-select,
.form-split .form-control,
.form-split .form-select,
.admin-form textarea {
    min-height: 44px;
    border-color: var(--border);
    border-radius: 14px;
}

.form-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.catalog-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
}

.inline-edit summary {
    display: inline-flex;
    list-style: none;
    cursor: pointer;
}

.inline-edit summary::-webkit-details-marker {
    display: none;
}

.inline-edit-form {
    display: grid;
    gap: 10px;
    min-width: 280px;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
}

.quick-category-box {
    margin: -4px 0 18px;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    background: #f8fafc;
}

.stock-check {
    display: flex;
    align-items: center;
    min-height: 48px;
    gap: 8px;
}

.ajax-results {
    display: grid;
    gap: 8px;
    margin: -8px 0 18px;
}

.ajax-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    color: var(--text);
}

.ajax-result-item span {
    color: var(--muted);
    font-size: 13px;
}

.item-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.order-page {
    display: grid;
    gap: 18px;
}

.order-totals {
    margin-top: 0;
}

.order-widget {
    min-width: 0;
}

.order-inline-form {
    display: grid;
    gap: 12px;
}

.order-inline-form .form-control,
.order-inline-form .form-select {
    min-height: 44px;
    border-color: var(--border);
    border-radius: 14px;
}

.ajax-result-item {
    width: 100%;
    text-align: left;
}

.ajax-result-item button,
button.ajax-result-item {
    border: 1px solid var(--border);
}

.pagination-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
    color: var(--muted);
}

.page-pill {
    display: inline-flex;
    align-items: center;
    min-height: 31px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f8fafc;
    color: var(--text);
    font-weight: 700;
}

.client-summary,
.meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.client-summary > div,
.meta-grid > div {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f8fafc;
}

.client-summary span,
.meta-grid span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.client-summary strong,
.meta-grid strong {
    overflow-wrap: anywhere;
}

.client-comment {
    margin: 18px 0;
    padding: 16px;
    border-radius: 16px;
    background: #f8fafc;
}

.client-comment p {
    margin: 0;
}

.notes-widget {
    min-height: 360px;
}

.note-form textarea,
.note-edit textarea {
    border-color: var(--border);
    border-radius: 14px;
}

.notes-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.note-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f8fafc;
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
}

.note-meta strong {
    color: var(--text);
}

.note-text {
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.empty-notes {
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    color: var(--muted);
    text-align: center;
}

.app-alert {
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.muted-text {
    color: var(--muted);
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-radius: 50%;
    background: #cbd5e1;
}

.status-dot.active {
    background: var(--accent);
}

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .client-view-grid,
    .client-summary,
    .meta-grid,
    .filter-bar,
    .items-filter,
    .orders-filter,
    .payments-filter,
    .catalog-filter,
    .item-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

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

    .app-main {
        margin-left: 0;
    }

    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 16px 20px;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .quick-search {
        flex: 1 1 260px;
    }

    .app-content {
        padding: 22px 20px 14px;
    }
}

@media (max-width: 680px) {
    .hero-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-panel h2 {
        font-size: 24px;
    }

    .stats-grid,
    .quick-actions {
        grid-template-columns: 1fr;
    }

    .topbar-title h1 {
        font-size: 24px;
    }

    .user-pill {
        width: 100%;
        justify-content: center;
    }

    .btn-accent {
        flex: 1 1 auto;
    }

    .app-footer {
        flex-direction: column;
        padding-inline: 20px;
    }

    .form-split,
    .dashboard-link-card {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: flex-start;
    }
}
