/* ============================================================
   PTC TOTALITY — Sistema de Mantenimiento FFS Mi-171
   Estilos Principales + Print
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-dark: #080e1a;
  --bg-card: rgba(15, 25, 50, 0.85);
  --bg-panel: #0f1a2e;
  --bg-sidebar: #091224;

  --accent: #00b4d8;
  --accent-dim: rgba(0, 180, 216, 0.15);
  --accent-glow: rgba(0, 180, 216, 0.4);

  --primary: #1a6b9a;
  --primary-light: #2196c4;
  --success: #2dc653;
  --danger: #e63946;
  --warning: #f4a261;

  --text-primary: #e8edf5;
  --text-secondary: #8899bb;
  --text-muted: #4a5568;

  --border: rgba(0, 180, 216, 0.18);
  --border-solid: #1e2d4a;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-hover: rgba(255, 255, 255, 0.08);

  /* Form/Excel colors */
  --excel-header-bg: #1F3864;
  --excel-header-text: #FFFFFF;
  --excel-section-bg: #2E75B6;
  --excel-section-text: #FFFFFF;
  --excel-row-odd: #FFFFFF;
  --excel-row-even: #EBF5FB;
  --excel-border: #BDD7EE;
  --excel-footer-bg: #D6E4F0;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);

  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 260px;
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-solid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ─── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-mono { font-family: 'Roboto Mono', monospace; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.w-full { width: 100%; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

/* ─── Animated Background ───────────────────────────────────── */
.bg-animated {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, rgba(26, 107, 154, 0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(0, 180, 216, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 60% 80%, rgba(45, 198, 83, 0.05) 0%, transparent 40%),
              var(--bg-dark);
}

.bg-animated::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ─── SCREEN: LOGIN ──────────────────────────────────────────── */
#screen-login {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem;
  gap: 2rem;
}

.login-brand {
  text-align: center;
}

.login-brand .brand-logo {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 20px rgba(0, 180, 216, 0.6));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-brand h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, #ffffff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-brand p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.04) inset;
  animation: slideUp 0.5s ease forwards;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.login-card .login-subtitle {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

/* ─── Form Controls ──────────────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  background: rgba(0, 180, 216, 0.06);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-control::placeholder { color: var(--text-muted); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border: none; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 4px 15px rgba(0, 180, 216, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 180, 216, 0.45);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--glass-hover);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover { color: var(--text-primary); background: var(--glass); }

.btn-danger {
  background: rgba(230, 57, 70, 0.15);
  border: 1px solid rgba(230, 57, 70, 0.3);
  color: var(--danger);
}

.btn-danger:hover { background: rgba(230, 57, 70, 0.25); }

.btn-success {
  background: linear-gradient(135deg, #1a7a3a, #2dc653);
  color: white;
  box-shadow: 0 4px 15px rgba(45, 198, 83, 0.25);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(45, 198, 83, 0.35);
}

.btn-icon {
  padding: 0.5rem;
  font-size: 1rem;
  line-height: 1;
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
}

/* ─── Alert ──────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: flex; align-items: center; gap: 0.5rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.alert-danger {
  background: rgba(230, 57, 70, 0.12);
  border: 1px solid rgba(230, 57, 70, 0.3);
  color: #ff6b75;
}

.alert-success {
  background: rgba(45, 198, 83, 0.12);
  border: 1px solid rgba(45, 198, 83, 0.3);
  color: #5dde80;
}

.alert-info {
  background: rgba(0, 180, 216, 0.12);
  border: 1px solid rgba(0, 180, 216, 0.3);
  color: var(--accent);
}

/* ─── SCREEN: APP ────────────────────────────────────────────── */
#screen-app {
  display: flex;
  min-height: 100vh;
  position: relative; z-index: 1;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, #ffffff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand .brand-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 0.15rem;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.75rem;
}

.user-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
  color: white;
}

.user-info .user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.user-info .user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-section-label {
  padding: 0.5rem 1.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  border-left: 2px solid transparent;
  font-size: 0.82rem;
  color: var(--text-secondary);
  user-select: none;
}

.nav-item:hover {
  background: var(--glass);
  color: var(--text-primary);
  border-left-color: var(--border);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-item .nav-icon {
  font-size: 1rem;
  width: 20px; text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ─── Top Bar ────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  background: rgba(8, 14, 26, 0.9);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

.topbar-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.mobile-menu-btn { display: none; }

/* ─── Dashboard Page ─────────────────────────────────────────── */
#page-dashboard {
  padding: 2rem 1.5rem;
}

.dashboard-header {
  margin-bottom: 2rem;
}

.dashboard-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.dashboard-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--accent);
  background: rgba(0, 180, 216, 0.05);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(26, 107, 154, 0.2); }
.stat-icon.green { background: rgba(45, 198, 83, 0.15); }
.stat-icon.orange { background: rgba(244, 162, 97, 0.15); }
.stat-icon.purple { background: rgba(138, 43, 226, 0.15); }

.stat-info .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* Forms grid */
.forms-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.form-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--accent));
  opacity: 0.8;
  transition: var(--transition);
}

.form-card:hover {
  border-color: var(--card-color, var(--accent));
  background: var(--glass-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--card-color, var(--accent)) inset;
}

.form-card:hover::before { opacity: 1; height: 4px; }

.form-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 0.75rem;
}

.form-card-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.form-card-code {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  font-family: 'Roboto Mono', monospace;
  color: var(--card-color, var(--accent));
  background: rgba(255,255,255,0.06);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}

.form-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-card-freq {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.form-card-pages {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.form-card-action {
  display: flex; align-items: center; gap: 0.25rem;
  color: var(--card-color, var(--accent));
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0;
  transition: var(--transition);
}

.form-card:hover .form-card-action { opacity: 1; }

/* ─── SCREEN: FORM ───────────────────────────────────────────── */
#page-form {
  padding: 0;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 56px);
}

.form-toolbar {
  background: rgba(9, 18, 36, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap;
  position: sticky; top: 56px; z-index: 40;
  backdrop-filter: blur(10px);
}

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

.form-toolbar-info .form-title-display {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-toolbar-info .form-meta-display {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.form-toolbar-actions {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
}

/* Page tabs */
.page-tabs {
  display: flex; gap: 0.25rem;
  padding: 0.75rem 1.5rem 0;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.page-tab {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-bottom: none;
  color: var(--text-secondary);
  white-space: nowrap;
}

.page-tab:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }

.page-tab.active {
  background: var(--bg-dark);
  color: var(--accent);
  border-color: var(--accent);
  border-bottom-color: var(--bg-dark);
}

/* Form content area */
.form-content {
  flex: 1;
  padding: 1.5rem;
  overflow-x: auto;
}

/* ─── MAINTENANCE FORM TABLE ─────────────────────────────────── */
.form-page-wrapper {
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  margin: 0 auto;
}

.form-page-wrapper.landscape { max-width: 1060px; }
.form-page-wrapper.portrait { max-width: 740px; }

/* Form Header */
.form-header {
  background: var(--excel-header-bg);
  color: var(--excel-header-text);
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.form-header-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
}

.form-header-meta {
  text-align: right;
  font-size: 9px;
  line-height: 1.6;
  font-family: 'Roboto Mono', monospace;
  opacity: 0.9;
}

/* Main Table */
.maintenance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5px;
  font-family: 'Inter', Arial, sans-serif;
  table-layout: fixed;
}

.maintenance-table th {
  background: var(--excel-header-bg);
  color: var(--excel-header-text);
  padding: 5px 6px;
  text-align: center;
  font-weight: 700;
  border: 1px solid var(--excel-border);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
  line-height: 1.3;
}

/* Column widths — landscape (standard 7-col) */
.maintenance-table.landscape col.col-item { width: 5%; }
.maintenance-table.landscape col.col-desc { width: 35%; }
.maintenance-table.landscape col.col-tc   { width: 6%; }
.maintenance-table.landscape col.col-note { width: 27%; }
.maintenance-table.landscape col.col-date { width: 10%; }
.maintenance-table.landscape col.col-sign { width: 17%; }

/* Column widths — portrait (6-col GOP6027) */
.maintenance-table.portrait col.col-item { width: 6%; }
.maintenance-table.portrait col.col-desc { width: 40%; }
.maintenance-table.portrait col.col-tc   { width: 8%; }
.maintenance-table.portrait col.col-note { width: 22%; }
.maintenance-table.portrait col.col-date { width: 10%; }
.maintenance-table.portrait col.col-sign { width: 14%; }

.maintenance-table td {
  padding: 4px 6px;
  border: 1px solid var(--excel-border);
  vertical-align: middle;
  line-height: 1.3;
}

/* Row types */
.row-section td {
  background: var(--excel-section-bg) !important;
  color: var(--excel-section-text) !important;
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
}

.row-item:nth-child(odd) td { background: var(--excel-row-odd); }
.row-item:nth-child(even) td { background: var(--excel-row-even); }
.row-item:hover td { background: rgba(0, 180, 216, 0.08) !important; }

.td-item { text-align: center; font-weight: 600; color: #1a3060; font-family: 'Roboto Mono', monospace; }
.td-desc { color: #1a1a2e; }
.td-tc { text-align: center; color: #1a3060; font-family: 'Roboto Mono', monospace; font-weight: 600; }
.td-note { color: #4a4a6a; font-size: 8.5px; font-style: italic; white-space: pre-line; }
.td-date { text-align: center; }
.td-sign { text-align: center; }

/* Form inputs inside table */
.field-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid #c5d8ec;
  outline: none;
  background: rgba(235, 245, 255, 0.5);
  font-family: inherit;
  font-size: inherit;
  color: #1a2a4a;
  text-align: inherit;
  padding: 1px 3px;
  min-height: 1.6em;
  resize: none;
  line-height: 1.4;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.field-input::placeholder {
  color: #a0b4cc;
  font-style: italic;
}

.field-input:focus {
  background: rgba(0, 180, 216, 0.12);
  border-bottom-color: #1a6b9a;
  border-radius: 2px;
  box-shadow: 0 1px 0 #1a6b9a;
}

.field-input:hover:not(:focus) {
  background: rgba(200, 225, 245, 0.6);
}

/* Date inputs */
input.field-input[type="date"] {
  font-size: 8px;
  cursor: pointer;
  color: #1a2a4a;
  -webkit-text-fill-color: #1a2a4a;
}

input.field-input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
  filter: invert(0.3) sepia(1) hue-rotate(190deg);
}

/* Hour meter field */
.field-hour-meter {
  display: flex; align-items: center; gap: 4px;
  font-size: 8px;
}

.field-hour-meter span { color: var(--text-secondary); white-space: nowrap; }

.field-hour-meter input {
  flex: 1;
  border: none; border-bottom: 1px solid var(--excel-border);
  outline: none;
  background: transparent;
  font-family: 'Roboto Mono', monospace;
  font-size: 8px;
  text-align: center;
  padding: 1px 2px;
}

/* Pressure field */
.field-pressure {
  font-size: 8px;
}

.field-pressure .pressure-label {
  font-style: italic;
  color: #4a4a6a;
  margin-bottom: 2px;
}

.field-pressure input {
  border: none; border-bottom: 1px dashed #aaa;
  outline: none; background: transparent;
  font-family: 'Roboto Mono', monospace;
  font-size: 9px; font-weight: 600;
  width: 80px; text-align: center;
}

/* Lifespan field */
.field-lifespan { font-size: 8px; display: flex; align-items: center; gap: 4px; }
.field-lifespan input {
  border: none; border-bottom: 1px dashed #aaa;
  outline: none; background: transparent;
  font-family: 'Roboto Mono', monospace;
  font-size: 9px; font-weight: 600;
  width: 60px; text-align: center;
}

/* Footer row */
.row-footer td {
  background: var(--excel-footer-bg) !important;
  padding: 6px 8px;
}

.footer-observations-label {
  font-weight: 700;
  font-size: 9px;
  color: #1a3060;
  margin-bottom: 2px;
}

.footer-observations-field {
  width: 100%;
  border: 1px solid #c5d8ec;
  border-radius: 3px;
  outline: none;
  background: rgba(235, 245, 255, 0.5);
  font-family: inherit;
  font-size: 9px;
  color: #1a1a2e;
  resize: vertical;
  min-height: 40px;
  padding: 3px 5px;
  transition: all 0.15s ease;
}

.footer-observations-field:focus {
  border-color: #1a6b9a;
  background: rgba(0, 180, 216, 0.08);
}

.footer-observations-field::placeholder {
  color: #a0b4cc;
  font-style: italic;
}

.footer-declaration {
  font-size: 8px;
  font-style: italic;
  color: #4a4a6a;
  padding: 4px 0 2px;
}

.footer-engineer {
  font-weight: 700;
  font-size: 9px;
  color: #1a3060;
  text-align: right;
}

/* ─── DIESEL GENERATOR PAGE ──────────────────────────────────── */
.diesel-page {
  padding: 12px;
  background: white;
  font-size: 10px;
  font-family: 'Inter', Arial, sans-serif;
}

.diesel-section {
  margin-bottom: 12px;
  border: 1px solid var(--excel-border);
  border-radius: 4px;
  overflow: hidden;
}

.diesel-section-title {
  background: var(--excel-header-bg);
  color: white;
  padding: 5px 10px;
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diesel-section-body {
  padding: 10px;
  background: #fafbfd;
}

.diesel-field-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.diesel-field-label {
  font-weight: 600;
  font-size: 9px;
  color: #1a3060;
  min-width: 90px;
}

.diesel-field-value {
  border: none;
  border-bottom: 1px solid #7aaad0;
  outline: none;
  background: rgba(235, 245, 255, 0.6);
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #1a2a4a;
  -webkit-text-fill-color: #1a2a4a;
  min-width: 100px;
  text-align: center;
  padding: 2px 4px;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.diesel-field-value::placeholder {
  color: #a0b4cc;
  font-weight: 400;
}

.diesel-field-value:focus {
  background: rgba(0, 180, 216, 0.14);
  border-bottom-color: #1a6b9a;
  box-shadow: 0 1px 0 #1a6b9a;
}

.diesel-checkbox-row {
  display: flex; gap: 16px;
  margin-bottom: 6px;
}

.diesel-checkbox-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 9px; font-weight: 600; color: #1a3060;
}

.diesel-checkbox-item input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--primary); cursor: pointer;
}

.diesel-textarea {
  width: 100%; min-height: 50px;
  border: 1px solid var(--excel-border); border-radius: 4px;
  font-family: 'Inter', sans-serif; font-size: 9px;
  padding: 6px; resize: vertical; background: white;
  outline: none;
}

.diesel-textarea:focus { border-color: var(--accent); }

/* ─── MEASUREMENT PAGES ──────────────────────────────────────── */
.measurement-page {
  background: white;
  padding: 12px;
  font-family: 'Inter', Arial, sans-serif;
  font-size: 9px;
}

.measurement-page-title {
  background: var(--excel-header-bg);
  color: white;
  padding: 5px 10px;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: -12px -12px 10px;
  text-align: center;
}

.meas-grid {
  display: grid;
  gap: 10px;
}

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

.meas-section {
  border: 1px solid var(--excel-border);
  border-radius: 4px;
  overflow: hidden;
}

.meas-section-title {
  background: var(--excel-section-bg);
  color: white;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 8.5px;
  text-transform: uppercase;
}

.meas-section-body {
  padding: 8px;
  background: #fafbfd;
}

.meas-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 5px;
  font-size: 8.5px;
}

.meas-label {
  font-weight: 600;
  color: #1a3060;
  min-width: 100px;
  font-size: 8px;
}

.meas-value {
  border: none;
  border-bottom: 1px solid #7aaad0;
  outline: none;
  background: rgba(235, 245, 255, 0.6);
  font-family: 'Roboto Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: #1a2a4a;
  -webkit-text-fill-color: #1a2a4a;
  min-width: 60px;
  text-align: center;
  padding: 2px 4px;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.meas-value::placeholder {
  color: #a0b4cc;
  font-weight: 400;
}

.meas-value:focus {
  background: rgba(0, 180, 216, 0.14);
  border-bottom-color: #1a6b9a;
  box-shadow: 0 1px 0 #1a6b9a;
}

.meas-value:hover:not(:focus) {
  background: rgba(200, 225, 245, 0.7);
}

.meas-result {
  display: flex; gap: 6px; align-items: center;
  margin: 6px 0;
}

.result-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border: 1px solid;
  border-radius: 3px;
  cursor: pointer;
  font-size: 8px; font-weight: 700;
  transition: all 0.15s;
}

.result-btn.pass {
  border-color: #2dc653;
  color: #2dc653;
  background: rgba(45, 198, 83, 0.08);
}

.result-btn.pass.selected {
  background: #2dc653;
  color: white;
}

.result-btn.fail {
  border-color: #e63946;
  color: #e63946;
  background: rgba(230, 57, 70, 0.08);
}

.result-btn.fail.selected {
  background: #e63946;
  color: white;
}

/* Height measurement table */
.height-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8px;
  margin-top: 4px;
}

.height-table th {
  background: #e8edf5;
  padding: 3px 5px;
  border: 1px solid var(--excel-border);
  text-align: center;
  font-weight: 700;
  color: #1a3060;
  font-size: 7.5px;
}

.height-table td {
  border: 1px solid var(--excel-border);
  padding: 2px 4px;
  text-align: center;
}

.height-table .td-point {
  font-weight: 600;
  color: #1a3060;
  background: #f0f4f8;
}

.height-table .td-initial {
  font-family: 'Roboto Mono', monospace;
  color: #4a4a6a;
}

.height-table .td-measured {
  background: rgba(0, 180, 216, 0.04);
}

.height-table input {
  border: none;
  border-bottom: 1px solid #7aaad0;
  outline: none;
  background: rgba(235, 245, 255, 0.6);
  font-family: 'Roboto Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  color: #1a2a4a;
  -webkit-text-fill-color: #1a2a4a;
  width: 100%;
  text-align: center;
  padding: 2px;
  border-radius: 2px;
  transition: background 0.15s;
}

.height-table input:focus {
  background: rgba(0, 180, 216, 0.14);
  outline: none;
}

.meas-footer-row {
  display: flex; justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--excel-border);
  gap: 12px;
}

.meas-responsible {
  display: flex; align-items: center; gap: 8px; font-size: 8.5px; flex: 1;
}

.meas-responsible-label { font-weight: 700; color: #1a3060; white-space: nowrap; }

.meas-responsible input {
  border: none;
  border-bottom: 1px solid #7aaad0;
  outline: none;
  background: rgba(235, 245, 255, 0.6);
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  color: #1a2a4a;
  -webkit-text-fill-color: #1a2a4a;
  flex: 1;
  padding: 2px 4px;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.meas-responsible input:focus {
  background: rgba(0, 180, 216, 0.14);
  border-bottom-color: #1a6b9a;
}

/* ─── Toast Notification ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem;
}

.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: rgba(15, 26, 46, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  min-width: 260px;
  max-width: 380px;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-color: rgba(45, 198, 83, 0.4); }
.toast.error   { border-color: rgba(230, 57, 70, 0.4); }
.toast.info    { border-color: rgba(0, 180, 216, 0.4); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }

/* ─── Loading Overlay ────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 14, 26, 0.85);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem;
}

.spinner {
  width: 42px; height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { color: var(--text-secondary); font-size: 0.875rem; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }

  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.6); }

  .main-content { margin-left: 0; }

  .mobile-menu-btn { display: flex; }

  .forms-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

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

@media (max-width: 600px) {
  #page-dashboard { padding: 1rem; }
  .forms-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .form-toolbar { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .form-toolbar-actions { width: 100%; flex-wrap: wrap; }
  .topbar-subtitle { display: none; }
}

/* ─── PRINT STYLES ───────────────────────────────────────────── */
@media print {
  /* Hide everything except form content */
  .sidebar,
  .topbar,
  .form-toolbar,
  .page-tabs,
  .toast-container,
  .loading-overlay,
  #screen-login,
  #page-dashboard,
  .bg-animated { display: none !important; }

  body {
    background: white !important;
    color: black !important;
    font-size: 9pt;
    margin: 0; padding: 0;
  }

  #screen-app { display: block !important; }
  .main-content { margin-left: 0 !important; }
  #page-form { display: block !important; padding: 0 !important; }
  .form-content { padding: 0 !important; overflow: visible !important; }

  /* Each page wrapper = one printed page */
  .form-page-wrapper {
    margin: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    page-break-after: always;
    break-after: page;
  }

  .form-page-wrapper:last-child {
    page-break-after: avoid;
    break-after: avoid;
  }

  /* Only show the active page in single-page view mode */
  /* (All pages visible when printing) */
  .print-page-landscape {
    page-break-after: always;
    break-after: page;
  }

  /* Form table print colors */
  .maintenance-table th,
  .maintenance-table .row-section td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  .row-section td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Input fields print as plain text */
  .field-input, .diesel-field-value,
  .meas-value, .diesel-textarea,
  .footer-observations-field,
  .meas-responsible input,
  .height-table input,
  .field-hour-meter input,
  .field-pressure input,
  .field-lifespan input {
    border: none !important;
    background: transparent !important;
  }

  input[type="date"].field-input {
    -webkit-appearance: none;
  }

  /* Buttons hide in print */
  .result-btn { border: 1px solid #ccc; }
  .result-btn.selected {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Page orientation */
@media print {
  .print-landscape {
    size: A4 landscape;
  }
  .print-portrait {
    size: A4 portrait;
  }
}
