:root {
    --blue: #007AFF;
    --blue-dark: #0056CC;
    --blue-light: #E8F2FF;
    --green: #34C759;
    --green-dark: #248A3D;
    --green-light: #E3F9EC;
    --red: #FF3B30;
    --red-dark: #C5221F;
    --red-light: #FDECEB;
    --orange: #FF9500;
    --orange-light: #FFF4E5;
    --gray-50: #F9FAFB;
    --gray-100: #F2F2F7;
    --gray-200: #E5E5EA;
    --gray-300: #D1D1D6;
    --gray-400: #AEAEB2;
    --gray-500: #8E8E93;
    --gray-600: #636366;
    --gray-700: #48484A;
    --gray-800: #3A3A3C;
    --gray-900: #1C1C1E;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 9999px;
    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-slow: 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font); background: var(--gray-100); color: var(--gray-900); line-height: 1.5; overflow-x: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, select, button { font-family: var(--font); font-size: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}
.login-logo p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}
.form-group {
    margin-bottom: 20px;
}
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}
.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--gray-900);
    background: var(--gray-50);
    transition: var(--transition);
}
.form-input:focus {
    outline: none;
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.12);
}
.form-input::placeholder { color: var(--gray-400); }
.form-input-error { border-color: var(--red); }
.form-error { color: var(--red); font-size: 12px; margin-top: 4px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--green-dark); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--red-dark); }
.btn-outline-danger { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.btn-outline-danger:hover:not(:disabled) { background: var(--red-light); }
.btn-ghost { background: transparent; color: var(--gray-500); padding: 8px 12px; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 6px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; }

/* Cards */
.card {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.card-clickable:active { transform: translateY(0); }
.card-body { padding: 20px; }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-red { background: var(--red-light); color: var(--red-dark); }
.badge-orange { background: var(--orange-light); color: #B85C00; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Status dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot-blue { background: var(--blue); }
.status-dot-green { background: var(--green); }
.status-dot-red { background: var(--red); }
.status-dot-orange { background: var(--orange); }
.status-dot-gray { background: var(--gray-300); }

/* App Layout */
.app-layout {
    min-height: 100vh;
    display: flex;
}
.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-slow);
}
.sidebar-brand {
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.sidebar-brand span {
    font-size: 12px;
    color: var(--gray-500);
    display: block;
    margin-top: 2px;
}
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: var(--gray-400);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidebar-link.active { color: #fff; background: rgba(255,255,255,0.1); }
.sidebar-link svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-link .badge {
    margin-left: auto;
    background: var(--orange);
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
}
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer-name { font-size: 14px; font-weight: 600; }
.sidebar-footer-role { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.sidebar-footer .btn { margin-top: 12px; width: 100%; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    background: var(--gray-100);
}
.page-header {
    padding: 32px 40px 24px;
}
.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.page-header p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}
.page-body {
    padding: 0 40px 40px;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.kpi-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}
.kpi-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
}
.kpi-value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
    letter-spacing: -1px;
    line-height: 1.1;
}
.kpi-value-blue { color: var(--blue); }
.kpi-value-green { color: var(--green); }
.kpi-value-red { color: var(--red); }
.kpi-value-orange { color: var(--orange); }

/* List items */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}
.list-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.list-item:active { transform: translateY(0); }
.list-item-info { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 15px; }
.list-item-sub { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.list-item-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Steps Timeline */
.timeline { padding: 0 0 0 8px; }
.timeline-step {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    position: relative;
}
.timeline-step:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 48px;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}
.timeline-step.done:not(:last-child)::before { background: var(--green); }
.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    z-index: 1;
    transition: var(--transition);
}
.timeline-dot-done { background: var(--green); }
.timeline-dot-current { background: var(--blue); animation: pulse 2s infinite; }
.timeline-dot-pending { background: var(--gray-300); }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0,122,255,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(0,122,255,0); }
}
.timeline-content { flex: 1; min-width: 0; }
.timeline-label { font-weight: 600; font-size: 15px; }
.timeline-time { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.timeline-photo {
    margin-top: 10px;
    width: 100px;
    height: 60px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
}
.timeline-photo.captured {
    background: var(--green-light);
    border-color: var(--green);
    color: var(--green-dark);
}

/* Mobile */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--gray-200);
    z-index: 90;
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
}
.mobile-header h2 { font-size: 17px; font-weight: 600; }
.mobile-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 83px;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--gray-200);
    z-index: 90;
    padding: 8px 0 28px;
    display: flex;
    justify-content: space-around;
}
.mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 16px;
}
.mobile-tab.active { color: var(--blue); }
.mobile-tab svg { width: 24px; height: 24px; }

/* Técnico Layout */
.tecnico-layout {
    min-height: 100vh;
    background: var(--gray-100);
}
.tecnico-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    padding: 20px;
    padding-top: 24px;
}
.tecnico-header h2 { font-size: 18px; font-weight: 700; }
.tecnico-header p { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.tecnico-body {
    padding: 20px;
    padding-bottom: 100px;
}

/* Tab Bar */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
}
.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-400);
    cursor: pointer;
    transition: var(--transition);
}
.tab-btn:hover { color: var(--gray-600); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--gray-400);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
    opacity: 1;
    transition: opacity var(--transition);
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal {
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.modal-header h3 { font-size: 20px; font-weight: 700; }
.modal-close {
    background: var(--gray-100);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: var(--transition);
    flex-shrink: 0;
}
.modal-close:hover { background: var(--gray-200); color: var(--gray-700); }
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.toast {
    background: var(--gray-900);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}
.toast-success { background: var(--green-dark); }
.toast-error { background: var(--red-dark); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filter-bar select {
    padding: 8px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: #fff;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
}
.filter-bar select:focus { border-color: var(--blue); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-header { padding: 80px 20px 16px; }
    .page-body { padding: 0 20px 100px; }
    .mobile-header { display: flex; }
    .mobile-tabs { display: flex; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .page-header h1 { font-size: 22px; }
    .tecnico-body { padding-bottom: 100px; }
    .modal { max-width: calc(100vw - 32px); margin: 0 16px; }
    .filter-bar { flex-direction: column; }
    .filter-bar select { width: 100%; }
    .list-item { padding: 14px 16px; }
    .coord-sidebar-open .main-content { display: none; }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Select dropdown */
.select-wrap {
    position: relative;
}
.select-wrap select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    padding: 12px 40px 12px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--gray-50);
    cursor: pointer;
}
.select-wrap::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--gray-400);
    pointer-events: none;
}

/* Section title */
.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--gray-800);
}

/* Divider */
.divider {
    height: 1px;
    background: var(--gray-200);
    margin: 16px 0;
}

/* User list item */
.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; }
.user-meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Slide-in detail panel */
.detail-panel {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    justify-content: flex-end;
    opacity: 1;
    transition: opacity var(--transition);
}
.detail-panel.hidden { opacity: 0; pointer-events: none; }
.detail-panel-inner {
    width: 100%;
    max-width: 520px;
    background: #fff;
    height: 100%;
    overflow-y: auto;
    animation: slideInRight 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -8px 0 32px rgba(0,0,0,0.12);
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.detail-panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}
.detail-panel-body {
    padding: 24px;
}
