
:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #152033;
  --muted: #64748b;
  --line: #e3e9f2;
  --blue: #1668e3;
  --blue-dark: #0f4fae;
  --green: #138a59;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, Arial, sans-serif; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { width: min(760px, 100%); min-height: 100vh; margin: 0 auto; padding: 20px 18px 32px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.brand-area {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.ats-logo {
  width: clamp(150px, 30vw, 250px);
  max-height: 104px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.app-heading {
  min-width: 0;
}
h1 {
  margin: 0;
  font-size: clamp(20px, 4vw, 28px);
  line-height: 1.08;
}
.app-heading span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.status { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 12px; color: var(--muted); font-size: 13px; }
.status.ok { color: var(--green); border-color: #bfe8d5; background: #effbf5; }
.status.error { color: #b42318; border-color: #f2c7c3; background: #fff4f2; }

.view { display: none; }
.view.active { display: block; }

.month-card { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 18px; padding: 18px 20px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.month-card span { color: var(--muted); }
.month-card strong { font-size: 19px; }

.hint { color: var(--muted); margin: 24px 2px 12px; }

.destination-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.destination { min-height: 210px; border: 0; border-radius: 24px; padding: 24px 18px; color: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; text-align: left; cursor: pointer; }
.destination-1 { background: linear-gradient(145deg, #1668e3, #0f4fae); }
.destination-2 { background: linear-gradient(145deg, #162338, #0f172a); }
.destination .icon { font-size: 40px; margin-bottom: auto; }
.destination > span:not(.icon) { font-size: 24px; font-weight: 850; }
.destination small { opacity: .82; margin-top: 7px; font-size: 14px; }

.scan-header { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.scan-header > div { text-align: right; }
.scan-header span { display:block; color: var(--muted); font-size: 12px; }
.back { border: 0; background: #eef3f9; color: var(--text); border-radius: 12px; padding: 12px 14px; font-weight: 700; }

.pages { min-height: 180px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.empty { grid-column: 1 / -1; min-height: 220px; border: 2px dashed #cfd8e6; border-radius: 20px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; background: rgba(255,255,255,.55); }
.page-card { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 6px 18px rgba(15,23,42,.06); }
.page-card img { width: 100%; height: 260px; object-fit: contain; display: block; background: #dce3ed; }
.page-number { position: absolute; top: 8px; left: 8px; background: rgba(15,23,42,.85); color:white; padding: 5px 8px; border-radius: 9px; font-size: 12px; font-weight: 700; }
.delete-page { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border:0; background: rgba(180,35,24,.93); color:white; font-size: 19px; }

.scan-actions { position: sticky; bottom: 12px; display: grid; gap: 10px; background: rgba(244,247,251,.94); backdrop-filter: blur(8px); padding-top: 10px; }
.primary, .secondary { min-height: 56px; border: 0; border-radius: 16px; font-weight: 850; font-size: 17px; cursor: pointer; }
.primary { background: var(--blue); color: #fff; }
.primary:disabled { opacity: .45; cursor: default; }
.secondary { background: #fff; color: var(--text); border: 1px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); width: min(90vw, 520px); opacity: 0; pointer-events: none; background: #0f172a; color: white; padding: 14px 16px; border-radius: 14px; box-shadow: var(--shadow); transition: .2s; text-align: center; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: #087443; }
.toast.error { background: #a61b12; }

.loading { position: fixed; inset: 0; background: rgba(244,247,251,.92); backdrop-filter: blur(8px); z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.hidden { display: none !important; }
.spinner { width: 48px; height: 48px; border: 5px solid #d8e2ef; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .app-shell { padding: 12px 12px 28px; }
  .topbar {
    align-items: flex-start;
    padding: 12px;
    gap: 10px;
  }
  .brand-area {
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
  }
  .ats-logo {
    width: min(230px, 66vw);
    max-height: 90px;
  }
  .app-heading span {
    font-size: 12px;
  }
  .status { font-size: 11px; padding: 7px 9px; white-space: nowrap; }
  .destination-grid { grid-template-columns: 1fr; }
  .destination { min-height: 170px; }
  .pages { grid-template-columns: 1fr 1fr; }
  .page-card img { height: 190px; }
}


.scan-info {
  margin: 0 0 14px;
  padding: 13px 15px;
  border: 1px solid #cbdcf5;
  background: #eef5ff;
  color: #334155;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.45;
}
.scan-badge {
  position: absolute;
  left: 8px;
  bottom: 48px;
  padding: 5px 8px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .3px;
  box-shadow: 0 3px 8px rgba(15,23,42,.12);
}
.scan-ok { background: #e9f9f0; color: #087443; }
.scan-warning { background: #fff2df; color: #9a5b00; }
.rescan-page {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--blue-dark);
  font-weight: 800;
}


.month-selector-card {
  align-items: center;
}
.month-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.month-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.month-select {
  min-width: 190px;
  min-height: 48px;
  border: 1px solid #cbd5e1;
  border-radius: 13px;
  background: #fff;
  color: var(--text);
  padding: 0 38px 0 14px;
  font-weight: 800;
  font-size: 16px;
}
.selected-path {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 13px;
  background: #eef5ff;
  border: 1px solid #d3e2f8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.selected-path span {
  color: var(--muted);
}
.selected-path strong {
  text-align: right;
}
.scan-header-meta small {
  display: block;
  margin-top: 4px;
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 12px;
}

@media (max-width: 520px) {
  .month-selector-card {
    align-items: stretch;
    flex-direction: column;
  }
  .month-select {
    width: 100%;
    min-width: 0;
  }
  .selected-path {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
  .selected-path strong {
    text-align: left;
  }
}


/* V6 - autentificare comuna ATS Business App */
.topbar-actions { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.user-chip { border:1px solid #d8e2ef; background:#f8fafc; color:var(--text); border-radius:999px; padding:8px 11px; font-size:12px; font-weight:800; }
.logout-btn { border:1px solid #d8e2ef; background:#fff; color:#9f1c12; border-radius:11px; padding:8px 11px; font-weight:800; cursor:pointer; }
.login-body { min-height:100vh; background:#f4f7fb; }
.login-shell { min-height:100vh; display:grid; place-items:center; padding:22px 16px; }
.login-card { width:min(460px,100%); background:#fff; border:1px solid var(--line); border-radius:24px; box-shadow:var(--shadow); padding:28px 24px; }
.login-logo { display:block; width:min(320px,88%); max-height:150px; object-fit:contain; margin:0 auto 14px; }
.login-card h1 { text-align:center; margin:4px 0 8px; }
.login-card > p { margin:0 auto 22px; text-align:center; color:var(--muted); line-height:1.45; }
.login-form { display:grid; gap:15px; }
.login-form label span { display:block; margin-bottom:7px; font-weight:800; font-size:13px; }
.login-form input { width:100%; min-height:52px; border:1px solid #cbd5e1; border-radius:13px; padding:0 14px; color:var(--text); background:#fff; font-size:16px; outline:none; }
.login-form input:focus { border-color:#1668e3; box-shadow:0 0 0 3px rgba(22,104,227,.12); }
.login-error { background:#fff2f0; border:1px solid #f1c1bc; color:#a61b12; padding:11px 12px; border-radius:12px; font-weight:700; font-size:13px; }
.login-note { display:block; margin-top:18px; color:var(--muted); line-height:1.4; text-align:center; }
@media (max-width:520px) {
  .topbar-actions { width:100%; justify-content:flex-start; }
  .user-chip { max-width:62vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
}


/* V7 - Pastreaza-ma autentificat */
.remember-row {
  display: grid !important;
  grid-template-columns: 24px 1fr;
  align-items: start;
  gap: 11px;
  cursor: pointer;
  user-select: none;
  padding: 3px 1px;
}
.remember-row > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.remember-check {
  width: 22px;
  height: 22px;
  border: 2px solid #b8c5d6;
  border-radius: 7px;
  background: #fff;
  display: grid !important;
  place-items: center;
  margin-top: 1px;
  transition: .15s ease;
}
.remember-row > input:checked + .remember-check {
  background: var(--blue);
  border-color: var(--blue);
}
.remember-row > input:checked + .remember-check::after {
  content: "✓";
  color: #fff;
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
}
.remember-row > input:focus-visible + .remember-check {
  box-shadow: 0 0 0 3px rgba(22,104,227,.15);
}
.remember-text {
  display: flex !important;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.remember-text strong {
  color: var(--text);
  font-size: 14px;
}
.remember-text small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}


/* V8 - Header mobil reorganizat */
.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin-bottom: 24px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.brand-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-panel .ats-logo {
  width: clamp(160px, 30vw, 250px);
  max-height: 100px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-panel .app-heading {
  min-width: 0;
}

.brand-panel .app-heading h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.05;
}

.brand-panel .app-heading span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.account-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.account-chip {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #cfd8e6;
  background: #f8fafc;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.account-strip .status {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  margin: 0;
  white-space: nowrap;
}

.logout-btn {
  min-height: 40px;
  border: 1px solid #efd2d2;
  border-radius: 999px;
  padding: 0 15px;
  background: #fff;
  color: #a61b12;
  font-weight: 800;
  cursor: pointer;
}

.logout-btn:active {
  transform: translateY(1px);
}

@media (max-width: 520px) {
  .topbar {
    padding: 14px;
    gap: 12px;
  }

  .brand-panel {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
  }

  .brand-panel .ats-logo {
    width: min(245px, 76vw);
    max-height: 96px;
  }

  .brand-panel .app-heading h1 {
    font-size: 28px;
    line-height: 1.0;
  }

  .brand-panel .app-heading span {
    font-size: 13px;
  }

  .account-strip {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding-top: 11px;
  }

  .account-chip,
  .account-strip .status,
  .logout-btn {
    min-height: 38px;
    font-size: 12px;
    padding-left: 11px;
    padding-right: 11px;
  }

  .account-chip {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 390px) {
  .account-strip {
    grid-template-columns: 1fr 1fr;
  }

  .account-chip {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .account-strip .status,
  .logout-btn {
    justify-content: center;
  }
}
