/* Portal Contador DATAROI — 3Spark */
:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --accent: #059669;
  --accent-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

/* Login Screen */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.login-box {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-box h1 {
  font-size: 1.4rem;
  margin-bottom: .25rem;
  color: var(--text);
}

.login-box .subtitle {
  color: var(--text-muted);
  font-size: .85rem;
  margin-bottom: 1.5rem;
}

.login-box input[type="password"] {
  width: 100%;
  padding: .7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}

.login-box input[type="password"]:focus {
  border-color: var(--primary);
}

.login-box button {
  width: 100%;
  margin-top: .75rem;
  padding: .7rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  transition: background .2s;
}

.login-box button:hover { background: #1d4ed8; }

.login-error {
  color: var(--danger);
  font-size: .85rem;
  margin-top: .5rem;
  display: none;
}

/* App Layout */
.app { display: none; }
.app.active { display: block; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
}

header .meta {
  font-size: .8rem;
  color: var(--text-muted);
}

/* Navigation */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

nav a {
  display: inline-block;
  padding: .75rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}

nav a:hover, nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main Content */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Sections */
.section {
  display: none;
  animation: fadeIn .3s ease;
}

.section.active { display: block; }

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

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.05rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.card h3 {
  font-size: .95rem;
  margin: 1rem 0 .5rem;
  color: var(--text);
}

/* KPI Row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.kpi .label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: .25rem;
}

.kpi .value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--mono);
}

.kpi .detail {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.kpi.green .value { color: var(--accent); }
.kpi.red .value { color: var(--danger); }
.kpi.blue .value { color: var(--primary); }
.kpi.yellow .value { color: var(--warning); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: .75rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead {
  background: #f1f5f9;
  position: sticky;
  top: 0;
}

th {
  text-align: left;
  padding: .6rem .75rem;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
}

tr:hover { background: #f8fafc; }

.amount { font-family: var(--mono); text-align: right; white-space: nowrap; }
.amount.positive { color: var(--accent); }
.amount.negative { color: var(--danger); }

/* Tags */
.tag {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 500;
}

.tag.green { background: var(--accent-light); color: #065f46; }
.tag.yellow { background: var(--warning-light); color: #92400e; }
.tag.red { background: var(--danger-light); color: #991b1b; }
.tag.blue { background: var(--primary-light); color: #1e40af; }

/* Alerts */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}

.alert.warn {
  background: var(--warning-light);
  border-left: 3px solid var(--warning);
  color: #92400e;
}

.alert.danger {
  background: var(--danger-light);
  border-left: 3px solid var(--danger);
  color: #991b1b;
}

.alert.info {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  color: #1e40af;
}

/* Links */
.drive-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  margin: .5rem .5rem .5rem 0;
  transition: background .2s;
}

.drive-link:hover { background: #bfdbfe; }

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: .78rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* Selectable rows */
.sel-cb {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

th.sel-col, td.sel-col {
  width: 28px;
  text-align: center;
  padding-left: .4rem;
  padding-right: .2rem;
}

tr.selected { background: var(--primary-light) !important; }

/* Floating action bar */
.fab-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: .6rem 1.25rem;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(37,99,235,.4);
  display: none;
  align-items: center;
  gap: .75rem;
  z-index: 200;
  font-size: .85rem;
  white-space: nowrap;
  animation: slideUp .25s ease;
}

.fab-bar.visible { display: flex; }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.fab-bar .count {
  background: rgba(255,255,255,.2);
  padding: .15rem .5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: .8rem;
}

.fab-bar button {
  background: #fff;
  color: var(--primary);
  border: none;
  padding: .4rem .85rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.fab-bar button:hover { background: #e0e7ff; }

#fab-copy {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
}

#fab-copy:hover { background: rgba(255,255,255,.25); }

.fab-bar .fab-clear {
  background: transparent;
  color: rgba(255,255,255,.7);
  padding: .3rem .5rem;
  font-size: .75rem;
}

.fab-bar .fab-clear:hover { color: #fff; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 250;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.visible { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: .25rem;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body textarea {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.5;
  resize: vertical;
  color: var(--text);
  background: #f8fafc;
}

.modal-body textarea:focus { outline: none; border-color: var(--primary); }

.modal-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

.modal-footer .btn {
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.modal-footer .hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Print */
@media print {
  .login-screen, nav, header button, .fab-bar, .sel-col { display: none !important; }
  .app { display: block !important; }
  .section { display: block !important; page-break-inside: avoid; }
  main { max-width: 100%; }
  .kpi-row { grid-template-columns: repeat(4, 1fr); }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* Responsive */
@media (max-width: 768px) {
  header { padding: .75rem 1rem; flex-direction: column; gap: .25rem; }
  nav { padding: 0 .5rem; }
  nav a { padding: .6rem .75rem; font-size: .8rem; }
  main { padding: 1rem; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
}
