/* ============================================================
   CYB Dashboard — shared styles
   ============================================================ */

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

:root {
  --navy:     #1a2b4a;
  --blue:     #2563eb;
  --blue-dk:  #1d4ed8;
  --green:    #16a34a;
  --red:      #dc2626;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --white:    #ffffff;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-700);
  min-height: 100vh;
}

/* ---- Header ---- */
header {
  background: var(--navy);
  color: var(--white);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: .01em; }
header a  { color: var(--gray-200); font-size: .85rem; text-decoration: none; }
header a:hover { color: var(--white); }

/* ---- Page wrapper ---- */
main { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ---- Back link ---- */
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--blue); font-size: .9rem; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ---- Tool grid (homepage) ---- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.tool-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.tool-card h2 { font-size: 1rem; font-weight: 600; }
.tool-card p  { font-size: .875rem; color: var(--gray-500); flex: 1; }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background .15s;
}
.btn-primary   { background: var(--blue);  color: var(--white); }
.btn-primary:hover   { background: var(--blue-dk); }
.btn-success   { background: var(--green); color: var(--white); }
.btn-success:hover   { background: #15803d; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: #d1d5db; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ---- Login page ---- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { font-size: 1.25rem; margin-bottom: .25rem; }
.login-card p  { font-size: .85rem; color: var(--gray-500); margin-bottom: 1.5rem; }

/* ---- Form elements ---- */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
label { font-size: .875rem; font-weight: 500; }
input[type="password"],
input[type="date"],
input[type="text"] {
  padding: .55rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
  width: 100%;
  background: var(--white);
}
input:focus { outline: 2px solid var(--blue); border-color: transparent; }

/* ---- Alerts ---- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
}
.alert-error   { background: #fef2f2; color: var(--red);   border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: var(--blue);  border: 1px solid #bfdbfe; }

/* ---- Card / section ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

/* ---- Date row ---- */
.date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.date-row .form-group { margin-bottom: 0; min-width: 160px; }

/* ---- Visit list ---- */
#visit-list { margin-top: 1rem; }
.visit-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--gray-200);
}
.visit-item:last-child { border-bottom: none; }
.visit-item .client   { font-weight: 600; }
.visit-item .address  { font-size: .85rem; color: var(--gray-500); }
.visit-item .time     { font-size: .85rem; color: var(--blue); }

/* ---- Results ---- */
.results-grid {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.stat { text-align: center; }
.stat .num  { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat .lbl  { font-size: .8rem; color: var(--gray-500); margin-top: .2rem; }
.stat.green .num { color: var(--green); }
.stat.red   .num { color: var(--red);   }

.failure-list { margin-top: .5rem; padding-left: 1.25rem; font-size: .8rem; color: var(--red); }

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: .4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .date-row { flex-direction: column; }
  .date-row .form-group { min-width: 0; width: 100%; }
}
