/* SaniCheck Portal — Design Tokens ECODESA v2 */

:root {
  --emerald: #0c8a5f;
  --emerald-2: #0a7350;
  --aqua: #35c9ac;
  --amber: #df8a00;
  --coral: #e0523c;
  --wash-a: #eff9f5;
  --wash-b: #e9f6f0;
  --wash-sun: #fbf7ed;
  --ink: #0a2e23;
  --ink-70: rgba(10, 46, 35, 0.74);
  --ink-55: rgba(10, 46, 35, 0.58);
  --ink-40: rgba(10, 46, 35, 0.42);
  --line: rgba(10, 46, 35, 0.12);
  --white: #ffffff;
  --bueno: #065f46;
  --bueno-bg: #d1fae5;
  --regular: #92400e;
  --regular-bg: #fef3c7;
  --deficiente: #991b1b;
  --deficiente-bg: #fee2e2;
  --font-heading: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Roboto Mono', ui-monospace, monospace;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lum: 0 20px 50px -24px rgba(12, 138, 95, 0.25),
    0 4px 14px -8px rgba(10, 46, 35, 0.08);
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: linear-gradient(165deg, var(--wash-a) 0%, var(--wash-b) 48%, #d8f0e6 100%);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: transparent;
}

/* ——— Login ——— */
.login-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 20px calc(32px + var(--safe-b));
  animation: fade-slide-up 0.45s ease both;
}

.brand-block {
  text-align: center;
  margin-bottom: 36px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-2) 100%);
  box-shadow: var(--shadow-lum);
  display: grid;
  place-items: center;
  position: relative;
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.brand-mark span {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  color: var(--white);
  letter-spacing: -0.03em;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.15;
}

.brand-sub {
  margin-top: 8px;
  color: var(--ink-55);
  font-size: 14px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-lum);
  border: 1px solid var(--line);
  position: relative;
}

.login-card::before {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--aqua), transparent);
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-70);
  margin-bottom: 8px;
}

.field-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--wash-a);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 20px;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-input:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(12, 138, 95, 0.15);
  background: var(--white);
}

.field-input::placeholder {
  letter-spacing: 0.2em;
  color: var(--ink-40);
  text-transform: none;
  font-family: var(--font-body);
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  margin-top: 16px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.12s ease, opacity 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-2) 100%);
  color: var(--white);
  box-shadow: 0 8px 20px -8px rgba(12, 138, 95, 0.55);
}

.btn-secondary {
  background: var(--wash-b);
  color: var(--emerald-2);
  border: 1px solid var(--line);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-55);
  height: 40px;
  margin-top: 0;
  width: auto;
  font-size: 13px;
  font-weight: 500;
}

.msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}

.msg.visible {
  display: block;
  animation: fade-slide-up 0.3s ease both;
}

.msg-error {
  background: var(--deficiente-bg);
  color: var(--deficiente);
}

.msg-ok {
  background: var(--bueno-bg);
  color: var(--bueno);
}

.msg-info {
  background: var(--wash-sun);
  color: var(--regular);
}

/* ——— Dashboard ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--emerald-2);
  color: var(--white);
  box-shadow: 0 8px 24px -12px rgba(10, 115, 80, 0.55);
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar-brand small {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.topbar-brand strong {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.main {
  flex: 1;
  padding: 16px 16px calc(24px + var(--safe-b));
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.tab {
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-55);
  transition: background 0.2s, color 0.2s;
}

.tab.active {
  background: var(--white);
  color: var(--emerald-2);
  box-shadow: var(--shadow-sm);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 14px 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  animation: fade-slide-up 0.4s ease both;
}

.item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--emerald);
}

.item.estado-por_vencer_7d::before {
  background: var(--amber);
}

.item.estado-vencido::before {
  background: var(--coral);
}

.item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.item-tipo {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-55);
}

.item-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-fecha {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-70);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-vigente {
  background: var(--bueno-bg);
  color: var(--bueno);
}

.badge-por_vencer_7d {
  background: var(--regular-bg);
  color: var(--regular);
}

.badge-vencido {
  background: var(--deficiente-bg);
  color: var(--deficiente);
}

.empty,
.loading {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-55);
  font-size: 14px;
}

.skeleton {
  height: 78px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, #e4f3ec 0%, #f4fbf7 50%, #e4f3ec 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes fade-slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (min-width: 481px) {
  body {
    padding: 24px 0;
  }

  .shell {
    border-radius: var(--radius-xl, 26px);
    overflow: hidden;
    box-shadow: var(--shadow-lum);
    background: linear-gradient(165deg, var(--wash-a), var(--wash-b));
    min-height: calc(100dvh - 48px);
  }
}
