body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;
  background:#111;
  color:#eee;
}

a{
  color:#fff;
  text-decoration:none;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  background:#242424;
  position:sticky;
  top:0;
  z-index:1000;
}

.wrap{
  padding:16px;
  max-width:1200px;
  margin:auto;
  position:relative;
  z-index:1;
}

.brand{
  font-weight:700;
}

.nav{
  display:flex;
  gap:12px;
}

/* ---------- login ---------- */

.login-card,
.settings-grid section,
.event-card{
  background:#1c1c1c;
  border-radius:16px;
  box-shadow:0 2px 8px rgba(0,0,0,.25);
}

.login-card{
  max-width:420px;
  margin:8vh auto;
  padding:20px;
}

.login-card form{
  display:grid;
  gap:10px;
}

.login-card input,
.settings-grid input,
.settings-grid select{
  padding:12px;
  border-radius:10px;
  border:1px solid #444;
  background:#111;
  color:#fff;
  width:100%;
  box-sizing:border-box;
}

.login-card button,
.settings-grid button,
.actions button,
.danger{
  padding:12px 14px;
  border:none;
  border-radius:10px;
  cursor:pointer;
}

/* ---------- buttons ---------- */

.danger{
  background:#b3262e;
  color:#fff;
}

/* ---------- page header ---------- */

.page-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:12px;
}

/* ---------- cards grid ---------- */

.cards{
  display:grid;
  gap:14px;
  grid-template-columns:1fr;
}

/* ---------- event card ---------- */

.event-card{
  display:grid;
  grid-template-columns:120px 1fr;
  gap:14px;
  padding:12px;
  align-items:stretch;
  z-index:1;
}

/* ---------- image ---------- */

.event-media{
  height:120px;
}

.event-media img,
.placeholder{
  width:120px;
  height:120px;
  border-radius:14px;
  object-fit:cover;
  background:#333;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* ---------- right side ---------- */

.event-body{
  min-width:0;
  height:120px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}

/* ---------- top row ---------- */

.event-top{
  position:relative;
  min-height:48px;
  padding-right:140px;
}

.plate{
  font-size:2.4rem;
  font-weight:800;
  line-height:1.05;
  letter-spacing:.02em;
  margin:0;
}

/* ---------- timestamp ---------- */

.top-time{
  position:absolute;
  top:0;
  right:0;
  font-size:1rem;
  color:#aaa;
  white-space:nowrap;
}

/* ---------- bottom row ---------- */

.event-bottom{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  gap:8px;
}

/* ---------- badges ---------- */

.badges-row{
  width:100%;
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:10px;
  align-items:end;
  position:relative;
  bottom: 0px;
}

.badge{
  height:44px;
  padding:0 14px;
  border-radius:12px;
  background:#333;
  text-align:center;
  display:flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  box-sizing:border-box;
  font-size:1.05rem;
  z-index:1;
}

.badge.ok{
  background:#1f5e2f;
}

.badge.bad{
  background:#692b2b;
}

.confidence-badge{
  background:#15365c;
}

/* ---------- actions ---------- */

.actions{
  margin-top:0;
}

.actions .danger{
  background:#b3262e;
  color:#fff;
}

/* ---------- messages ---------- */

.error{
  background:#692b2b;
  padding:12px;
  border-radius:10px;
  margin-bottom:10px;
}

.okmsg{
  background:#1f5e2f;
  padding:12px;
  border-radius:10px;
  margin-bottom:10px;
}

/* ---------- settings ---------- */

.settings-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:16px;
}

.settings-grid section{
  padding:18px;
  display:grid;
  grid-template-columns:minmax(150px,220px) minmax(0,1fr);
  gap:12px 16px;
  align-items:center;
}

.settings-grid h2{
  grid-column:1/-1;
  margin:0 0 6px 0;
}

.settings-grid .checkline{
  grid-column:1/-1;
  display:flex;
  align-items:center;
  gap:10px;
}

.settings-grid .checkline input{
  width:auto;
}

.form-actions{
  grid-column:1/-1;
}

.form-actions button{
  min-width:140px;
}

/* ---------- desktop ---------- */

@media(min-width:900px){

  .settings-grid{
    grid-template-columns:1fr 1fr;
  }

  .cards{
    grid-template-columns:1fr 1fr;
  }

}

/* ---------- mobile ---------- */

@media(max-width:700px){

  .wrap{
    padding:12px;
  }

  .topbar{
    padding:12px;
    gap:10px;
    flex-wrap:wrap;
  }

  .nav{
    gap:10px;
    flex-wrap:wrap;
  }

  .page-header{
    align-items:flex-start;
    gap:10px;
    flex-direction:column;
  }

  .page-header h1{
    margin:0;
    font-size:2.4rem;
    line-height:1.05;
  }

  .cards{
    grid-template-columns:1fr;
    gap:12px;
  }

  .event-card{
    grid-template-columns:1fr;
    gap:12px;
    padding:12px;
  }

  .event-media{
    width:100%;
    height:auto;
  }

  .event-media img,
  .placeholder{
    width:100%;
    height:auto;
    aspect-ratio:16/10;
    border-radius:14px;
    object-fit:cover;
  }

  .event-body{
    height:auto;
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:10px;
  }

  .event-top{
    position:static;
    min-height:0;
    padding-right:0;
    display:flex;
    flex-direction:column;
    gap:4px;
  }

  .plate{
    font-size:2.05rem;
    line-height:1;
    word-break:break-word;
  }

  .top-time{
    position:static;
    display:block;
    font-size:1rem;
    line-height:1.2;
    color:#aaa;
    white-space:normal;
  }

  .event-bottom{
    margin-top:0;
    display:flex;
    flex-direction:column;
    gap:10px;
  }

  .badges-row{
    grid-template-columns:1fr;
    gap:10px;
  }

  .badge{
    width:100%;
    height:46px;
    font-size:1rem;
    padding:0 12px;
  }

  .actions{
    width:100%;
  }

  .actions .danger{
    width:100%;
  }

  .image-modal-content{
    padding:10px;
  }

  .image-modal-img{
    max-width:100%;
    max-height:100%;
    border-radius:10px;
  }

  .image-modal-close{
    top:10px;
    right:10px;
  }
}

/* -------- image modal -------- */

.image-modal[hidden]{
  display:none;
}

.image-modal{
  position:fixed;
  inset:0;
  z-index:9999;
}

.image-modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.82);
}

.image-modal-content{
  position:relative;
  z-index:1;
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  box-sizing:border-box;
}

.image-modal-img{
  max-width:100%;
  max-height:100%;
  width:auto;
  height:auto;
  border-radius:14px;
  box-shadow:0 10px 40px rgba(0,0,0,.45);
  background:#111;
  touch-action:auto;
}

.image-modal-close{
  position:absolute;
  top:16px;
  right:16px;
  width:44px;
  height:44px;
  border:none;
  border-radius:999px;
  background:rgba(20,20,20,.85);
  color:#fff;
  font-size:28px;
  line-height:1;
  cursor:pointer;
  z-index:2;
}

@media(max-width:700px){
  .image-modal-content{
    padding:12px;
    align-items:center;
    justify-content:center;
  }

  .image-modal-img{
    max-width:100%;
    max-height:100%;
    border-radius:10px;
  }

  .image-modal-close{
    top:10px;
    right:10px;
  }
}