/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f3f4f6;
    color: #333;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.2rem;
    border-bottom: 1px solid #334155;
    text-align: center;
}

.sidebar-header .logo-icon {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.sidebar-header .company-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-header .company-rut {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 0.2rem;
}

.sidebar-menu {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 0.7rem 1.2rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: #334155;
    color: #fff;
    border-left-color: #3b82f6;
}

.sidebar-menu li a .icon {
    width: 22px;
    margin-right: 0.7rem;
    text-align: center;
    font-size: 0.9rem;
}

/* Main wrapper */
.main-wrapper {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.top-header {
    background: #fff;
    padding: 0.8rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-header .page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
}

.top-header .user-area {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.85rem;
    color: #4b5563;
}

.top-header .user-area .btn-logout {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: #374151;
}

.top-header .user-area .btn-logout:hover {
    background: #e5e7eb;
}

/* Content */
.content {
    padding: 1.5rem;
    flex: 1;
}

/* Card / Panel */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
}

.toolbar .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.toolbar .form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.toolbar .form-group input,
.toolbar .form-group select {
    padding: 0.5rem 0.7rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 160px;
    background: #fff;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.9; }

.btn-primary {
    background: #2563eb;
    color: #fff;
}

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

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

/* Table */
.table-wrap {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: #fff;
}

thead th {
    background: #111827;
    color: #fff;
    padding: 0.65rem 0.8rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid #374151;
}

thead th.right {
    text-align: right;
}

tbody td {
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}

tbody tr:nth-child(even) {
    background: #f9fafb;
}

tbody tr:hover {
    background: #f3f4f6;
}

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

tbody td.bold {
    font-weight: 600;
}

tfoot td {
    padding: 0.65rem 0.8rem;
    background: #e5e7eb;
    font-weight: 700;
    border-top: 2px solid #d1d5db;
}

tfoot td.right {
    text-align: right;
}

/* Messages */
.messages {
    margin-bottom: 1rem;
}

.alert {
    padding: 0.8rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Dashboard stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.stat-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 0.4rem;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1f2937;
}

.stat-card .value.green { color: #059669; }
.stat-card .value.red { color: #dc2626; }
.stat-card .value.blue { color: #2563eb; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-header .company-name,
    .sidebar-header .company-rut,
    .sidebar-menu li a span {
        display: none;
    }
    .main-wrapper {
        margin-left: 60px;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}
