:root {
    --bg: #eef5fc;
    --bg2: #f8fbff;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d8e4f0;
    --primary: #0786c8;
    --primary-dark: #064b78;
    --primary-soft: #e3f3ff;
    --accent: #f6a800;
    --danger: #b91c1c;
    --ok: #167245;
    --shadow: 0 14px 36px rgba(15, 44, 75, .10);
    --shadow-soft: 0 5px 16px rgba(15, 44, 75, .07);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Arial, Helvetica, sans-serif;
    background: radial-gradient(circle at top left, rgba(7,134,200,.14), transparent 34%), linear-gradient(180deg, var(--bg) 0%, var(--bg2) 52%, #fff 100%);
    color: var(--text);
}

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

.topbar {
    min-height: 76px;
    background: rgba(255,255,255,.95);
    border-bottom: 1px solid rgba(7,134,200,.14);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 10px 26px;
    box-shadow: 0 4px 18px rgba(15,44,75,.07);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand { display: inline-flex; align-items: center; text-decoration: none; flex: 0 0 auto; }
.brand-logo { display: block; max-height: 54px; max-width: 210px; width: auto; object-fit: contain; }
.topbar-title { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.topbar-title strong { font-size: 20px; color: var(--primary-dark); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.usernav { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.user-pill { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px 7px 12px; box-shadow: var(--shadow-soft); white-space: nowrap; }
.user-pill span { font-weight: 800; }
.user-pill small { color: var(--primary-dark); background: var(--primary-soft); padding: 4px 8px; border-radius: 999px; font-weight: 800; }
.user-summary { max-width: none; }
.user-welcome { display: inline-flex; align-items: center; gap: 4px; }
.user-welcome strong { font-weight: 900; }
.nav-profile { background: #0b77bd !important; }
.nav-profile:hover { background: var(--primary-dark) !important; }


.btn, .nav-btn, button.btn, a.btn {
    background: var(--primary);
    color: white !important;
    border: 0;
    border-radius: 10px;
    height: 36px;
    min-height: 36px;
    padding: 0 14px;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.15;
    white-space: nowrap;
    vertical-align: middle;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: 0 8px 18px rgba(7,134,200,.16);
}
.btn:hover, .nav-btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-small { height: 30px; min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.secondary, .nav-back { background: #475569 !important; }
.secondary:hover, .nav-back:hover { background: #334155 !important; }
.nav-menu { background: #0b77bd !important; }
.danger, .nav-logout { background: #9a3412 !important; }
.danger:hover, .nav-logout:hover { background: #7c2d12 !important; }
.ok { background: #15803d !important; }
.ok:hover { background: #166534 !important; }

.container { width: 100%; max-width: 1500px; margin: 0 auto; padding: 24px; flex: 1 0 auto; }
.panel, .login-box { background: rgba(255,255,255,.96); border: 1px solid rgba(7,134,200,.13); border-radius: 18px; box-shadow: var(--shadow); }
.panel { padding: 20px; margin-bottom: 18px; overflow: visible; }
.panel h1, .panel h2, .login-box h1 { margin-top: 0; color: var(--primary-dark); letter-spacing: -.03em; }
.panel-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.muted { color: var(--muted); }
.one-line { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; }

.login-wrap { min-height: calc(100vh - 76px); display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 430px; padding: 30px; }
.login-logo-wrap { text-align: center; margin-bottom: 16px; }
.login-logo { max-width: 300px; max-height: 150px; width: auto; height: auto; object-fit: contain; }

.field { margin-bottom: 14px; }
label { display: block; font-weight: 800; margin-bottom: 5px; color: #24364b; font-size: 13px; }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="datetime-local"], input[type="email"], select, textarea {
    width: 100%; border: 1px solid #cbd9e8; border-radius: 9px; padding: 9px 10px; font-size: 14px; background: white; color: var(--text); outline: none;
}
textarea { min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(96,165,250,.16); }

/* v4.63: botones y controles en la misma línea con altura y fuente uniformes */
.toolbar .btn,
.actions-row .btn,
.row-actions .btn,
.stat-row .btn,
.panel-heading .btn {
    flex: 0 0 auto;
}
.toolbar input[type="search"],
.toolbar select,
.toolbar .btn {
    height: 36px;
    min-height: 36px;
}
.row-actions form,
.actions-row form,
.toolbar form {
    margin: 0;
}
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; font-weight: 700; }

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}
.password-field input[type="password"],
.password-field input[type="text"] {
    padding-right: 46px;
}
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
}
.password-toggle:hover,
.password-toggle:focus {
    background: rgba(7,134,200,.10);
    outline: none;
}

.error, .success, .notice { padding: 11px 12px; border-radius: 10px; margin-bottom: 14px; }
.error { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; }
.success { background: #dcfce7; color: var(--ok); border: 1px solid #bbf7d0; }
.notice { background: #eef6ff; color: var(--primary-dark); border: 1px solid #bfdbfe; }
.notice.ok, .notice.ok strong, .success.ok, .success.ok strong { color: #fff !important; }

.grid-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 18px; margin-top: 22px; }
.card { display: flex; min-height: 132px; flex-direction: column; gap: 10px; background: linear-gradient(180deg,#fff 0%,#f7fbff 100%); color: var(--text); text-decoration: none; border: 1px solid rgba(7,134,200,.14); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; position: relative; overflow: hidden; }
.card::after { content: ""; position: absolute; right: -28px; top: -28px; width: 90px; height: 90px; border-radius: 999px; background: rgba(246,168,0,.14); }
.card:hover { transform: translateY(-3px); border-color: #60a5fa; box-shadow: 0 20px 44px rgba(15,44,75,.14); text-decoration: none; }
.card strong { font-size: 18px; color: var(--primary-dark); }
.card span:last-child { color: var(--muted); line-height: 1.35; }
.icon-square { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: white; background: linear-gradient(135deg,var(--primary),#0ea5e9); font-weight: 900; box-shadow: 0 8px 18px rgba(7,134,200,.20); }

.toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .field { margin-bottom: 0; min-width: 210px; }
.field-wide { min-width: 340px !important; flex: 1 1 340px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 16px; }
.form-grid .field { margin-bottom: 0; }
.field-full { grid-column: 1 / -1; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.inline-form { display: inline; margin: 0; }

.stat-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stat-chip, .badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 13px; font-weight: 800; white-space: nowrap; }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid rgba(7,134,200,.13); border-radius: 16px; box-shadow: var(--shadow-soft); }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 980px; }
th, td { border-bottom: 1px solid rgba(216,228,240,.95); padding: 8px 10px; text-align: left; vertical-align: middle; font-size: 13px; }
th { background: linear-gradient(180deg,#f8fbff 0%,#eef6ff 100%); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #42617f; white-space: nowrap; position: static !important; top: auto !important; z-index: auto !important; }
tr:last-child td { border-bottom: 0; }
.nowrap-table th, .nowrap-table td { white-space: nowrap; }
.products-table tbody tr:hover td, .data-table tbody tr:hover td { background: #e8f2ff !important; }
.product-cell { min-width: 340px; max-width: 560px; }
.product-cell small { color: var(--muted); margin-top: 3px; max-width: 520px; display: block; }
.code-cell { font-weight: 900; color: var(--primary-dark); }
.small-cell { max-width: 170px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.family-band-0 td { background: #ffffff; }
.family-band-1 td { background: #f2f8ff; }
.family-band-2 td { background: #fff8e8; }
.family-band-3 td { background: #f3fff6; }
.family-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; background: rgba(7,134,200,.10); color: var(--primary-dark); font-weight: 800; font-size: 12px; white-space: nowrap; }
.status-ok { color: var(--ok); font-weight: 900; }
.status-no { color: var(--danger); font-weight: 900; }
.product-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: white; display: block; }
.photo-cell { min-width: 150px; max-width: 230px; }
.photo-chip { display: inline-flex; align-items: center; justify-content: center; padding: 4px 8px; border-radius: 999px; background: #dbeafe; color: #1e40af; font-size: 12px; font-weight: 900; margin-right: 6px; white-space: nowrap; }
.muted-chip { background: #f1f5f9; color: #475569; }
.photo-name { display: inline-block; max-width: 130px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.check-inline { display: flex; align-items: center; gap: 8px; margin-bottom: 0; font-weight: 800; white-space: nowrap; }
.check-inline input { width: auto; }
.input-small, .input-money, .select-small { width: 82px; border: 1px solid #cbd9e8; border-radius: 8px; padding: 7px 8px; font-size: 14px; background: white; }
.input-money { width: 95px; }
.select-small { width: 130px; }
.center { text-align: center; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; min-width: 210px; }
.mini-grid label { font-size: 12px; margin: 0; }
.sticky-actions { position: static; background: rgba(248,251,255,.96); border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: var(--shadow-soft); }
.editable-table { min-width: 1260px; }
.print-header { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow-soft); }
.document-note { margin: 18px 0; color: var(--muted); font-size: 13px; }

.site-footer { flex-shrink: 0; margin-top: 34px; padding: 16px 28px; background: linear-gradient(180deg,#fff 0%,#f8fbff 100%); border-top: 1px solid rgba(7,134,200,.13); }
.site-footer-inner { max-width: 1500px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-powered, .footer-macopal { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; text-decoration: none; }
.footer-powered span { color: var(--muted); font-weight: 800; white-space: nowrap; }
.footer-logo-cortana { display: block; height: 48px; width: auto; max-width: 260px; object-fit: contain; }
.footer-logo-macopal { display: block; height: 48px; width: auto; max-width: 160px; object-fit: contain; }
.footer-web-link { color: var(--primary); font-weight: 900; text-decoration: none; white-space: nowrap; }
.footer-powered:hover, .footer-web-link:hover { opacity: .86; text-decoration: none; }

@media (max-width: 900px) {
    .topbar { align-items: flex-start; flex-direction: column; padding: 14px 18px; position: static; }
    .topbar-left { align-items: flex-start; flex-direction: column; gap: 8px; }
    .topbar-title span { white-space: normal; }
    .brand-logo { max-height: 70px; max-width: 210px; }
    .container { padding: 18px; }
    .site-footer { padding: 18px; }
    .site-footer-inner { align-items: flex-start; flex-direction: column; }
    .usernav { justify-content: flex-start; }
}
@media (max-width: 620px) {
    .user-pill { display: none; }
    .field-wide { min-width: 100% !important; }
    .toolbar .field { min-width: 100%; }
    .btn, .nav-btn { padding: 9px 11px; }
}
@media print {
    .topbar, .site-footer, .no-print, .usernav, .sticky-actions { display: none !important; }
    body { background: white; color: black; }
    .container { max-width: none; padding: 0; }
    .table-wrap, .print-header { border: 0; box-shadow: none; border-radius: 0; }
    table { min-width: 0; font-size: 11px; }
    th, td { padding: 5px 6px; white-space: normal; }
}

.btn.mini {
    height: 30px;
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 8px;
}

.actions-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.inline-form {
    display: inline;
    margin: 0;
}

.hidden-form {
    display: none;
}

.permissions-table th,
.permissions-table td {
    text-align: center;
}

.permissions-table th:nth-child(2),
.permissions-table td:nth-child(2) {
    text-align: left;
}

.input-rol-name {
    min-width: 220px;
}

.permission-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 4px 6px;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    font-weight: 900;
}

.permission-check input {
    width: auto;
    margin: 0;
}

/* Ajustes bloque 8: cabeceras, logos, footer y permisos por rol */
th {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
}

.brand-logo-commercial {
    max-height: 76px;
    max-width: 240px;
}

.topbar {
    border-top: 5px solid var(--primary);
}

.card-restricted .restricted-lock {
    position: absolute;
    right: 18px;
    top: 16px;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(246, 168, 0, .18);
    color: #9a3412;
    font-size: 18px;
    font-weight: 900;
}

.card::after {
    background: rgba(246, 168, 0, .16);
}

.icon-square {
    box-shadow: 0 10px 20px rgba(11, 98, 163, .18), inset 0 -4px 0 rgba(246,168,0,.35);
}

.lang-pill {
    background: #fff7ed !important;
    color: #9a3412 !important;
}

.site-footer {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-top: 1px solid rgba(11, 98, 163, .16);
}

.site-footer-inner {
    align-items: center;
}

.footer-powered {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-weight: 900;
}

.footer-powered span {
    color: #667085;
    font-weight: 900;
}

.footer-logo-cortana {
    height: 56px;
    max-width: 190px;
    object-fit: contain;
}

.footer-macopal {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.footer-logo-macopal {
    height: 46px;
    max-width: 165px;
    object-fit: contain;
}

.footer-web-link { display: none !important; }

.role-summary {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 14px 0 18px;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 12px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 800;
    border: 1px solid rgba(11, 98, 163, .15);
    white-space: nowrap;
}

.role-chip strong {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: white;
    background: var(--primary);
}

.role-1 { background: #e4f2ff; }
.role-2 { background: #edf7ff; }
.role-3 { background: #fff7ed; }
.role-4 { background: #f8fafc; }

.input-menu-name { min-width: 220px; }
.input-page { min-width: 150px; }
.input-desc { min-width: 330px; }
.input-icon { width: 64px; text-align: center; }
.input-order { width: 80px; }
.select-role { min-width: 190px; }

.switch-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 4px 8px;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    font-weight: 900;
    white-space: nowrap;
}
.switch-check input { width: auto; margin: 0; }

.compact-form {
    align-items: end;
}

textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid #cbd9e8;
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 15px;
    font-family: Arial, Helvetica, sans-serif;
    resize: vertical;
}

@media (max-width: 900px) {
    .brand-logo-commercial { max-height: 92px; max-width: 240px; }
    .footer-logo-cortana { height: 50px; max-width: 180px; }
}


/* Footer versión visible - v2.00 */
.site-footer-inner.site-footer-grid {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr;
    align-items: center !important;
    gap: 20px;
}

.site-footer-grid .footer-powered {
    justify-self: start;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.footer-version {
    justify-self: center;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border: 1px solid rgba(7, 134, 200, .18);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
    box-shadow: var(--shadow-soft);
}

.site-footer-grid .footer-macopal {
    justify-self: end;
}

@media (max-width: 900px) {
    .site-footer-inner.site-footer-grid {
        grid-template-columns: 1fr;
        justify-items: flex-start;
    }

    .footer-version,
    .site-footer-grid .footer-macopal,
    .site-footer-grid .footer-powered {
        justify-self: start;
    }
}


/* Macopal v2.02: cabecera con foto, menú sin Mi Perfil y administración más naranja */
.user-summary {
    gap: 9px;
}

.header-user-photo,
.header-user-initials {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    flex: 0 0 auto;
    border: 2px solid rgba(246, 168, 0, .42);
    box-shadow: 0 8px 18px rgba(15, 44, 75, .12);
}

.header-user-photo {
    object-fit: cover;
    background: #fff;
}

.header-user-initials {
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 900;
}

.menu-card-administracio {
    border-color: rgba(246, 168, 0, .38) !important;
    background:
        radial-gradient(circle at right top, rgba(246, 168, 0, .34), transparent 27%),
        linear-gradient(180deg, #fffdfa 0%, #fff5df 100%) !important;
}

.menu-card-administracio .menu-icon {
    background: linear-gradient(135deg, #f6a800, #c96f00) !important;
    color: #fff !important;
    box-shadow: 0 10px 20px rgba(201, 111, 0, .22) !important;
}

.menu-card-administracio .menu-marker-office {
    background: rgba(246, 168, 0, .24) !important;
    border-color: rgba(246, 168, 0, .52) !important;
}

.footer-version {
    min-width: 220px;
    text-align: center;
}

.profile-photo-box {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 14px;
    background: linear-gradient(135deg, #f8fbff, #fff7e6);
    border: 1px solid rgba(246, 168, 0, .22);
    border-radius: 16px;
    margin-bottom: 18px;
}

.profile-photo-preview,
.profile-photo-placeholder {
    width: 92px;
    height: 92px;
    border-radius: 18px;
    border: 2px solid rgba(11, 98, 163, .20);
    box-shadow: var(--shadow-soft);
    background: #fff;
    flex: 0 0 auto;
}

.profile-photo-preview {
    object-fit: cover;
}

.profile-photo-placeholder {
    display: grid;
    place-items: center;
    font-size: 36px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.profile-photo-help {
    color: var(--muted);
    font-size: 13px;
    margin-top: 5px;
}


/* Macopal Comercial v2.03: usuarios + empleados unificados y sombra naranja en pie */
.footer-logo-macopal {
    filter: drop-shadow(0 0 10px rgba(246, 168, 0, .45)) drop-shadow(0 6px 12px rgba(154, 52, 18, .10));
    border-radius: 10px;
    background: rgba(255, 247, 237, .35);
    padding: 3px 6px;
}

.admin-user-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.admin-form-block {
    border: 1px solid rgba(11, 98, 163, .14);
    border-radius: 16px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: var(--shadow-soft);
}

.admin-form-block h2 {
    margin: 0 0 12px;
    color: var(--primary-dark);
    font-size: 18px;
}

.field-full-block {
    grid-column: 1 / -1;
}

.compact-fields {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.slim-photo-box {
    margin-bottom: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
}

.table-user-photo,
.table-user-initials {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 2px solid rgba(246, 168, 0, .38);
    box-shadow: 0 6px 14px rgba(15, 44, 75, .12);
}

.table-user-photo {
    object-fit: cover;
    background: #fff;
}

.table-user-initials {
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 900;
}

@media (max-width: 980px) {
    .admin-user-form { grid-template-columns: 1fr; }
}

/* Macopal Comercial v2.05: perfil Comercial en modo solo visualización */
.view-only-chip {
    background: linear-gradient(135deg, rgba(14,165,233,.14), rgba(11,98,163,.10)) !important;
    color: var(--primary-dark) !important;
    border: 1px solid rgba(14,165,233,.28) !important;
}

/* Macopal Comercial v2.08: avisos impost plàstic, fotos de producte i accions a la dreta */
.actions-row {
    justify-content: flex-end;
}

.row-actions.table-actions,
th.table-actions,
td.table-actions {
    text-align: right;
    justify-content: flex-end;
}

.row-actions.table-actions {
    min-width: 230px;
}

input[type="file"] {
    width: 100%;
    border: 1px dashed #cbd9e8;
    border-radius: 9px;
    padding: 9px 10px;
    background: #fffaf0;
    color: var(--text);
}

.plastic-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 7px;
    min-width: 26px;
    min-height: 24px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid rgba(246, 168, 0, .50);
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(246, 168, 0, .18);
    white-space: nowrap;
}

.family-warning {
    font-size: 12px;
}

.data-table .photo-cell,
.products-table .photo-cell {
    min-width: 165px;
}


/* Macopal Comercial v3.00: control de llicències i sessions */
.config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 16px;
}
.config-grid code {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 6px;
    background: #f1f5f9;
    color: var(--primary-dark);
    font-size: 12px;
    white-space: normal;
}
@media (max-width: 800px) {
    .config-grid { grid-template-columns: 1fr; }
}

/* Macopal Comercial v3.01: SQL OVH compatible, permisos menú sin seccio/ordre */

/* Macopal Comercial v4.00 */
.license-pill-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 999px;
    padding: 7px 12px;
    background: linear-gradient(135deg, rgba(11,98,163,.10), rgba(246,168,0,.18));
    border: 1px solid rgba(11,98,163,.18);
    color: var(--primary-dark);
    font-weight: 900;
    font-size: 13px;
    box-shadow: var(--shadow-soft);
}

.form-panel {
    margin-top: 18px;
}

.actions-right {
    justify-content: flex-end;
}

.menu-card-tarifes {
    background:
        radial-gradient(circle at right top, rgba(249,115,22,.20), transparent 25%),
        linear-gradient(180deg, #ffffff 0%, #fffaf2 100%);
}

@media (max-width: 900px) {
    .license-pill-header { font-size: 12px; }
}


/* Macopal Comercial v4.05: detall en mode visualització i llistes compactes en dues línies */
.readonly-fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}
.readonly-fieldset[disabled] {
    opacity: 1;
}
.readonly-fieldset[disabled] input,
.readonly-fieldset[disabled] select,
.readonly-fieldset[disabled] textarea {
    color: var(--text);
    background: #f8fbff;
    -webkit-text-fill-color: var(--text);
}
.fit-table {
    width: 100%;
    max-width: 100%;
}
.fit-table th {
    white-space: nowrap;
}
.fit-table td {
    white-space: normal;
    line-height: 1.25;
}
.fit-table .wrap-cell {
    white-space: normal !important;
    overflow: visible;
    text-overflow: clip;
}
.fit-table .product-cell {
    min-width: 250px;
    max-width: 360px;
}
.fit-table .small-cell {
    min-width: 110px;
    max-width: 220px;
}
.fit-table .table-actions {
    min-width: 130px;
    max-width: 180px;
}
.fit-table .row-actions.table-actions {
    flex-wrap: wrap;
    white-space: normal;
    gap: 5px;
}
.fit-table .btn-small {
    margin: 1px 0;
}
.clients-fit-table { min-width: 1180px; }
.productes-fit-table { min-width: 1480px; }
.tarifes-base-fit-table { min-width: 1580px; }
@media (max-width: 1500px) {
    .container { max-width: 100%; }
    .table-wrap { max-width: calc(100vw - 48px); }
}

/* Macopal Comercial v4.06: clients ordenables, baixes/inactius en vermell i millor aprofitament de l'espai */
.sort-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted rgba(11, 98, 163, .35);
}
.sort-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.clients-fit-table {
    min-width: 1120px;
}
.clients-fit-table .client-name-col,
.clients-fit-table .client-name-cell {
    min-width: 270px;
    max-width: 440px;
}
.clients-fit-table .email-cell {
    max-width: 230px;
    word-break: break-word;
}
.baixa-row td,
.producte-inactiu-row td {
    background: #fff1f1 !important;
}
.baixa-row .client-name-cell a,
.producte-inactiu-row .product-cell a,
.producte-inactiu-row .code-cell a {
    color: var(--danger) !important;
}
.baixa-row .code-cell,
.producte-inactiu-row .code-cell {
    color: var(--danger) !important;
}
.inactive-row td {
    color: #7f1d1d;
}
.clients-fit-table td,
.productes-fit-table td {
    line-height: 1.28;
}
@media (max-width: 1500px) {
    .clients-fit-table { min-width: 1040px; }
    .clients-fit-table .client-name-col,
    .clients-fit-table .client-name-cell { min-width: 245px; }
}


/* Macopal Comercial v4.07: llistats més llegibles i foto de producte esborrable */
.clients-table-wrap {
    overflow-x: auto;
}
.clients-readable-table {
    width: 100%;
    min-width: 1160px;
    table-layout: fixed;
}
.clients-readable-table th,
.clients-readable-table td {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    vertical-align: top;
}
.clients-readable-table th:nth-child(1),
.clients-readable-table td:nth-child(1) { width: 5%; }
.clients-readable-table th:nth-child(2),
.clients-readable-table td:nth-child(2) { width: 22%; }
.clients-readable-table th:nth-child(3),
.clients-readable-table td:nth-child(3) { width: 14%; }
.clients-readable-table th:nth-child(4),
.clients-readable-table td:nth-child(4) { width: 6%; }
.clients-readable-table th:nth-child(5),
.clients-readable-table td:nth-child(5) { width: 12%; }
.clients-readable-table th:nth-child(6),
.clients-readable-table td:nth-child(6) { width: 12%; }
.clients-readable-table th:nth-child(7),
.clients-readable-table td:nth-child(7) { width: 6%; }
.clients-readable-table th:nth-child(8),
.clients-readable-table td:nth-child(8) { width: 8%; }
.clients-readable-table th:nth-child(9),
.clients-readable-table td:nth-child(9) { width: 8%; }
.clients-readable-table th:nth-child(10),
.clients-readable-table td:nth-child(10) { width: 7%; }
.clients-readable-table th:nth-child(11),
.clients-readable-table td:nth-child(11) { width: 8%; }
.clients-readable-table .client-name-cell,
.clients-readable-table .contact-cell,
.clients-readable-table .poblacio-cell,
.clients-readable-table .observations-cell {
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.32;
}
.clients-readable-table .contact-cell a {
    color: var(--primary-dark);
    text-decoration: none;
}
.clients-readable-table .contact-cell a:hover {
    text-decoration: underline;
}
.clients-readable-table .table-actions {
    white-space: normal !important;
}
.clients-readable-table .row-actions.table-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.clients-readable-table .row-actions.table-actions .btn-small {
    width: 100%;
    min-width: 0;
}
.danger-check {
    color: var(--danger);
}
@media (max-width: 1500px) {
    .clients-readable-table { min-width: 1120px; }
}

/* Macopal Comercial v4.08: canvi de tarifa per productes seleccionats */
.block-muted {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    margin-top: 3px;
}
.table-relaxed th,
.table-relaxed td {
    white-space: normal !important;
    vertical-align: top;
}
.table-relaxed .product-cell {
    min-width: 300px;
    max-width: 520px;
    overflow-wrap: anywhere;
}
.two-line-cell {
    display: block;
    max-width: 180px;
    overflow-wrap: anywhere;
    line-height: 1.28;
}

/* Macopal Comercial v4.10: ajust clients i canvi de tarifa per productes amb selecció persistent */
.clients-readable-table {
    min-width: 1180px;
    table-layout: fixed;
    border-collapse: collapse;
}
.clients-readable-table th,
.clients-readable-table td {
    border-bottom: 1px solid rgba(216, 228, 240, .95) !important;
    vertical-align: middle;
}
.clients-readable-table th:nth-child(1),
.clients-readable-table td:nth-child(1) { width: 5%; }
.clients-readable-table th:nth-child(2),
.clients-readable-table td:nth-child(2) { width: 25%; }
.clients-readable-table th:nth-child(3),
.clients-readable-table td:nth-child(3) { width: 18%; }
.clients-readable-table th:nth-child(4),
.clients-readable-table td:nth-child(4) { width: 7%; }
.clients-readable-table th:nth-child(5),
.clients-readable-table td:nth-child(5) { width: 14%; }
.clients-readable-table th:nth-child(6),
.clients-readable-table td:nth-child(6) { width: 7%; }
.clients-readable-table th:nth-child(7),
.clients-readable-table td:nth-child(7) { width: 8%; }
.clients-readable-table th:nth-child(8),
.clients-readable-table td:nth-child(8) { width: 7%; }
.clients-readable-table th:nth-child(9),
.clients-readable-table td:nth-child(9) { width: 7%; }
.clients-readable-table th:nth-child(10),
.clients-readable-table td:nth-child(10) { width: 6%; }
.clients-readable-table .client-name-cell,
.clients-readable-table .contact-cell,
.clients-readable-table .poblacio-cell,
.clients-readable-table .empleat-cell,
.clients-readable-table .conditions-cell,
.clients-readable-table .baixa-date-cell {
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.33;
}
.clients-readable-table td.table-actions {
    display: table-cell !important;
    vertical-align: middle;
    border-bottom: 1px solid rgba(216, 228, 240, .95) !important;
}
.action-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.action-stack .btn-small {
    width: 100%;
    min-width: 0;
}

.canvi-productes-actions {
    position: sticky;
    top: 94px;
    z-index: 20;
}
.canvi-productes-actions .small-help {
    margin: 8px 0 0;
    font-size: 13px;
}
.canvi-productes-table {
    min-width: 1450px;
}
.canvi-productes-table th,
.canvi-productes-table td {
    vertical-align: middle;
}
.canvi-productes-table .product-cell {
    min-width: 330px;
    max-width: 520px;
}
.canvi-productes-table .input-money {
    width: 108px;
}
.preview-panel {
    border: 1px solid rgba(22, 114, 69, .22);
    background: linear-gradient(180deg, #ffffff 0%, #f4fff8 100%);
}
.preview-change-table {
    min-width: 900px;
}
.preview-change-table td,
.preview-change-table th {
    white-space: normal;
}
.row-selected td {
    background: #eefbf4 !important;
}


/* Macopal Comercial v4.20: avisos foto antiga i Dte1 calculat */
.foto-review-row td {
    background: #fff1f1 !important;
}
.foto-review-row .code-cell,
.foto-review-row .code-cell a,
.foto-review-row .product-cell a {
    color: var(--danger) !important;
}
.photo-review-chip {
    display: inline-flex;
    margin-top: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: var(--danger);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}
.legacy-photo-alert {
    font-weight: 800;
}


/* Macopal Comercial v4.21 */
.admin-user-form {
    grid-template-columns: minmax(560px, 1.15fr) minmax(470px, .85fr);
    align-items: stretch;
}

.admin-form-block {
    min-height: 100%;
}

.admin-photo-block .profile-photo-box.slim-photo-box {
    display: grid;
    grid-template-columns: 96px minmax(260px, 1fr) minmax(145px, 180px);
    align-items: center;
    gap: 18px;
}

.admin-photo-block .field {
    margin-bottom: 0;
}

.admin-photo-block input[type="file"] {
    max-width: 100%;
}

.compact-fields {
    grid-template-columns: minmax(180px, 1fr) minmax(210px, 1fr) minmax(190px, 220px);
    align-items: end;
}

.compact-fields .field:last-child {
    align-self: end;
}

.input-readonly-soft {
    background: #f1f5f9 !important;
    color: #64748b !important;
}

.history-json {
    max-width: 520px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    color: #334155;
}

.history-action-insert { color: #166534; font-weight: 900; }
.history-action-update { color: #0b62a3; font-weight: 900; }
.history-action-delete { color: #b91c1c; font-weight: 900; }

@media (max-width: 1180px) {
    .admin-user-form { grid-template-columns: 1fr; }
    .admin-photo-block .profile-photo-box.slim-photo-box { grid-template-columns: 96px 1fr; }
}

@media (max-width: 720px) {
    .admin-photo-block .profile-photo-box.slim-photo-box,
    .compact-fields { grid-template-columns: 1fr; }
}

/* Macopal Comercial v4.63: zona drag&drop de fotos y pie más cercano al contenido */
.container {
    flex: 0 0 auto;
    padding-top: 18px;
    padding-bottom: 10px;
}
.site-footer {
    margin-top: 12px !important;
}
.product-photo-dropzone {
    display: grid;
    gap: 7px;
    width: 100%;
    min-height: 118px;
    padding: 16px;
    border: 2px dashed rgba(7, 134, 200, .32);
    border-radius: 16px;
    background: linear-gradient(180deg, #f8fbff 0%, #eef7ff 100%);
    cursor: pointer;
    text-align: center;
    place-items: center;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.product-photo-dropzone.is-dragover {
    border-color: var(--primary);
    background: #e4f2ff;
    transform: translateY(-1px);
}
.product-photo-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.product-photo-dropzone .dropzone-main {
    color: var(--primary-dark);
    font-weight: 900;
    font-size: 15px;
}
.product-photo-dropzone .dropzone-sub,
.product-photo-dropzone .dropzone-file {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.product-photo-dropzone .dropzone-file {
    color: #9a3412;
}
.dropzone-preview {
    max-width: 140px;
    max-height: 100px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    padding: 4px;
}

/* v5.01: avisos verdes con fondo verde y texto blanco en toda la aplicación */
.notice.ok,
.success.ok,
.notice.success,
.alert.ok,
.alert-success,
.flash.ok,
.flash-success,
.message.ok,
.message-success {
    background: #16883f !important;
    border-color: #16883f !important;
    color: #fff !important;
}
.notice.ok *,
.success.ok *,
.notice.success *,
.alert.ok *,
.alert-success *,
.flash.ok *,
.flash-success *,
.message.ok *,
.message-success * {
    color: #fff !important;
}
