*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange: #e8792f;
  --orange-light: #f5a623;
  --orange-bg: #fef6ee;
  --orange-border: #fdd9b5;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --yellow: #d97706;
  --yellow-bg: #fffbeb;
  --yellow-border: #fde68a;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --gray: #6b7280;
  --bg: #f5f5f6;
  --card: #ffffff;
  --border: #e2e4e8;
  --text: #1a1d23;
  --text-light: #6b7280;
  --sidebar-bg: #2a2d35;
  --sidebar-text: #b0b4bc;
  --sidebar-active: #e8792f;
  --sem-off: #d1d5db;
}

body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ====== LOGIN ====== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2a2d35 0%, #1a1d23 100%); }
.login-card { background: white; border-radius: 16px; padding: 40px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 12px; }
.login-logo p { color: var(--text-light); font-size: 13px; margin-top: 4px; }
.login-logo .icon { font-size: 40px; }

/* ====== LAYOUT ====== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform 0.3s; }
.sidebar-header { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-header h2 { font-size: 14px; font-weight: 800; color: white; line-height: 1.3; }
.sidebar-header p { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; transition: all 0.15s; color: var(--sidebar-text); font-size: 13px; font-weight: 500; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: var(--sidebar-active); color: white; border-radius: 0; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--orange); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: white; flex-shrink: 0; }
.user-info .name { font-size: 13px; font-weight: 600; color: white; }
.user-info .role { font-size: 11px; color: var(--sidebar-text); }
.main-content { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { background: white; border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar h1 { font-size: 16px; font-weight: 700; }
.page-content { padding: 24px; flex: 1; }

/* ====== FORMS ====== */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; background: white; color: var(--text); transition: border-color 0.15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(232,121,47,0.1); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 11px; color: var(--text-light); margin-top: 4px; }

/* ====== BUTTONS ====== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit; border: none; cursor: pointer; transition: all 0.15s; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--orange); color: white; }
.btn-primary:hover:not(:disabled) { background: #d06a24; }
.btn-success { background: var(--green); color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-warning { background: var(--yellow); color: white; }
.btn-warning:hover:not(:disabled) { background: #b45309; }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

/* ====== CARDS ====== */
.card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 15px; font-weight: 700; }

/* ====== SEMAPHORE ====== */
.semaphore { display: flex; align-items: center; gap: 4px; }
.sem-light { width: 16px; height: 16px; border-radius: 50%; background: var(--sem-off); border: 2px solid rgba(0,0,0,0.1); transition: all 0.3s; }
.sem-light.red { background: var(--red); box-shadow: 0 0 8px rgba(220,38,38,0.5); }
.sem-light.yellow { background: var(--orange-light); box-shadow: 0 0 8px rgba(245,166,35,0.5); }
.sem-light.green { background: var(--green); box-shadow: 0 0 8px rgba(22,163,74,0.5); }
.sem-light.pulse { animation: semPulse 1.5s infinite; }
@keyframes semPulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.semaphore-row { display: flex; gap: 20px; align-items: center; padding: 12px 0; }
.sem-phase { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sem-phase-label { font-size: 10px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.sem-phase-light { width: 28px; height: 28px; border-radius: 50%; background: var(--sem-off); border: 3px solid rgba(0,0,0,0.08); transition: all 0.3s; }
.sem-phase-light.red { background: var(--red); border-color: #b91c1c; box-shadow: 0 0 12px rgba(220,38,38,0.4); }
.sem-phase-light.yellow { background: var(--orange-light); border-color: #d97706; box-shadow: 0 0 12px rgba(245,166,35,0.4); }
.sem-phase-light.green { background: var(--green); border-color: #15803d; box-shadow: 0 0 12px rgba(22,163,74,0.4); }
.sem-phase-light.pulse { animation: semPulse 1.5s infinite; }
.sem-connector { width: 30px; height: 3px; background: var(--sem-off); margin-top: -14px; }
.sem-connector.done { background: var(--green); }

/* ====== STATUS BADGES ====== */
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-red { background: var(--red-bg); color: var(--red); border: 1.5px solid var(--red-border); }
.status-orange { background: var(--orange-bg); color: var(--orange); border: 1.5px solid var(--orange-border); }
.status-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1.5px solid var(--yellow-border); }
.status-green { background: var(--green-bg); color: var(--green); border: 1.5px solid var(--green-border); }
.status-blue { background: var(--blue-bg); color: var(--blue); border: 1.5px solid var(--blue-border); }
.status-gray { background: #f9fafb; color: var(--gray); border: 1.5px solid var(--border); }

/* ====== OPERATION CARDS ====== */
.op-card { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 16px; margin-bottom: 12px; cursor: pointer; transition: all 0.15s; border-left: 4px solid transparent; }
.op-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); transform: translateY(-1px); }
.op-card.border-red { border-left-color: var(--red); }
.op-card.border-orange { border-left-color: var(--orange); }
.op-card.border-green { border-left-color: var(--green); }
.op-card.border-gray { border-left-color: var(--gray); }
.op-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.op-card-title { font-size: 15px; font-weight: 700; }
.op-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-light); margin-top: 4px; }
.op-card-meta span { display: flex; align-items: center; gap: 4px; }
.op-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.op-type-chip { display: inline-flex; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.op-type-chip.realtime { background: var(--blue-bg); color: var(--blue); }
.op-type-chip.memorized { background: var(--orange-bg); color: var(--orange); }

/* ====== PHASE TIMELINE ====== */
.phase-timeline { display: flex; align-items: center; gap: 0; margin: 16px 0; }
.phase-step { flex: 1; position: relative; }
.phase-step-inner { text-align: center; position: relative; }
.phase-step-circle { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; margin: 0 auto 6px; border: 3px solid var(--border); background: white; }
.phase-step-circle.done { background: var(--green); border-color: var(--green); }
.phase-step-circle.active { background: var(--orange); border-color: var(--orange); animation: pulsePhase 2s infinite; }
.phase-step-circle.pending { background: white; border-color: var(--border); }
.phase-step-circle.waiting { background: var(--orange-bg); border-color: var(--orange); }
.phase-step-label { font-size: 11px; font-weight: 600; color: var(--text-light); }
.phase-connector { width: 100%; height: 3px; background: var(--border); position: absolute; top: 20px; left: 50%; z-index: 0; }
.phase-connector.done { background: var(--green); }
@keyframes pulsePhase { 0%,100%{box-shadow:0 0 0 0 rgba(232,121,47,0.4)} 50%{box-shadow:0 0 0 8px rgba(232,121,47,0)} }

/* ====== EVIDENCE ====== */
.evidence-section { margin-top: 20px; }
.evidence-category { margin-bottom: 20px; }
.evidence-category h4 { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.evidence-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); border-radius: 8px; margin-bottom: 6px; }
.evidence-icon { font-size: 20px; flex-shrink: 0; }
.evidence-info { flex: 1; min-width: 0; }
.evidence-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evidence-meta { font-size: 11px; color: var(--text-light); }

/* ====== UPLOAD ZONE ====== */
.upload-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; cursor: pointer; transition: all 0.15s; background: var(--bg); }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--orange); background: var(--orange-bg); }
.upload-zone p { color: var(--text-light); font-size: 13px; margin-top: 8px; }

/* ====== BATTERY MODULE ====== */
.battery-card { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 16px; margin-bottom: 12px; transition: all 0.15s; }
.battery-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.battery-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.battery-serial { font-size: 15px; font-weight: 700; font-family: 'Courier New', monospace; }
.battery-brand { font-size: 12px; color: var(--text-light); }
.battery-bar-container { width: 100%; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.battery-bar { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.battery-bar.high { background: var(--green); }
.battery-bar.medium { background: var(--orange); }
.battery-bar.low { background: var(--red); }
.battery-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-light); }
.battery-alert { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; margin-top: 8px; }
.battery-alert.warning { background: var(--yellow-bg); color: var(--yellow); }
.battery-alert.danger { background: var(--red-bg); color: var(--red); }
.calc-result { padding: 16px; border-radius: 10px; margin-top: 12px; }
.calc-result.ok { background: var(--green-bg); border: 1px solid var(--green-border); }
.calc-result.fail { background: var(--red-bg); border: 1px solid var(--red-border); }
.calc-result h4 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.calc-result p { font-size: 13px; margin: 2px 0; }

/* ====== TABS ====== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 20px; font-size: 13px; font-weight: 600; color: var(--text-light); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ====== STATS ====== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 20px; text-align: center; }
.stat-number { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-light); font-weight: 500; margin-top: 4px; }

/* ====== DETAIL VIEW ====== */
.detail-header { margin-bottom: 24px; }
.detail-back { display: inline-flex; align-items: center; gap: 6px; color: var(--orange); font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 16px; text-decoration: none; }
.detail-back:hover { text-decoration: underline; }
.detail-title { font-size: 22px; font-weight: 800; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.detail-meta-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-light); }

/* ====== ALERTS ====== */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-info { background: var(--blue-bg); color: #1e40af; border: 1px solid var(--blue-border); }
.alert-success { background: var(--green-bg); color: #15803d; border: 1px solid var(--green-border); }
.alert-warning { background: var(--yellow-bg); color: #92400e; border: 1px solid var(--yellow-border); }
.alert-danger { background: var(--red-bg); color: #991b1b; border: 1px solid var(--red-border); }

/* ====== COMMENTS ====== */
.comment { display: flex; gap: 10px; margin-bottom: 12px; }
.comment-bubble { background: var(--bg); border-radius: 10px; padding: 10px 14px; flex: 1; }
.comment-bubble.supervisor { background: var(--orange-bg); }
.comment-author { font-size: 12px; font-weight: 700; }
.comment-text { font-size: 13px; margin-top: 2px; }
.comment-time { font-size: 11px; color: var(--text-light); }

/* ====== NOTIFICATIONS ====== */
.notif-list { max-height: 500px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; cursor: pointer; transition: background 0.15s; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--orange-bg); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); flex-shrink: 0; margin-top: 5px; }
.notif-text { flex: 1; }
.notif-time { font-size: 11px; color: var(--text-light); }

/* ====== MODAL ====== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto; }
.modal { background: white; border-radius: 16px; width: 100%; max-width: 600px; margin: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ====== MISC ====== */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 10px; font-weight: 700; background: var(--orange); color: white; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; background: var(--bg); color: var(--text-light); border: 1px solid var(--border); }
.chip.sro { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--text-light); font-size: 13px; }
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 10px; color: white; font-size: 13px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,0.2); animation: slideIn 0.3s ease; max-width: 320px; display: flex; align-items: center; gap: 8px; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--orange); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--orange); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: flex; align-items: center; justify-content: center; min-height: 200px; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-light); }
.font-bold { font-weight: 700; }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; font-size: 20px; }
.overlay-close { position: fixed; inset: 0; z-index: 99; display: none; }
.sidebar.open ~ .overlay-close { display: block; }

/* ====== TABLE ====== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; background: var(--bg); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); border-bottom: 2px solid var(--border); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: var(--bg); }
.data-table .mono { font-family: 'Courier New', monospace; font-weight: 600; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .phase-step-label { font-size: 9px; }
  .hamburger { display: flex !important; }
  .page-content { padding: 16px; }
  .semaphore-row { gap: 12px; }
  .sem-connector { width: 16px; }
}
