:root {
    --theme-name: 'base';
    --background-color: #f4f6fb;
    --bg-gradient: radial-gradient(circle at top left, rgba(96, 138, 255, 0.12), transparent 26%), radial-gradient(circle at 84% 8%, rgba(56, 189, 248, 0.1), transparent 22%), linear-gradient(180deg, #fdfdff 0%, #f4f6fb 100%);
    --surface-color: #ffffff;
    --surface-alt: #f7f9ff;
    --text-primary: #111827;
    --text-muted: #55606c;
    --primary-color: #1d4ed8;
    --primary-hover: #1e40af;
    --secondary-color: #0284c7;
    --border-color: rgba(148, 163, 184, 0.18);
    --link-color: #1d4ed8;
    --navbar-bg: rgba(255, 255, 255, 0.96);
    --footer-bg: rgba(249, 250, 253, 0.98);
    --shadow-color: rgba(15, 23, 42, 0.08);
    --accent-color: #fb923c;
    --radius: 20px;
    --font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --decor-1: radial-gradient(circle at 16% 10%, rgba(59, 130, 246, 0.14), transparent 70%);
    --decor-2: radial-gradient(circle at 86% 10%, rgba(56, 189, 248, 0.1), transparent 70%);
    --decor-3: linear-gradient(120deg, rgba(15, 23, 42, 0.05) 0%, rgba(255, 255, 255, 0) 62%);
    --pattern-opacity: 0.55;
    --page-max-width: 1160px;
    --page-max-width-wide: 1440px;
    --page-padding: clamp(18px, 2.4vw, 30px);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-gradient, var(--background-color));
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: 1.6;
    padding: 0;
    margin: 0;
    width: 100%;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
}

body::before {
    background-image: var(--decor-1), var(--decor-2), var(--decor-3);
    background-repeat: no-repeat;
    background-size: 60% 60%, 55% 55%, 100% 100%;
    background-position: 0% 0%, 100% 0%, 50% 50%;
    opacity: var(--pattern-opacity);
    animation: float-bg 16s ease-in-out infinite;
}

body::after {
    background-image: radial-gradient(600px 300px at 70% 120%, rgba(15, 23, 42, 0.08), transparent 70%);
    opacity: 0.6;
}

a {
    color: var(--link-color, var(--primary-color));
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-hover);
}

.navbar {
    background: rgba(247, 250, 255, 0.96);
    backdrop-filter: blur(18px);
    padding: 16px var(--page-padding);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
    animation: slide-down 0.35s ease-out;
}

.navbar form {
    display: inline-block;
}

.navbar select,
.navbar input[type="text"] {
    padding: 10px 14px;
    border: 1px solid rgba(148, 163, 184, 0.34);
    border-radius: 14px;
    background: var(--surface-color);
    color: var(--text-primary);
}

.navbar input[type="submit"] {
    padding: 10px 16px;
    border: none;
    border-radius: 14px;
    background-color: var(--secondary-color);
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.navbar input[type="submit"]:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 12px 25px rgba(37, 99, 235, 0.16);
}

.navbar .user-info {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: 8px;
    color: var(--text-muted);
}

.navbar a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 999px;
    color: var(--text-primary);
    margin-right: 10px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.navbar a:hover {
    color: var(--primary-hover);
    background: rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.container {
    width: min(var(--page-max-width), calc(100vw - (var(--page-padding) * 2)));
    margin: 28px auto;
    padding: clamp(20px, 2.3vw, 32px);
    background: var(--surface-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 22px 45px rgba(15, 23, 42, 0.08);
    animation: fade-in 0.4s ease-out;
}

.container .container {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
}

.content,
.page {
    width: 100%;
}

.content > :first-child,
.page > :first-child {
    margin-top: 0;
}

.page h1 {
    margin-top: 0;
    font-size: clamp(1.7rem, 3vw, 2.25rem);
}

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

.card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.08);
    padding: 24px;
    animation: pop-in 0.4s ease-out;
}

.auth-shell {
    max-width: 420px;
    margin: 10px auto;
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.card-title {
    font-size: clamp(1.4rem, 2.6vw, 1.95rem);
    margin: 0;
}

.card-subtitle {
    color: var(--text-muted);
    margin: 0;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 18px;
}

.app-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 20px 35px rgba(15, 23, 42, 0.06);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 45px rgba(15, 23, 42, 0.1);
}

.app-card .card-title {
    margin-bottom: 0;
}

.app-card .card-subtitle {
    color: var(--text-muted);
    font-size: 0.98rem;
}

.app-card-actions {
    margin-top: auto;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.helper-links {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-muted);
}

.table-container,
.products-table,
.categories-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 22px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.95);
}

th,
td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    padding: 14px 16px;
    text-align: left;
    vertical-align: top;
}

th {
    background-color: rgba(37, 99, 235, 0.95);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:nth-child(even) td {
    background: rgba(241, 244, 255, 0.8);
}

tr:hover td {
    background: rgba(37, 99, 235, 0.08);
}

button,
input[type="submit"],
input[type="button"] {
    border: none;
    background: var(--primary-color);
    color: #fff;
    padding: 12px 16px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.12);
    transition: transform 0.18s ease, background 0.22s ease, box-shadow 0.22s ease;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 18px 34px rgba(37, 99, 235, 0.16);
}

.btn-link,
a.btn-link {
    background: transparent;
    color: var(--primary-color);
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    text-decoration: underline;
}

.btn-link:hover,
a.btn-link:hover {
    color: var(--primary-hover);
}

.text-center {
    text-align: center;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-color);
    color: var(--text-primary);
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    margin: 14px 0;
}

.alert.alert-warning {
    background: #fff7ed;
    border-color: #fdba74;
}

.alert.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
}

.alert.alert-success {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}

.alert.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.hint {
    color: var(--text-muted);
    font-size: 14px;
}

.error-page {
    text-align: center;
    padding: 40px 0;
}

.error-page h1 {
    font-size: 40px;
    margin-bottom: 10px;
}

.footer{
    width: 100%;
    padding: 14px 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    text-align: center;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 700;
    cursor: pointer;
    background: var(--primary-color);
    color: #fff;
    text-decoration: none;
    transition: transform 0.16s ease, background 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    box-shadow: 0 18px 32px rgba(29, 78, 216, 0.14);
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 20px 36px rgba(29, 78, 216, 0.16);
}

.btn-sm {
    padding: 9px 14px;
    font-size: 0.92rem;
    border-radius: 999px;
    min-width: 96px;
}

.table-container a.btn-sm,
.table-container button.btn-sm,
.table-container a.btn {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.92rem;
    box-shadow: none;
}

.btn-secondary {
    background: #64748b;
    color: #fff;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

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

.btn-info {
    background: #0284c7;
    color: #fff;
}

.btn-secondary:hover,
.btn-warning:hover,
.btn-success:hover,
.btn-danger:hover,
.btn-info:hover {
    filter: brightness(1.06);
}

.btn-secondary {
    border-color: rgba(100, 116, 139, 0.32);
}

.btn-warning {
    border-color: rgba(245, 158, 11, 0.28);
}

.btn-success {
    border-color: rgba(22, 163, 74, 0.28);
}

.btn-danger {
    border-color: rgba(220, 38, 38, 0.28);
}

.btn-info {
    border-color: rgba(2, 132, 199, 0.28);
}

.btn-link,
a.btn-link {
    background: transparent;
    color: var(--primary-color);
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    text-decoration: underline;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.badge-success { background: #dcfce7; color: #166534; border-color: #86efac; }
.badge-warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-secondary { background: #e2e8f0; color: #334155; border-color: #cbd5e1; }
.badge-info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
    padding: 20px;
}

.modal.is-open {
    display: flex;
    animation: fade-in 0.2s ease-out;
}

.modal-content {
    width: min(560px, 96vw);
    background: var(--surface-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 24px 50px var(--shadow-color);
    overflow: hidden;
    animation: pop-in 0.25s ease-out;
}

.modal-content--xl {
    width: min(960px, 96vw);
}

.modal-body--frame {
    padding: 0;
}

.modal-frame {
    display: block;
    width: 100%;
    min-height: 72vh;
    border: 0;
    background: #fff;
}

.modal-header {
    padding: 16px 18px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border-color);
    position:relative;
}

.modal-title {
    margin: 0;
    font-size: 20px;
}

.modal-body {
    padding: 18px;
}

.modal-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: var(--surface-alt);
}

.modal-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    position:absolute;
    right: 6px;
    top: 6px;
}

.modal--warning .modal-header { background: #fef3c7; color: #92400e; }
.modal--danger .modal-header { background: #fee2e2; color: #991b1b; }
.modal--info .modal-header { background: #e0f2fe; color: #075985; }
.modal--warning .modal-body { color: #92400e; }
.modal--danger .modal-body { color: #991b1b; }
.modal--info .modal-body { color: #075985; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pop-in {
    from { opacity: 0; transform: scale(0.98) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slide-down {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes float-bg {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(12px); }
}

@media (max-width: 720px) {
    .navbar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .navbar a {
        margin-right: 8px;
    }

    .nav-links {
        width: 100%;
        justify-content: flex-start;
    }

    .navbar .user-info {
        margin-left: 0;
    }

    .container {
        padding: 16px;
        margin: 14px auto;
    }

    .helper-links {
        flex-direction: column;
        gap: 8px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions .btn,
    .form-actions button,
    .form-actions input[type="submit"],
    .form-actions input[type="button"] {
        width: 100%;
        justify-content: center;
    }

    .modal {
        padding: 12px;
    }

    .modal-content {
        width: 100%;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }

    .modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .table-container table,
    .products-table table,
    .categories-table table,
    table {
        min-width: 640px;
    }

    th, td {
        padding: 9px 10px;
    }

    .footer {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (min-width: 721px) and (max-width: 1199px) {
    .container {
        width: min(var(--page-max-width), calc(100vw - 40px));
    }
}

@media (min-width: 1200px) {
    .container {
        width: min(var(--page-max-width-wide), calc(100vw - 64px));
    }
}

@media (min-width: 1440px) {
    body {
        font-size: 17px;
    }

    .container {
        padding: 30px 34px;
    }
}
