:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.1);
    --shadow-md: 0 10px 25px -15px rgba(15, 23, 42, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "DM Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1:focus,
h2:focus,
h3:focus,
h4:focus,
h5:focus,
h6:focus,
p:focus,
span:focus,
div:focus,
section:focus,
main:focus,
[tabindex="-1"]:focus,
.page-header:focus,
.content-area:focus {
    outline: none !important;
    box-shadow: none !important;
}

h1 {
    margin-bottom: 0.5rem;
    font-size: clamp(1.75rem, 2vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.03em;
}

h2 {
    margin-bottom: 0.25rem;
    font-size: 1.125rem;
    font-weight: 700;
}

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

.sidebar {
    position: sticky;
    top: 0;
    width: 260px;
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-logo-img {
    height: 38px;
    width: auto;
    max-width: 100%;
    display: block;
    object-fit: contain;
}

.login-logo-img {
    height: 52px;
    width: auto;
    max-width: 100%;
    display: block;
    margin: 0 auto 0.75rem auto;
    object-fit: contain;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 0.875rem;
    font-weight: 800;
}

.nav-menu {
    flex: 1;
    padding: 1.25rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title,
.eyebrow {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-section-title {
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    border-left: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 700;
}

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

.nav-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    color: var(--primary);
}

.main-content {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.875rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.search-bar {
    width: min(100%, 460px);
}

.search-input {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.search-input:focus,
.form-input:focus,
.tenant-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background-color: var(--bg-primary);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.tenant-switcher,
.language-switcher,
.tenant-label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.tenant-switcher {
    min-width: 180px;
}

.tenant-select-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.language-switcher {
    min-width: 96px;
}

.tenant-switcher-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tenant-select {
    height: 38px;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.tenant-select-wrapper .tenant-select {
    padding-right: 2.2rem;
}

.tenant-select.is-loading {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    opacity: 0.85;
    cursor: wait;
}

.tenant-select.is-success {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.tenant-switcher-spinner {
    position: absolute;
    right: 0.65rem;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(37, 99, 235, 0.25);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: tenant-spin 0.65s linear infinite;
    pointer-events: none;
}

.tenant-switcher-success {
    position: absolute;
    right: 0.65rem;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--success);
    animation: tenant-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

@keyframes tenant-spin {
    to { transform: rotate(360deg); }
}

@keyframes tenant-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Slim Top Progress Bar */
.top-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(37, 99, 235, 0.15);
    z-index: 9999;
    overflow: hidden;
}

.top-progress-bar-indicator {
    height: 100%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary), 0 0 5px var(--primary);
    animation: top-bar-indeterminate 1.4s ease-in-out infinite;
}

@keyframes top-bar-indeterminate {
    0% {
        transform: translateX(-100%) scaleX(0.2);
    }
    50% {
        transform: translateX(30%) scaleX(0.7);
    }
    100% {
        transform: translateX(110%) scaleX(0.2);
    }
}

.tenant-select.lang-select {
    min-width: 96px;
}

.language-flags {
    display: flex;
    gap: 0.4rem;
}

.language-flag-button {
    min-height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
}

.language-flag-button.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.tenant-label {
    padding: 0.2rem 0;
}

.tenant-label strong {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

.icon-button {
    position: relative;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.icon-button:hover {
    background: var(--bg-secondary);
    border-color: #cbd5e1;
    color: var(--text-primary);
    transform: translateY(-1px);
}

.notification-badge {
    position: absolute;
    top: -0.3rem;
    right: -0.3rem;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    box-shadow: 0 0 0 2px #fff;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.5rem 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
    transition: border-color 0.15s ease;
}

.user-menu:hover {
    border-color: #cbd5e1;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.user-summary {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.user-summary span {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.user-summary small {
    max-width: 170px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.logout-button:hover {
    background: var(--bg-secondary);
    color: var(--danger);
}

.content-area {
    flex: 1;
    padding: 2rem;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.page-header p {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--text-secondary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    color: #fff;
    transform: translateY(-1px);
}

.btn-secondary {
    border-color: var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.btn.btn-secondary:hover,
.btn.btn-secondary:focus-visible {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

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

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card,
.card,
.table-container {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-primary);
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05);
}

.stat-card {
    position: relative;
    padding: 1.5rem;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background 0.2s ease;
}

.stat-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 10px 25px -12px rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
}

.stat-card:hover::before {
    background: var(--primary);
}

.stat-label {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.stat-value {
    font-size: 2.125rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.warning {
    color: var(--warning);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.card-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-header p {
    margin: 0.2rem 0 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.activity-list,
.health-list {
    padding: 1.5rem;
}

.activity-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 10px;
    background: var(--bg-secondary);
}

.activity-item + .activity-item {
    margin-top: 0.75rem;
}

.activity-item strong,
.activity-item span {
    display: block;
}

.activity-item span:not(.badge) {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.activity-icon,
.product-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 800;
}

.activity-icon.blue {
    background: var(--primary);
}

.activity-icon.green {
    background: var(--success);
}

.activity-icon.purple {
    background: #7c3aed;
}

.badge {
    width: max-content;
    padding: 0.25rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.725rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-success {
    border-color: rgba(16, 185, 129, 0.2);
    background: #ecfdf5;
    color: #047857;
}

.badge-warning {
    border-color: rgba(245, 158, 11, 0.2);
    background: #fffbeb;
    color: #b45309;
}

.badge-info {
    border-color: rgba(37, 99, 235, 0.2);
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-danger {
    border-color: rgba(239, 68, 68, 0.2);
    background: #fef2f2;
    color: #b91c1c;
}

.table-container {
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

th,
td {
    padding: 0.875rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

tbody tr {
    transition: background-color 0.12s ease;
}

tbody tr:hover {
    background-color: #f8fafc;
}

td code,
.tech-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8125rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.product-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
}

.product-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--bg-tertiary);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 36rem),
        linear-gradient(135deg, #eff6ff 0%, #f8fafc 45%, #ffffff 100%);
}

.login-card {
    width: min(100%, 480px);
    padding: 2rem;
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 24px 70px -36px rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(16px);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.75rem 0 0 0;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.login-intro,
.login-note {
    color: var(--text-secondary);
}

.login-form {
    display: grid;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.login-form label {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 800;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-error {
    color: var(--danger);
    font-size: 0.875rem;
    font-weight: 700;
}

.form-info {
    color: var(--success);
    font-size: 0.875rem;
    font-weight: 700;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.login-submit {
    margin-top: 0.5rem;
    width: 100%;
}

.login-language-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light, #e2e8f0);
}

.login-language-icon {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    line-height: 1;
}

.login-language-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.login-language-select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-language-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.prefill-panel {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.prefill-buttons {
    display: grid;
    gap: 0.5rem;
}

.prefill-button {
    justify-content: flex-start;
}

.system-card {
    max-width: 780px;
}

.users-tenant-card {
    margin-bottom: 1rem;
}

.management-record-list {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.management-record {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-primary);
    box-shadow: 0 8px 24px -20px rgba(15, 23, 42, 0.65);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.management-record:hover {
    border-color: #bfdbfe;
    box-shadow: 0 14px 30px -22px rgba(37, 99, 235, 0.55);
}

.management-record-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 1rem 1.25rem;
    padding: 1.25rem;
}

.management-record-field {
    min-width: 0;
}

.management-record-field-wide {
    grid-column: span 2;
}

.management-record-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.2;
    text-transform: uppercase;
}

.management-record-value {
    display: block;
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 650;
}

.management-record-title {
    font-size: 1rem;
    font-weight: 800;
}

.management-record-field .form-select {
    width: 100%;
    min-width: 0;
}

.management-record-logo input[type="file"] {
    width: 100%;
    max-width: 16rem;
    font-size: 0.75rem;
}

.client-logo-preview {
    display: block;
    max-width: 120px;
    max-height: 52px;
    margin-bottom: 0.5rem;
}

.management-record-metric .management-record-value {
    color: var(--primary);
    font-size: 1.15rem;
    font-weight: 800;
}

.management-permissions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    font-size: 0.875rem;
}

.management-permissions label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.management-record-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

.management-record-message {
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--border);
    background: #eff6ff;
    color: #1e40af;
}

.management-record-edit {
    max-width: none;
    border-top: 1px solid var(--border);
    border-bottom: 0;
    background: #f8fafc;
}

.client-create-form {
    max-width: 720px;
    padding: 1rem 1.5rem;
}

.client-create-grid {
    grid-template-columns: minmax(280px, 1fr) minmax(160px, 0.55fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.clients-header-actions,
.client-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.client-actions {
    gap: 0.5rem;
}

.client-actions .btn {
    width: auto;
    padding-inline: 0.75rem;
}

@media (max-width: 700px) {
    .management-record-list {
        padding: 0.75rem;
    }

    .management-record-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .management-record-field-wide {
        grid-column: auto;
    }

    .management-record-actions {
        padding: 0.75rem 1rem;
    }

    .management-record-actions .btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .client-create-grid {
        grid-template-columns: 1fr;
    }

    .clients-header-actions,
    .client-form-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .clients-header-actions .btn,
    .client-form-actions .btn {
        width: 100%;
    }
}

.users-page-header {
    margin-bottom: 1rem;
}

.users-tenant-header {
    padding: 0.75rem 1rem;
}

.users-tenant-header h2 {
    margin-bottom: 0.125rem;
    font-size: 1.125rem;
}

.users-tenant-header .btn,
.users-create-actions .btn,
.users-row-actions .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.users-create-form {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.management-record-edit.client-create-form,
.management-record-edit.users-create-form {
    max-width: none;
    border-bottom: 0;
}

.users-create-grid {
    grid-template-columns: minmax(220px, 1.5fr) minmax(160px, 1fr) minmax(120px, 0.6fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.users-create-grid .form-field label {
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
}

.users-create-grid .form-control,
.users-create-grid .form-select {
    padding: 0.375rem 0.5rem;
    min-height: 2rem;
}

.users-create-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.users-create-message {
    margin-top: 0.375rem;
}

.users-row-actions {
    gap: 0.5rem;
}

.users-row-actions .btn,
.users-row-actions .btn + .btn {
    width: auto;
    margin-left: 0;
}

@media (max-width: 900px) {
    .users-create-grid {
        grid-template-columns: 1fr;
    }

    .users-tenant-header {
        align-items: stretch;
        flex-direction: column;
    }

    .users-tenant-header .btn {
        width: 100%;
    }
}

.products-search-card {
    margin-bottom: 1rem;
    padding: 1rem;
}

.products-search-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
}

.audit-filter-card {
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
}

.audit-filter-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.audit-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.audit-filter-field label {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.audit-filter-field .form-input {
    height: 38px;
    padding: 0.375rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
}

.audit-filter-field.search-field {
    flex: 1;
    min-width: 220px;
}

.audit-filter-field.tenant-field {
    width: 220px;
}

.audit-filter-field.date-field {
    width: 170px;
}

.audit-filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1px;
}

.audit-filter-actions .btn {
    height: 38px;
    padding: 0 1.25rem;
    font-size: 0.875rem;
}

/* Audit Analytics & Activity Chart */
.audit-analytics-card {
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
}

.audit-analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.audit-analytics-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audit-analytics-header p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0.15rem 0 0 0;
}

.audit-categories-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.audit-category-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    user-select: none;
}

.audit-category-chip:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    background: rgba(37, 99, 235, 0.04);
}

.audit-category-chip.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 0 0 1px var(--primary);
}

.audit-category-chip .chip-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.audit-category-chip .chip-count {
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.audit-category-chip.active .chip-count {
    background: var(--primary);
    color: #fff;
}

.cat-dot-all { background: #64748b; }
.cat-dot-product { background: #2563eb; }
.cat-dot-auth { background: #10b981; }
.cat-dot-user { background: #a855f7; }
.cat-dot-client { background: #f59e0b; }
.cat-dot-asset { background: #06b6d4; }
.cat-dot-other { background: #94a3b8; }

.audit-chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem 0.75rem 1.25rem;
}

.audit-chart-legend {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border);
}

.audit-chart-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: center;
}

.audit-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.audit-chart-bars-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
    padding-top: 15px;
    overflow-x: auto;
}

.audit-chart-col {
    flex: 1;
    min-width: 28px;
    max-width: 56px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px;
    transition: background 0.15s ease-in-out;
    position: relative;
    user-select: none;
}

.audit-chart-col:hover {
    background: rgba(37, 99, 235, 0.08);
}

.audit-chart-col.selected-day {
    background: rgba(37, 99, 235, 0.15);
    outline: 2px solid var(--primary);
}

.audit-col-count {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.audit-col-bar-body {
    width: 100%;
    max-width: 24px;
    border-radius: 3px 3px 0 0;
    display: flex;
    flex-direction: column-reverse;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.15);
}

.bar-seg {
    width: 100%;
    transition: height 0.2s ease-in-out;
}

.bar-seg-product { background: #2563eb; }
.bar-seg-auth { background: #10b981; }
.bar-seg-user { background: #a855f7; }
.bar-seg-client { background: #f59e0b; }
.bar-seg-asset { background: #06b6d4; }
.bar-seg-other { background: #94a3b8; }

.audit-col-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
}

.audit-chart-filter-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.85rem;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--primary);
    margin-top: 0.75rem;
}

.audit-badge-purple {
    border-color: rgba(168, 85, 247, 0.2);
    background: #faf5ff;
    color: #7e22ce;
}

.audit-badge-client {
    border-color: rgba(245, 158, 11, 0.2);
    background: #fffbeb;
    color: #b45309;
}

.audit-badge-asset {
    border-color: rgba(6, 182, 212, 0.2);
    background: #ecfeff;
    color: #0e7490;
}

.audit-badge-neutral {
    border-color: rgba(100, 116, 139, 0.2);
    background: #f8fafc;
    color: #475569;
}

.products-paging {
    padding: 1rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.products-page-picker .form-input {
    width: auto;
}

.products-page-status {
    white-space: nowrap;
}

.products-page-jump {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.products-page-jump label {
    white-space: nowrap;
}

.products-page-jump .form-input {
    width: 5rem;
}

/* ── Product detail header ─────────────────────────────────────── */

.pd-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.75rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding: 1.75rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-primary);
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05);
}

.pd-header-icon {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.pd-product-image-panel {
    width: 150px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.pd-product-image-panel .pd-header-icon {
    width: 130px;
    height: 130px;
}

.pd-product-image {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.pd-product-image-panel input[type="file"] {
    max-width: 150px;
    font-size: 0.75rem;
}

.pd-header-body {
    min-width: 0;
}

.pd-title {
    margin-bottom: 0.25rem;
    font-size: clamp(1.4rem, 2.2vw, 1.85rem);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.pd-description {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.pd-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.85rem 1.25rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.pd-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.pd-meta-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pd-meta-value {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 700;
}

.pd-meta-value.tech-id {
    display: inline-block;
    width: fit-content;
}

.pd-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
}

.pd-qr img {
    width: 130px;
    height: 130px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.pd-qr small {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pd-public-link {
    white-space: nowrap;
    font-size: 0.8125rem;
    padding: 0.45rem 0.85rem;
}

/* ── Product detail tabs + L2 card grid ────────────────────────── */

.pd-tabs-container {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.pd-tab-bar {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1.25rem 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    overflow-x: auto;
    scrollbar-width: none;
}

.pd-tab {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding: 0.75rem 1.15rem;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.pd-tab:hover {
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.03);
}

.pd-tab.active {
    color: var(--primary);
    background: var(--bg-primary);
    border-bottom: 2px solid var(--primary);
    font-weight: 700;
    box-shadow: 0 -1px 2px rgba(15, 23, 42, 0.03);
}

.pd-tab-content {
    padding: 1.5rem;
    animation: tab-in 0.15s ease;
}

.pd-l2-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.pd-l2-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-primary);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pd-l2-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.pd-l2-card-wide {
    grid-column: 1 / -1;
}

.pd-l2-title {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

.pd-l2-card .l3-row {
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.pd-l2-card .l3-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.product-metric-layout {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(300px, 1.2fr);
    align-items: center;
    gap: 2rem;
}

.product-metric-chart-panel {
    display: grid;
    justify-items: center;
    gap: 1rem;
}

.product-pie-chart {
    width: min(230px, 70vw);
    aspect-ratio: 1;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--border), 0 12px 28px rgba(15, 23, 42, 0.08);
}

.product-metric-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem 1rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.product-metric-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.product-metric-legend i {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
}

.product-metric-values .l3-row:first-child .l3-label,
.product-metric-values .l3-row:first-child .l3-value {
    color: var(--text-primary);
    font-weight: 800;
}

.product-certification-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
}

.product-certification-list span {
    padding: 0.2rem 0.6rem;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.08);
    color: #047857;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

@media (max-width: 760px) {
    .product-metric-layout {
        grid-template-columns: 1fr;
    }
}

/* ── Operational accordion ─────────────────────────────────────── */

.pd-ops-accordion {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-primary);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

.pd-ops-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    border: 0;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: left;
}

.pd-ops-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.pd-ops-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pd-ops-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.2s ease, background 0.15s ease;
    color: var(--text-muted);
}

.pd-ops-chevron.open {
    transform: rotate(180deg);
}

.pd-ops-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.pd-ops-badge.error {
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
}

.pd-ops-badge.warning {
    border: 1px solid rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.08);
    color: var(--warning);
}

.pd-ops-body {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    animation: accordion-open 0.18s ease;
}

.mt-3 {
    margin-top: 0.75rem;
}

.product-version-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.product-version-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.product-version-meta,
.product-version-status {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-top: 0.15rem;
}

.product-version-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 0.5rem;
    width: min(100%, 660px);
}

.product-version-button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.product-version-button small {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
}

.product-version-button:hover {
    border-color: #cbd5e1;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.product-version-button.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    font-weight: 700;
}

.product-version-button.active small {
    color: var(--primary-dark);
}

.product-integrity-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.25rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: 10px;
    background: var(--bg-primary);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.product-integrity-panel.verified {
    border-left-color: var(--success);
}

.product-integrity-panel.warning {
    border-left-color: var(--warning);
}

.product-integrity-panel.failed {
    border-left-color: var(--danger);
}

.product-integrity-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.product-integrity-meta {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-top: 0.15rem;
}

.product-integrity-counts {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.product-integrity-counts span {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.product-anchor-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.25rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: 10px;
    background: var(--bg-primary);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.product-anchor-panel.verified {
    border-left-color: var(--success);
}

.product-anchor-panel.warning {
    border-left-color: var(--warning);
}

.product-anchor-panel.failed {
    border-left-color: var(--danger);
}

.product-anchor-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.product-anchor-meta {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-top: 0.15rem;
}

.product-anchor-status span {
    display: inline-block;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.l1-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.l1-tab {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
}

.l1-tab.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.tab-content {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    padding: 0.9rem;
}

.l2-section + .l2-section {
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.l2-title {
    margin: 0 0 0.65rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.l3-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1.25rem;
    padding: 0.45rem 0;
    font-size: 0.875rem;
}

.l3-row.changed {
    margin: 0.25rem -0.5rem;
    padding: 0.5rem;
    border-left: 3px solid var(--warning);
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.08);
}

.l3-label {
    flex: 1 1 45%;
    min-width: 0;
    color: var(--text-secondary);
    font-weight: 500;
}

.l3-value {
    flex: 1 1 55%;
    min-width: 0;
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

.l3-row.label-omitted .l3-value {
    width: 100%;
    text-align: left;
}

.l3-value small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.digital-link-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

.digital-link-actions a {
    max-width: 100%;
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.digital-link-copy {
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.digital-link-copy:hover,
.digital-link-copy:focus-visible {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
}

.product-history-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-primary);
    margin-top: 1.25rem;
    overflow: hidden;
}

.product-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.product-history-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.product-history-meta,
.product-history-empty,
.product-history-more {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.product-history-status span {
    display: inline-block;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.product-history-empty,
.product-history-more {
    padding: 1.25rem;
    text-align: center;
}

.product-history-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.product-history-summary span {
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.product-history-summary strong {
    color: var(--text-primary);
}

.product-history-list {
    display: grid;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
}

.product-history-transaction {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.product-history-transaction-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.product-history-transaction-header strong,
.product-history-transaction-header small {
    display: block;
}

.product-history-transaction-header strong {
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 700;
}

.product-history-transaction-header small {
    margin-top: 0.1rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.product-history-transaction-header time {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.product-history-transaction-events {
    display: grid;
}

.product-history-item {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.product-history-item:last-child {
    border-bottom: 0;
}

.product-history-item strong,
.product-history-item small,
.product-history-detail span,
.product-history-detail small {
    display: block;
}

.product-history-item strong {
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
}

.product-history-item small,
.product-history-detail small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.product-history-detail span {
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.product-history-operation {
    display: inline-block;
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    margin-bottom: 0.3rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.product-history-operation.insert {
    border: 1px solid rgba(22, 163, 74, 0.25);
    background: rgba(22, 163, 74, 0.08);
    color: var(--success);
}

.product-history-operation.update {
    border: 1px solid rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.08);
    color: var(--warning);
}

.product-history-operation.delete {
    border: 1px solid rgba(220, 38, 38, 0.25);
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
}

.product-history-more {
    border-top: 1px solid var(--border);
    text-align: center;
}

@media (max-width: 900px) {
    .product-version-panel {
        flex-direction: column;
    }

    .product-version-actions {
        width: 100%;
    }

    .product-history-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .product-history-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.system-actions {
    padding: 1.5rem;
    display: grid;
    gap: 1rem;
}

/* ── Template browser ──────────────────────────────────────────── */

.template-browser {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.template-browser-search {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.template-create-toggle,
.template-import-toggle {
    white-space: nowrap;
}

.template-create-accordion {
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    animation: accordion-open 0.18s ease;
}

@keyframes accordion-open {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.field-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field-accordion-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    overflow: hidden;
    scroll-margin-top: 80px;
}

.field-accordion-item.open {
    border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
    box-shadow: var(--shadow);
}

.field-accordion-item.invalid {
    border-color: var(--danger, #dc3545);
}

.field-accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.field-accordion-header:hover {
    background: color-mix(in srgb, var(--primary) 7%, transparent);
}

.field-accordion-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.field-accordion-chevron {
    display: inline-block;
    font-size: 1.2rem;
    transition: transform 0.18s ease;
}

.field-accordion-item.open .field-accordion-chevron {
    transform: rotate(180deg);
}

.field-accordion-body {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    animation: accordion-open 0.18s ease;
}

.field-accordion-subsection + .field-accordion-subsection {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.field-accordion-subsection h5 {
    margin: 0 0 1rem;
    color: var(--primary);
    font-size: 1rem;
}

.field-accordion-body .template-field-label {
    font-size: 0.95rem;
}

.field-accordion-field + .field-accordion-field {
    margin-top: 1.25rem;
}

.optional-empty-chip {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.15rem 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.01em;
}

@media (max-width: 640px) {
    .field-accordion-meta {
        font-size: 0;
    }
}

.template-create-accordion-inner {
    padding: 1rem;
}

.template-create-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.5rem;
    align-items: end;
}

.template-message {
    padding: 1rem;
}

/* template card list */

.template-card-list {
    display: flex;
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    padding: 0;
    scrollbar-width: thin;
}

.template-card {
    flex: 0 0 auto;
    min-width: 200px;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 1rem;
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.template-card:last-child {
    border-right: 0;
}

.template-card:hover {
    background: var(--bg-secondary);
}

.template-card.active {
    background: var(--bg-secondary);
    box-shadow: inset 0 -3px 0 var(--primary);
}

.template-card-name {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card-desc {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card-counts {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.template-card-counts span {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
}

/* ── Template detail area ───────────────────────────────────────── */

.template-detail-area {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.template-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.template-detail-header h2 {
    margin-bottom: 0.2rem;
    font-size: 1.35rem;
    font-weight: 800;
}

.template-detail-header p {
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.template-warning {
    margin: 0.75rem 1.25rem 0;
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-left: 4px solid var(--warning);
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.1);
    color: #7c2d12;
    font-size: 0.875rem;
    font-weight: 700;
}

.template-metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

.template-metrics span,
.template-tags span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 800;
}

/* ── Tabs ────────────────────────────────────────────────────────── */

.template-tabs {
    display: flex;
    gap: 0;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    overflow-x: auto;
    scrollbar-width: none;
}

.template-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.template-tab:hover {
    color: var(--text-primary);
}

.template-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.template-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 800;
}

.template-tab.active .template-tab-badge {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary);
}

.template-tab-panel {
    padding: 1.25rem;
    animation: tab-in 0.15s ease;
}

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

/* ── Tab: Overview (grouped field tree) ─────────────────────────── */

.template-empty-state {
    min-height: 180px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    font-weight: 700;
}

.template-attribute-groups {
    display: grid;
    gap: 0.75rem;
}

.template-group {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.template-group.open {
    border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
    box-shadow: var(--shadow-sm);
}

.template-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.template-group-header:hover {
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.template-group-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.template-group-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.template-group-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.template-group-chevron {
    display: inline-block;
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.18s ease;
}

.template-group.open .template-group-chevron {
    transform: rotate(180deg);
}

.template-group-body {
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid var(--border);
    animation: accordion-open 0.18s ease;
}

.template-subgroup + .template-subgroup {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.template-field-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.35rem 0.75rem;
    margin-top: 0.45rem;
}

.template-field-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    border-radius: 8px;
    background: var(--bg-primary);
    padding: 0.45rem 0.6rem;
}

.template-field-row small,
.template-table-note {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ── Tab: Fields (table) ─────────────────────────────────────────── */

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.template-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* ── Tab: Edit template / Add·Edit field (forms) ─────────────────── */

.template-form-card {
    max-width: 900px;
}

.template-form-card > h2 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.template-editing-notice {
    margin-bottom: 1rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.07);
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-left: 3px solid var(--primary);
}

.template-meta-form {
    display: grid;
    gap: 1rem;
}

.template-meta-form-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.template-field-label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 700;
}

.template-field-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.template-fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    padding: 0.85rem 1rem;
    margin: 0;
}

.template-fieldset legend {
    padding: 0 0.35rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.template-fieldset-wide {
    grid-column: 1 / -1;
}

.template-fieldset-body {
    display: grid;
    gap: 0.6rem;
}

.template-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.template-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ── Impeccable Template Console Extensions ───────────────────────── */

.template-import-panel {
    margin-bottom: 1.5rem;
}

.template-import-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.template-import-header h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.template-import-header p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.template-import-upload {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.template-import-upload label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.template-import-file-input {
    padding: 0.5rem 0.75rem;
    height: auto;
    font-size: 0.875rem;
    background: var(--bg-primary);
    border: 1px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.template-import-file-input:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 3%, var(--bg-primary));
}

.template-import-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.template-import-callout {
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    line-height: 1.45;
}

.template-import-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    align-items: center;
}

.template-import-warnings {
    margin-top: 0.5rem;
    background: #fffcf4;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 1rem 1.25rem;
    border-radius: 8px;
}

.template-import-warnings h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-import-warnings ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.8125rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Detail header & action bar */
.template-detail-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.template-detail-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.template-lang-picker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.template-lang-picker span {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.template-lang-select {
    padding: 0.2rem 0.5rem;
    height: auto;
    min-height: 28px;
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--text-primary);
    cursor: pointer;
}

.template-action-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-sm);
}

/* Fields Table Enhancements */
.template-table-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    overflow: hidden;
    margin-top: 0.5rem;
}

.template-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.template-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.template-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}

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

.template-table tr:hover td {
    background: color-mix(in srgb, var(--primary) 2.5%, var(--bg-primary));
}

.template-row-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.template-row-action-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--bg-primary);
}

/* Category Manager & Field Ergonomics */
.template-callout-guide {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    line-height: 1.45;
}

.template-category-picker-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.template-category-manager {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.template-category-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.template-category-manager-header h4 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--primary);
}

.template-category-list-scroll {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 160px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.template-category-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    transition: background 0.12s ease;
}

.template-category-list-item:hover {
    background: var(--bg-primary);
}

.template-category-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.template-lang-l3-grid {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 1.25rem;
    align-items: flex-start;
}

.template-field-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    display: block;
}



.login-note {
    padding: 1rem;
    border-radius: 10px;
    background: var(--bg-secondary);
    font-size: 0.875rem;
}

.redirecting-state {
    min-height: 100vh;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    font-weight: 700;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: #fef3c7;
    box-shadow: 0 -1px 2px rgba(15, 23, 42, 0.12);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.55rem;
    right: 0.75rem;
    cursor: pointer;
}

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

@media (max-width: 820px) {
    .app-container {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }

    .nav-menu {
        display: flex;
        gap: 1rem;
        padding: 1rem;
        overflow-x: auto;
    }

    .nav-section {
        min-width: 220px;
        margin-bottom: 0;
    }

    .top-bar,
    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .top-bar-actions,
    .user-menu {
        flex-wrap: wrap;
    }

    .products-search-row {
        grid-template-columns: 1fr;
    }

    .template-browser-search {
        grid-template-columns: 1fr auto;
    }

    .template-create-toggle {
        grid-column: 1 / -1;
    }

    .template-card-list {
        flex-direction: column;
    }

    .template-card {
        max-width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .template-card.active {
        box-shadow: inset 3px 0 0 var(--primary);
    }

    .template-create-fields {
        grid-template-columns: 1fr;
    }

    .template-meta-form-fields {
        grid-template-columns: 1fr;
    }

    .template-fieldset-wide {
        grid-column: auto;
    }

    .template-detail-header {
        flex-direction: column;
    }

    .product-header {
        flex-direction: column;
    }

    .content-area {
        padding: 1.25rem;
    }

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

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    vertical-align: text-bottom;
    border: 0.15em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}
/* Shared binary asset management */
.asset-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; margin:1.5rem 0; }
.asset-tab { display:flex; min-height:4.5rem; justify-content:space-between; align-items:center; padding:1rem 1.25rem; border:1px solid var(--border-color,#dee2e6); border-radius:.7rem; background:#fff; color:var(--text-primary); cursor:pointer; transition:border-color .15s ease,background-color .15s ease,box-shadow .15s ease; }
.asset-tab:hover { border-color:#9fb9e8; background:#f8faff; }
.asset-tab:disabled { cursor:not-allowed; opacity:.6; }
.asset-tab:disabled:hover { border-color:var(--border-color,#dee2e6); background:#fff; }
.asset-tab.active { border-color:#0d6efd; background:#edf4ff; color:#0b57d0; box-shadow:inset 0 0 0 1px #0d6efd,0 3px 10px rgba(13,110,253,.1); }
.asset-tab.active:disabled:hover { border-color:#0d6efd; background:#edf4ff; }
.asset-tab-name { font-size:1.05rem; font-weight:800; }
.asset-tab > span:last-child { min-width:2rem; padding:.2rem .55rem; border-radius:1rem; background:#eef2f7; color:var(--text-primary); text-align:center; }
.asset-tab.active > span:last-child { background:#0d6efd; color:#fff; }
.asset-folder-panel { display:grid; grid-template-columns:minmax(0,1fr) minmax(18rem,26rem); align-items:center; gap:2rem; margin-bottom:1rem; padding:1.15rem 1.25rem; border:1px solid var(--border); border-radius:.75rem; background:#fff; box-shadow:var(--shadow-sm); }
.asset-folder-context { min-width:0; }
.asset-folder-eyebrow { display:block; margin-bottom:.25rem; color:#0d6efd; font-size:.72rem; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.asset-folder-heading { display:flex; align-items:center; gap:.75rem; }
.asset-folder-heading h2 { margin:0; font-size:1.35rem; line-height:1.25; }
.asset-folder-heading span { padding:.15rem .55rem; border-radius:1rem; background:#edf4ff; color:#0b57d0; font-size:.78rem; font-weight:700; }
.asset-folder-context p { max-width:48rem; margin:.35rem 0 0; color:var(--text-secondary); font-size:.9rem; line-height:1.45; }
.asset-search { min-width:0; }
.asset-search label { display:block; margin-bottom:.35rem; font-size:.8rem; font-weight:700; }
.asset-search-controls { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.5rem; }
.asset-search-controls .form-input { min-width:0; padding:.65rem .8rem; }
.asset-search-controls .btn { min-height:2.65rem; padding:.6rem 1rem; }
.asset-drop-zone { position:relative; display:flex; min-height:10rem; margin-bottom:1rem; padding:1.5rem; flex-direction:column; align-items:center; justify-content:center; gap:.3rem; border:2px dashed #9fb3c8; border-radius:.75rem; background:#f8fafc; color:#334155; text-align:center; cursor:pointer; transition:border-color .15s ease,background-color .15s ease,box-shadow .15s ease; overflow:hidden; }
.asset-drop-zone:hover,.asset-drop-zone:focus-within { border-color:#0d6efd; background:#f1f6ff; box-shadow:0 0 0 3px rgba(13,110,253,.1); }
.asset-drop-zone.disabled { cursor:not-allowed; opacity:.65; }
.asset-drop-zone.uploading { border-style:solid; border-color:#8eb8f8; background:#f7faff; cursor:wait; opacity:1; }
.asset-drop-input { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.asset-drop-input:disabled { cursor:not-allowed; }
.asset-drop-icon { display:grid; width:2.5rem; height:2.5rem; place-items:center; margin-bottom:.25rem; border-radius:50%; background:#0d6efd; color:#fff; font-size:1.5rem; line-height:1; }
.asset-drop-zone small { color:#64748b; }
.asset-upload-progress { width:min(100%,36rem); }
.asset-upload-progress-header,.asset-upload-progress-meta { display:flex; align-items:center; justify-content:space-between; gap:1rem; }
.asset-upload-progress-header strong { min-width:0; overflow:hidden; color:var(--text-primary); text-overflow:ellipsis; white-space:nowrap; }
.asset-upload-progress-header span { flex:none; color:#0b57d0; font-size:1.1rem; font-weight:800; font-variant-numeric:tabular-nums; }
.asset-upload-progress progress { display:block; width:100%; height:.75rem; margin:.8rem 0 .55rem; border:0; border-radius:999px; overflow:hidden; background:#dce8f8; accent-color:#0d6efd; }
.asset-upload-progress progress::-webkit-progress-bar { border-radius:999px; background:#dce8f8; }
.asset-upload-progress progress::-webkit-progress-value { border-radius:999px; background:#0d6efd; }
.asset-upload-progress progress::-moz-progress-bar { border-radius:999px; background:#0d6efd; }
.asset-upload-progress-meta { flex-wrap:wrap; color:#52677f; font-size:.82rem; font-variant-numeric:tabular-nums; }
.asset-upload-status { margin-inline-start:auto; text-align:end; }
.asset-secondary { display:block; color:#6c757d; margin-top:.25rem; }
.asset-actions { display:flex; gap:.4rem; flex-wrap:wrap; }
.asset-empty { padding:3rem; text-align:center; color:#6c757d; }
.asset-paging { display:flex; justify-content:center; align-items:center; gap:1rem; padding:1rem; border-top:1px solid #dee2e6; }
.pd-attachment { display:flex; align-items:center; gap:.5rem; margin:.4rem 0; }
@media (max-width: 760px) {
  .asset-tabs { grid-template-columns:1fr; }
  .asset-folder-panel { grid-template-columns:1fr; gap:1rem; }
}
@media (max-width: 480px) {
  .asset-upload-progress-meta { align-items:flex-start; flex-direction:column; gap:.2rem; }
  .asset-upload-status { margin-inline-start:0; text-align:start; }
}

/* ── Product Detail Edit Panel & Controls ───────────────────────── */

.product-edit-panel {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-primary);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.product-edit-panel .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
}

.product-edit-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.product-edit-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.product-edit-form .form-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.85rem 1.15rem;
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.05);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.product-edit-form .form-info div:first-child {
    font-weight: 700;
    color: var(--text-primary);
}

.pd-edit-language-row {
    display: grid;
    grid-template-columns: 50px 1fr 2fr;
    gap: 0.75rem;
    align-items: start;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    margin-top: 0.75rem;
}

.pd-edit-language-row strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.pd-edit-attribute {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.pd-edit-attribute:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.pd-edit-translatable-input {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
}

.pd-edit-translatable-input .form-input {
    flex: 1;
}

.pd-icon-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.pd-icon-action-btn:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
}

.edit-field-modified {
    position: relative;
    border-left: 3px solid var(--warning) !important;
    padding-left: 0.5rem;
    border-radius: 4px;
}

.edit-field-invalid {
    position: relative;
    border-left: 3px solid var(--danger) !important;
    padding-left: 0.5rem;
    border-radius: 4px;
}

@media (max-width: 768px) {
    .pd-edit-language-row {
        grid-template-columns: 1fr;
    }
}

