:root {
    --ink: #1a232b;
    --ink-soft: #4f5b66;
    --paper: #f6f0e6;
    --surface: #ffffff;
    --accent: #d46b2d;
    --accent-strong: #9f4d1f;
    --sea: #1f6d6f;
    --olive: #3d6b4c;
    --glow: 0 24px 50px rgba(26, 35, 43, 0.12);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Optima", "Candara", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 10% 0%, #f3d7c4 0%, transparent 45%),
        radial-gradient(circle at 80% 10%, #bfe1de 0%, transparent 45%),
        radial-gradient(circle at 30% 80%, #f3e3c5 0%, transparent 55%),
        linear-gradient(160deg, #f7f2ea 0%, #f0ebe1 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Modo embebido en app móvil */
body.mobile-app {
    --ink: #1f2937;
    --ink-soft: #64748b;
    --paper: #f8fafc;
    --surface: #ffffff;
    --accent: #1e3a8a;
    --accent-strong: #1d4ed8;
    --glow: 0 12px 28px rgba(15, 23, 42, 0.12);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

body.mobile-app .page-header h2,
body.mobile-app .stat-card strong,
body.mobile-app .sidebar-header h1 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body.mobile-app .nav-item.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.26);
}

/* Ocultar Nuevo Ticket en modo app (desktop + móvil) */
body.mobile-app a[href*="page=nuevo"] {
    display: none !important;
}

/* Layout principal */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid rgba(26, 35, 43, 0.08);
    box-shadow: 4px 0 24px rgba(26, 35, 43, 0.06);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink-soft);
    text-decoration: none;
    transition: all 0.2s;
    margin: 16px 24px 0;
}

.sidebar-back:hover {
    background: var(--accent);
    color: #fff;
}

.sidebar-header {
    padding: 16px 24px 20px;
    border-bottom: 1px solid rgba(26, 35, 43, 0.06);
}

.sidebar-header-title,
.sidebar-header-title * {
    text-decoration: none !important;
    border-bottom: 0 !important;
}

.sidebar-header-title {
    display: inline-block;
    cursor: pointer;
}

.sidebar-header h1 {
    margin: 0;
    font-family: "Bodoni MT", "Didot", "Times New Roman", serif;
    font-size: 1.8rem;
    letter-spacing: 1px;
    color: var(--ink);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-panel-link {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 12px;
    padding: 14px 16px;
    background: var(--paper);
    border: 1px solid rgba(26, 35, 43, 0.08);
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.sidebar-panel-link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(26, 35, 43, 0.04);
    color: var(--ink);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: white;
    box-shadow: 0 4px 12px rgba(212, 107, 45, 0.3);
}

.nav-item svg {
    flex-shrink: 0;
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 32px 40px;
    position: relative;
    z-index: 1;
}

/* Page header */
.page-header {
    margin-bottom: 32px;
}

.page-header h2 {
    margin: 0 0 8px;
    font-family: "Bodoni MT", "Didot", "Times New Roman", serif;
    font-size: 2rem;
    letter-spacing: 0.5px;
}

.page-header p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 1rem;
}

/* Panel styles */
.panel {
    margin-bottom: 24px;
    padding: 26px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--glow);
    border: 1px solid rgba(26, 35, 43, 0.08);
    animation: rise 0.6s ease both;
}

h2 {
    margin: 0 0 16px;
    font-size: 1.3rem;
    letter-spacing: 0.4px;
}

h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

/* Stats grid */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stats.panel {
    padding: 0;
    background: transparent;
    box-shadow: none;
    border: none;
}

.stat-card {
    padding: 22px 24px;
    border-radius: var(--radius-md);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid rgba(26, 35, 43, 0.08);
    box-shadow: var(--glow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.stat-card-link:focus-visible {
    outline: 2px solid rgba(26, 35, 43, 0.35);
    outline-offset: 2px;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 30px 60px rgba(26, 35, 43, 0.15);
}

.stat-card.urgente {
    border-left: 4px solid #c0392b;
}

.stat-card.pendiente {
    border-left: 4px solid #d46b2d;
}

.stat-card.hecho {
    border-left: 4px solid var(--olive);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card strong {
    font-size: 2.2rem;
    font-family: "Bodoni MT", "Didot", "Times New Roman", serif;
}

/* Grid de cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 22px;
}

.card {
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--glow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    border: 1px solid rgba(26, 35, 43, 0.08);
    animation: rise 0.6s ease both;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(26, 35, 43, 0.04);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 30px 60px rgba(26, 35, 43, 0.18);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.estado-pendiente {
    background: #f6d7c7;
    color: #7d2b1a;
}

.estado-en_progreso {
    background: #f3e7b6;
    color: #7a5a19;
}

.estado-hecho {
    background: #cfe8df;
    color: #1f5b3c;
}

.prioridad-baja {
    background: #d7e9f0;
    color: #2a5f6f;
}

.prioridad-media {
    background: #f4e7c0;
    color: #7a5a19;
}

.prioridad-alta {
    background: #f6c4b6;
    color: #8f2c23;
}

.prioridad-critica {
    background: #f3b0a6;
    color: #7a1510;
}

.card img {
    width: 100%;
    height: 170px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Progress bar */
.progress {
    height: 9px;
    background: #efe7db;
    border-radius: 999px;
    overflow: hidden;
}

.progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--sea), var(--accent));
}

/* Forms */
form {
    display: grid;
    gap: 14px;
}

.form-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Formulario nuevo con mas espacio */
.panel-wide {
    max-width: none;
    width: 100%;
}

.form-grid-nuevo {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 24px;
}

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

.form-field-spacer {
    margin-bottom: 24px;
}

.form-field-spacer label {
    display: block;
    margin-bottom: 8px;
}

.image-uploads {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.image-upload-item {
    padding: 16px;
    background: #faf7f2;
    border-radius: var(--radius-sm);
    border: 2px dashed rgba(26, 35, 43, 0.15);
    transition: border-color 0.2s ease;
}

.image-upload-item:hover {
    border-color: var(--accent);
}

.image-upload-item input[type="file"] {
    border: none;
    background: transparent;
    padding: 0;
}

.image-remove-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: none;
    color: var(--ink-soft);
}

.image-remove-label input[type="checkbox"] {
    width: auto;
}

label {
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(26, 35, 43, 0.12);
    background: #fffaf3;
    font: inherit;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 107, 45, 0.18);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

/* Actions */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.actions textarea {
    min-height: 70px;
    max-width: 260px;
    background: #fff6ea;
}

button,
.btn-link {
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-weight: 700;
    cursor: pointer;
    background: var(--accent);
    color: white;
    font: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.btn-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(212, 107, 45, 0.25);
}

.btn-secondary {
    background: var(--olive);
}

.btn-secondary:hover {
    box-shadow: 0 10px 20px rgba(61, 107, 76, 0.25);
}

.btn-muted {
    background: #d8cbb8;
    color: #2f2b26;
}

.btn-muted:hover {
    box-shadow: 0 10px 20px rgba(26, 35, 43, 0.15);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 10px;
}

.btn-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Filters */
.filters {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
}

.filters-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filters-actions-row form {
    margin: 0;
}

.inline-action-form {
    display: inline-flex !important;
    gap: 0;
    margin: 0;
    vertical-align: middle;
    width: auto !important;
    max-width: max-content;
    flex: 0 0 auto;
}

.filters-actions-row button,
.filters-actions-row .btn-link,
.inline-action-form button {
    width: auto !important;
    min-width: 0;
    display: inline-flex;
    white-space: nowrap;
}

.filters-actions-row .btn-compact {
    padding: 6px 12px !important;
    font-size: 0.82rem;
    line-height: 1.05;
    border-radius: 10px;
}

.btn-download-pdf {
    padding-left: 12px !important;
    padding-right: 12px !important;
}

/* Utils */
.note {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.tag {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    background: #efe3d0;
    font-size: 0.78rem;
}

.checklist {
    padding-left: 18px;
    margin: 0;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.msg {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: #d9ece4;
    color: #1f5b3c;
    font-weight: 700;
    margin-bottom: 16px;
}

.msg-error {
    background: #f6c4b6;
    color: #7a1510;
}

.quick-search-panel {
    margin-bottom: 24px;
}

.quick-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    min-width: 260px;
}

.quick-search-form input[type="number"] {
    flex: 1;
    max-width: 220px;
}

.quick-profile-btn {
    margin-left: auto;
}

.perfil-select-panel {
    margin-bottom: 18px;
}

.perfil-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.perfil-selector-card {
    text-decoration: none;
    color: inherit;
    background: #faf5ee;
    border: 1px solid rgba(26, 35, 43, 0.1);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.perfil-selector-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(26, 35, 43, 0.12);
    border-color: rgba(212, 107, 45, 0.45);
}

.perfil-selector-card.active {
    border-color: rgba(212, 107, 45, 0.7);
    box-shadow: 0 8px 20px rgba(212, 107, 45, 0.18);
}

.perfil-selector-avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    font-weight: 700;
}

.perfil-selector-name {
    font-weight: 700;
}

.perfil-panel {
    position: relative;
    overflow: hidden;
    background: linear-gradient(160deg, #fff6ef 0%, #ffffff 65%);
}

.perfil-panel::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    right: -60px;
    top: -70px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 107, 45, 0.2) 0%, rgba(212, 107, 45, 0) 70%);
    pointer-events: none;
}

.perfil-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.perfil-avatar {
    width: 72px;
    height: 72px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    box-shadow: 0 10px 22px rgba(212, 107, 45, 0.35);
}

.perfil-identidad h3 {
    margin: 0;
    font-size: 1.2rem;
}

.perfil-identidad p {
    margin: 3px 0 0;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.perfil-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    position: relative;
    z-index: 1;
}

.perfil-stat {
    background: #faf5ee;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(26, 35, 43, 0.1);
    padding: 14px;
    display: grid;
    gap: 6px;
}

.perfil-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-soft);
    font-weight: 700;
}

.perfil-stat strong {
    font-size: 1.4rem;
    line-height: 1.1;
}

.perfil-streak {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.9rem;
}

.perfil-streak.is-hot {
    background: #ffe1d1;
    color: #8f2c23;
    animation: pulse-fire 1.2s ease-in-out infinite;
}

.perfil-streak.is-cold {
    background: #dff1ff;
    color: #2a5f6f;
    animation: fall-snow 1.7s ease-in-out infinite;
}

.perfil-stat-note {
    color: var(--ink-soft);
    font-size: 0.82rem;
}

@keyframes pulse-fire {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.06);
    }
}

@keyframes fall-snow {
    0% {
        transform: translateY(-1px);
    }
    50% {
        transform: translateY(3px);
    }
    100% {
        transform: translateY(-1px);
    }
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.chart-widget {
    min-height: 280px;
}

.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Donut Chart */
.donut-chart {
    position: relative;
    width: 160px;
    height: 160px;
}

.donut-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut-segment {
    transition: stroke-width 0.2s ease;
}

.donut-segment:hover {
    stroke-width: 5;
}

.pie-chart {
    width: 160px;
    height: 160px;
}

.pie-svg {
    width: 100%;
    height: 100%;
}

.pie-link {
    cursor: pointer;
}

.pie-segment {
    stroke: #ffffff;
    stroke-width: 0.6;
    transform-origin: 18px 18px;
    transition: transform 0.15s ease;
}

.pie-segment:hover {
    transform: scale(1.06);
}

.pie-caption {
    min-height: 1.1rem;
    font-size: 0.78rem;
    color: var(--ink-soft);
    text-align: center;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-total {
    display: block;
    font-family: "Bodoni MT", "Didot", "Times New Roman", serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
}

.donut-label {
    display: block;
    font-size: 0.75rem;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-label {
    color: var(--ink-soft);
}

.legend-value {
    font-weight: 700;
    color: var(--ink);
}

/* Ticket calendar */
.ticket-calendar-panel {
    margin-bottom: 24px;
}

.ticket-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.ticket-calendar-header h3 {
    margin: 0;
}

.ticket-calendar-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ticket-calendar-nav strong {
    font-size: 0.95rem;
}

.ticket-calendar-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    color: var(--ink-soft);
    font-size: 0.82rem;
    margin-bottom: 12px;
}

.ticket-calendar-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.ticket-calendar-dot.closed {
    background: #3d6b4c;
}

.ticket-calendar-dot.due {
    background: #d46b2d;
}

.ticket-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0;
    border: 1px solid rgba(212, 167, 45, 0.45);
    border-radius: 14px;
    overflow: hidden;
}

.ticket-calendar-weekday {
    text-align: center;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
    background: #efe7c9;
    border-right: 1px solid rgba(212, 167, 45, 0.45);
    border-bottom: 1px solid rgba(212, 167, 45, 0.45);
}

.ticket-calendar-weekday:nth-child(7n) {
    border-right: 0;
}

.ticket-calendar-day {
    min-height: 96px;
    background: #ececec;
    border-right: 1px solid rgba(212, 167, 45, 0.45);
    border-bottom: 1px solid rgba(212, 167, 45, 0.45);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ticket-calendar-day.has-events {
    background: #efefef;
}

.ticket-calendar-day.is-today {
    background: #efe6b2;
    box-shadow: inset 0 0 0 2px #e1ac0b;
}

.ticket-calendar-day-empty {
    background: #efe7c9;
}

.ticket-calendar-grid .ticket-calendar-day:nth-child(7n) {
    border-right: 0;
}

.ticket-calendar-grid .ticket-calendar-day:nth-last-child(-n + 7) {
    border-bottom: 0;
}

.ticket-calendar-day-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.ticket-calendar-day-num {
    font-weight: 700;
    font-size: 0.9rem;
}

.ticket-calendar-day-counts {
    display: flex;
    gap: 4px;
}

.ticket-calendar-count {
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.ticket-calendar-count.closed {
    background: #3d6b4c;
}

.ticket-calendar-count.due {
    background: #d46b2d;
}

.ticket-calendar-count.total {
    background: #9dcfb0;
    color: #155138;
}

/* Bar Chart */
.bar-chart {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 8px;
}

.bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 40px;
    align-items: center;
    gap: 12px;
}

.bar-label {
    font-size: 0.68rem;
    color: var(--ink-soft);
    text-align: right;
    white-space: normal;
    line-height: 1.2;
    overflow-wrap: anywhere;
    max-height: calc(1.2em * 2);
    overflow: hidden;
    text-overflow: clip;
}

.bar-track {
    height: 24px;
    background: #efe7db;
    border-radius: 6px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease;
    min-width: 4px;
}

.bar-value {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--ink);
}

/* Dashboard widgets */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.widget {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--glow);
    border: 1px solid rgba(26, 35, 43, 0.08);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.widget-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.widget-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.widget-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #faf7f2;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.widget-item:hover {
    background: #f5f0e8;
}

.widget-item-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.widget-item-link:hover {
    background: var(--surface);
    box-shadow: 0 4px 12px rgba(26, 35, 43, 0.08);
}

.widget-item-arrow {
    flex-shrink: 0;
    color: var(--ink-soft);
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.widget-item-link:hover .widget-item-arrow {
    opacity: 1;
    transform: translateX(2px);
}

.widget-item-content {
    flex: 1;
    min-width: 0;
}

.widget-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-item-title .ticket-num {
    color: var(--ink-soft);
    font-weight: 500;
    margin-right: 4px;
}

.widget-item-meta {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

/* Task list */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #faf7f2;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--ink);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.task-row:hover {
    background: var(--surface);
    border-color: rgba(26, 35, 43, 0.08);
    box-shadow: 0 4px 12px rgba(26, 35, 43, 0.08);
}

.task-status {
    flex-shrink: 0;
}

.task-info {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.task-desc {
    font-size: 0.9rem;
    color: var(--ink-soft);
    margin-bottom: 6px;
    white-space: pre-wrap;
}

.task-tags {
    display: inline-flex;
    gap: 4px;
}

.task-tags .tag {
    padding: 2px 6px;
    font-size: 0.7rem;
}

.task-priority {
    flex-shrink: 0;
}

.task-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.task-progress-text {
    font-size: 0.85rem;
    color: var(--ink-soft);
    min-width: 36px;
}

.task-arrow {
    flex-shrink: 0;
    color: var(--ink-soft);
}

.task-row-finalizadas {
    gap: 12px;
}

.task-row-finalizadas .task-priority {
    margin-left: auto;
}

/* Ficha */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 12px;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--accent);
}

/* Numero de ticket */
.ticket-number {
    display: inline-block;
    font-family: "Bodoni MT", "Didot", "Times New Roman", serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(212, 107, 45, 0.1);
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

h2 .ticket-number {
    font-size: 0.9rem;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 0;
}

.task-ticket-number {
    flex-shrink: 0;
    font-family: "Bodoni MT", "Didot", "Times New Roman", serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 50px;
}

.ficha-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

.ficha-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ficha-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ficha-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.ficha-details {
    margin: 0;
}

.ficha-details dt {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-soft);
    margin-bottom: 4px;
}

.ficha-details dd {
    margin: 0 0 16px 0;
    font-weight: 500;
}

.ficha-details dd:last-child {
    margin-bottom: 0;
}

/* Animations */
@keyframes rise {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        width: 70px;
        overflow: hidden;
    }

    .sidebar-header h1 {
        font-size: 1.2rem;
        text-align: center;
    }

    .nav-item {
        justify-content: center;
        padding: 14px;
    }

    .nav-item span,
    .nav-item:not(:has(svg))::after {
        display: none;
    }

    .main-content {
        margin-left: 70px;
        padding: 24px 20px;
    }
}

@media (max-width: 600px) {
    .sidebar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid rgba(26, 35, 43, 0.08);
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        padding: 8px;
        width: 100%;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 10px 16px;
        font-size: 0.75rem;
    }

    .main-content {
        margin-left: 0;
        margin-bottom: 80px;
        padding: 20px 16px;
    }

    .quick-search-form {
        min-width: 100%;
        flex-wrap: wrap;
    }

    .quick-search-form input[type="number"] {
        max-width: none;
    }

    .quick-profile-btn {
        margin-left: 0;
    }

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

    .actions textarea {
        max-width: 100%;
    }

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

    .ficha-sidebar {
        order: -1;
    }

    .task-row {
        flex-wrap: wrap;
    }

    .task-priority,
    .task-progress {
        display: none;
    }

    .task-info {
        flex-basis: calc(100% - 120px);
    }

    .ticket-calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        border: 0;
    }

    .ticket-calendar-weekday {
        display: none;
    }

    .ticket-calendar-day {
        min-height: 110px;
        border: 1px solid rgba(212, 167, 45, 0.45);
        border-radius: 10px;
    }
}
