/* Colores tomados de proyecto/android/app/src/main/res/values/colors.xml */
:root {
  --primary: #1565C0;
  --primary-dark: #0D47A1;
  --primary-light: #1976D2;
  --accent: #FF6F00;
  --background: #F5F7FA;
  --surface: #FFFFFF;
  --text-primary: #1A2332;
  --text-secondary: #6B7280;
  --divider: #E3E8EF;
  --blue-bg: #EFF6FF;   --blue-tx: #1565C0;
  --green-bg: #DCFCE7;  --green-tx: #166534;
  --red-bg: #FEE2E2;    --red-tx: #991B1B;
  --yellow-bg: #FEF3C7; --yellow-tx: #92400E;
  --gray-bg: #F1F5F9;   --gray-tx: #475569;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100%; max-width: 480px; margin: 0 auto; background: var(--background); position: relative; }
button, input, select, textarea { font: inherit; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary) 55%, var(--primary-light));
  padding: 48px 24px 32px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-brand { text-align: center; color: #fff; margin-bottom: 28px; }
.login-logo {
  width: 80px; height: 80px; border-radius: 20px; background: #fff; margin: 0 auto 14px;
  display: grid; place-items: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.login-logo svg { width: 46px; height: 46px; fill: var(--primary); }
.login-brand h1 { font-size: 28px; margin: 0; font-weight: 700; }
.login-brand p { margin: 4px 0 0; color: rgba(255, 255, 255, .67); font-size: 14px; }
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.login .card { border-radius: 20px; padding: 24px; }
.login h2 { margin: 0; font-size: 22px; }
.login .sub { margin: 4px 0 20px; color: var(--text-secondary); font-size: 13px; }
.demo-hint { margin-top: 14px; font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.demo-hint code { background: var(--gray-bg); padding: 1px 5px; border-radius: 4px; }

/* ---------- Campos ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #C9D1DC; border-radius: 8px; padding: 12px; font-size: 15px;
  background: #fff; color: var(--text-primary); outline: none;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21, 101, 192, .15); }
.error-box { background: var(--red-bg); color: var(--red-tx); font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }

.btn {
  border: 0; border-radius: 10px; padding: 0 16px; height: 48px; font-weight: 600; font-size: 15px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn-sm { height: 34px; font-size: 12px; padding: 0 12px; border-radius: 8px; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-text { background: transparent; color: var(--primary); }

/* ---------- Barra superior y menú lateral ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 5; height: 56px; background: var(--primary); color: #fff;
  display: flex; align-items: center; gap: 8px; padding: 0 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
}
.toolbar h1 { font-size: 19px; font-weight: 500; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: inherit; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.icon-btn:active { background: rgba(255, 255, 255, .15); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 280px; max-width: 82vw; background: #fff; z-index: 21;
  transform: translateX(-105%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.menu-open .scrim { opacity: 1; pointer-events: auto; }
.menu-open .drawer { transform: none; box-shadow: 4px 0 24px rgba(0, 0, 0, .2); }
.drawer-head { background: linear-gradient(135deg, var(--primary-dark), var(--primary) 55%, var(--primary-light)); color: #fff; padding: 28px 20px 18px; }
.drawer-head .avatar { width: 56px; height: 56px; border-radius: 16px; background: #fff; display: grid; place-items: center; margin-bottom: 12px; }
.drawer-head .avatar svg { width: 32px; height: 32px; fill: var(--primary); }
.drawer-head .n { font-size: 16px; font-weight: 600; }
.drawer-head .c, .drawer-head .r { font-size: 13px; color: rgba(255, 255, 255, .7); }
.drawer nav { padding: 8px; flex: 1; }
.drawer a {
  display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 48px; border-radius: 24px;
  color: var(--text-primary); text-decoration: none; font-size: 14px; font-weight: 500;
}
.drawer a svg { width: 22px; height: 22px; fill: var(--text-secondary); }
.drawer a.active { background: var(--blue-bg); color: var(--primary); }
.drawer a.active svg { fill: var(--primary); }
.drawer hr { border: 0; border-top: 1px solid var(--divider); margin: 8px 0; }

/* ---------- Contenido ---------- */
.content { padding: 16px; padding-bottom: 96px; }
.saludo { font-size: 20px; font-weight: 700; margin: 4px 0 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.stat .t { font-size: 12px; color: var(--text-secondary); }
.stat .v { font-size: 32px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat .v.green { color: var(--green-tx); }
.stat .s { font-size: 11px; color: var(--text-secondary); }
.stat-wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 15px; font-weight: 700; margin: 18px 0 10px; }

.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input { flex: 1; border: 1px solid #C9D1DC; border-radius: 10px; padding: 0 12px; height: 44px; font-size: 14px; outline: none; background: #fff; }
.chips-filter { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: none; }
.chips-filter button { flex: none; border: 1px solid var(--divider); background: #fff; color: var(--text-secondary); border-radius: 16px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.chips-filter button.on { background: var(--blue-bg); color: var(--primary); border-color: #BFDBFE; }

.doc-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.doc-desc { font-size: 13px; color: var(--text-secondary); margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 12px; }
.chip.activo { background: var(--green-bg); color: var(--green-tx); }
.chip.inactivo { background: var(--red-bg); color: var(--red-tx); }
.chip.revision { background: var(--yellow-bg); color: var(--yellow-tx); }
.chip.archivado { background: var(--gray-bg); color: var(--gray-tx); }
.chip.clasif { background: var(--blue-bg); color: var(--blue-tx); }
.meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.mini { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--divider); font-size: 13px; cursor: pointer; }
.mini:last-child { border-bottom: 0; }
.mini .tt { font-weight: 600; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.detail-grid .k { font-size: 11px; color: var(--text-secondary); }
.detail-grid .v { font-size: 13px; font-weight: 600; margin-top: 2px; }

.hist-accion { font-size: 13px; font-weight: 700; color: var(--primary); }
.hist-fecha { font-size: 11px; color: var(--text-secondary); }
.hist-doc { font-size: 13px; margin-top: 4px; }
.hist-user { font-size: 12px; color: var(--text-secondary); }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }

.user-row { display: flex; align-items: center; gap: 12px; }
.user-av { width: 44px; height: 44px; border-radius: 22px; background: var(--blue-bg); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.user-info { flex: 1; min-width: 0; }
.user-info .n { font-size: 14px; font-weight: 700; }
.user-info .c { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
.user-tags { text-align: right; font-size: 11px; }
.user-tags .rol { color: var(--primary); font-weight: 600; }
.user-tags .est { color: var(--green-tx); }
.user-tags .est.inactivo { color: var(--red-tx); }

.fab {
  position: fixed; right: max(16px, calc(50% - 224px)); bottom: 20px; z-index: 4; height: 56px; border-radius: 16px; border: 0;
  background: var(--accent); color: #fff; padding: 0 20px; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 16px rgba(255, 111, 0, .35); cursor: pointer;
}
.fab svg { width: 22px; height: 22px; fill: #fff; }

.empty, .loading { text-align: center; color: var(--text-secondary); font-size: 14px; padding: 40px 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid #D6E4F5; border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 10px; animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: #1F2937; color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 14px; z-index: 30; transition: transform .25s; max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); }
