:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #0f172a;
    color: #e2e8f0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}

.sidebar-brand {
    padding: 22px 20px 18px;
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.sidebar-section {
    margin-bottom: 2px;
}

.sidebar-section-title {
    padding: 14px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    font-weight: 700;
}

.sidebar a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar a:hover {
    background: rgba(255,255,255,0.04);
    color: #ffffff;
    text-decoration: none;
}

.sidebar a.active {
    background: rgba(13, 148, 136, 0.15);
    color: #ffffff;
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-user {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

.sidebar-user-name {
    display: block;
    font-size: 13px;
    color: #94a3b8;
    font-weight: 600;
}

.sidebar-user-role {
    color: #64748b;
    font-weight: 400;
}

.sidebar-user-logout {
    display: inline-block;
    margin-top: 8px;
    color: #f87171;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.sidebar-user-logout:hover {
    color: #fca5a5;
    text-decoration: underline;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

.hamburger {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 101;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 6px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Layout */
.main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg);
}

.main.no-sidebar {
    margin-left: 0;
}

.main.auth-layout {
    margin-left: 0;
}

.auth-layout {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

.auth-layout .page {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.auth-layout .panel {
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
}

.page {
    margin: 0 auto;
    max-width: 1200px;
    padding: 28px;
}

.page-title {
    margin-bottom: 24px;
}

.page-title h1 {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.page-title p {
    color: var(--muted);
    margin: 0;
    max-width: 760px;
    line-height: 1.5;
}

/* Stats */
.stat-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 22px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.stat-label {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat strong {
    display: block;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Buttons */
.button {
    align-items: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #0f172a;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    min-height: 38px;
    padding: 8px 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.button:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.button.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #ffffff;
}

.button.ghost {
    background: transparent;
    border-color: transparent;
}

.button.ghost:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.button.small {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 13px;
}

/* Panel */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 22px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.panel-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-heading h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.muted, .hint {
    color: var(--muted);
}

.hint {
    font-size: 13px;
    margin: 0;
    max-width: 820px;
    line-height: 1.5;
}

.empty {
    color: var(--muted);
    margin: 12px 0;
    font-weight: 500;
}

/* Actions */
.actions-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 22px;
}

/* Forms / filters */
.form, .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.form { align-items: flex-end; }
.filters { align-items: end; }

label {
    color: #334155;
    display: grid;
    font-size: 13px;
    font-weight: 600;
    gap: 6px;
}

input,
select {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    min-height: 38px;
    padding: 7px 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

input[type="file"] {
    max-width: 280px;
    padding: 6px;
}

/* Alerts */
.alert {
    border-radius: 10px;
    font-weight: 600;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid transparent;
}

.alert.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--danger);
}

.alert.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: var(--success);
}

.alert.warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: var(--warning);
}

.message-list {
    margin: 0;
    padding-left: 20px;
}

.message-list li {
    margin-bottom: 6px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: #f8fafc;
}

.number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.row-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Photo cells */
.products-table { min-width: 1120px; }

.clickable-row {
    cursor: pointer;
}

.clickable-row td a,
.clickable-row td button {
    pointer-events: auto;
}

.clickable-row td form {
    pointer-events: none;
}

.clickable-row td form input,
.clickable-row td form button {
    pointer-events: auto;
}

.clickable-row td select,
.clickable-row td textarea {
    pointer-events: auto;
}

.description { min-width: 260px; }

.photo-cell {
    width: 92px;
}

.photo-cell img {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    height: 68px;
    object-fit: contain;
    width: 68px;
    background: #fff;
}

.photo-placeholder {
    align-items: center;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 500;
    height: 68px;
    justify-content: center;
    width: 68px;
}

.upload-inline {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 7px;
}

.photo-actions {
    align-items: center;
    display: flex;
    gap: 7px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
    font-size: 13px;
}

/* Tags */
.tag {
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 999px;
    color: #9a3412;
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    margin-top: 4px;
    padding: 2px 8px;
    vertical-align: middle;
    line-height: 1.4;
}

.tag-new {
    background: #f0fdf4;
    border-color: #86efac;
    color: var(--success);
}

.tag-update {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

.promo-active-badge {
    background: var(--success);
    border-radius: 999px;
    color: #ffffff;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    text-transform: uppercase;
    vertical-align: middle;
}

.promo-price {
    color: var(--success);
    font-size: 18px;
    font-weight: 700;
}

.promo-overline {
    color: var(--muted);
    text-decoration: line-through;
}

.promo-cover {
    align-items: center;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 720px;
    padding: 48px;
    text-align: center;
}

.promo-cover h1 {
    font-size: 48px;
    margin: 0 0 18px;
}

.promo-cover .validity {
    color: var(--muted);
    font-size: 18px;
    margin: 0 0 32px;
}

.promo-cover .discount-badge {
    background: var(--success);
    border-radius: 8px;
    color: #ffffff;
    font-size: 32px;
    font-weight: 700;
    padding: 18px 36px;
}

.promo-cover .meta {
    color: var(--muted);
    margin-top: 28px;
}

.promo-validity {
    font-size: 12px;
    white-space: nowrap;
}

.cover-break {
    page-break-after: always;
}

.print-photo {
    width: 92px;
}

.print-toolbar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 22px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.print-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.print-sheet {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.print-sheet.supplier-sheet {
    padding: 0;
    overflow: hidden;
}

.supplier-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.supplier-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 6px;
}

.supplier-header span {
    color: var(--muted);
    font-size: 13px;
}

.promo-price {
    color: var(--success);
    font-size: 18px;
    font-weight: 700;
}

.promo-overline {
    color: var(--muted);
    text-decoration: line-through;
}

.promo-banner {
    background: var(--success);
    border-radius: 8px;
    color: #ffffff;
    margin: 0 22px 18px;
    padding: 14px;
    text-align: center;
}

.print-logo {
    max-height: 60px;
    max-width: 200px;
}

/* Product summary */
.product-summary {
    align-items: flex-start;
    display: flex;
    gap: 18px;
    margin-bottom: 18px;
}

.summary-photo img,
.photo-placeholder.large {
    height: 128px;
    width: 128px;
}

.product-summary h2 {
    font-size: 20px;
    line-height: 1.25;
    margin: 0 0 12px;
    font-weight: 700;
}

.details-list {
    display: grid;
    gap: 8px;
    margin: 0;
}

.details-list div {
    display: grid;
    gap: 6px;
    grid-template-columns: 120px minmax(0, 1fr);
}

.details-list dt {
    color: var(--muted);
    font-weight: 600;
}

.details-list dd {
    margin: 0;
}

.wide-field {
    min-width: min(520px, 100%);
}

.wide-field input {
    width: 100%;
}

/* Image results */
.image-result-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.image-result {
    border: 1px solid var(--line);
    border-radius: 12px;
    display: grid;
    gap: 10px;
    padding: 12px;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.image-result:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

.image-result-preview {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    height: 160px;
    justify-content: center;
    overflow: hidden;
}

.image-result-preview img {
    display: block;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.image-result h3 {
    font-size: 14px;
    line-height: 1.3;
    margin: 0;
    min-height: 36px;
    font-weight: 600;
}

.image-result p {
    color: var(--muted);
    font-size: 12px;
    margin: 0;
    min-height: 18px;
}

.result-actions {
    align-items: center;
    display: flex;
    gap: 8px;
}

/* Review cards */
.review-queue {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.review-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    display: grid;
    gap: 10px;
    padding: 14px;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.review-card:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.review-card .image-result-preview {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    height: 160px;
    justify-content: center;
    overflow: hidden;
}

.review-card .image-result-preview img {
    display: block;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.review-product-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.review-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

/* Utilities */
.inline {
    display: inline;
}

.selected-list {
    margin: 0;
    padding-left: 20px;
}

.selected-list li {
    margin-bottom: 4px;
}

/* Responsive */
@media (max-width: 760px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .page {
        padding: 20px;
    }

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

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .product-summary {
        display: block;
    }

    .summary-photo {
        margin-bottom: 14px;
    }

    .details-list div {
        grid-template-columns: 1fr;
    }

    th, td {
        padding: 8px 10px;
        font-size: 13px;
    }

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

    .actions-row {
        flex-direction: column;
    }

    .actions-row .button {
        width: auto;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .page {
        padding: 16px;
    }

    .panel {
        padding: 14px;
        border-radius: 10px;
    }
}

/* Print */
@media print {
    body {
        background: #ffffff;
    }

    .sidebar,
    .hamburger,
    .sidebar-overlay {
        display: none !important;
    }

    .main {
        margin-left: 0;
    }

    .print-toolbar {
        display: none;
    }

    .print-sheet {
        box-shadow: none;
        margin: 0;
        max-width: none;
        min-height: 0;
        padding: 0;
    }

    .print-sheet.page-numbered::after {
        align-items: center;
        bottom: 18px;
        color: var(--muted);
        content: "Pagina " counter(page);
        display: flex;
        font-size: 12px;
        justify-content: flex-end;
        left: 0;
        position: absolute;
        right: 0;
    }

    .print-sheet.compact {
        padding: 14px;
    }

    .print-sheet.compact .price-list {
        font-size: 11px;
    }

    .print-sheet.compact .price-list th,
    .print-sheet.compact .price-list td {
        padding: 5px;
    }

    .print-sheet.photographic .print-photo img {
        height: 110px;
        width: 110px;
    }

    .supplier-sheet {
        page-break-after: always;
    }

    th {
        background: #f2f4f7 !important;
    }

    .panel, .stat {
        box-shadow: none;
        border: 1px solid #d8dee8;
    }
}
