:root { color-scheme: light dark; }

html, body { height: 100%; }
*, *::before, *::after { box-sizing: border-box; }

h1, h2 { font-weight: 500; }

body{
  background: url("../images/bg.jpg") center center / cover no-repeat fixed;
  color:#fff;
  font-family:'General Sans', Arial, sans-serif;
  font-size:16px;
  margin:0;
  min-height:100svh;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:clamp(16px,3vw,32px);
  gap:clamp(16px,2.5vw,28px);
  text-align:center;
}

a { color: #fff; }

.topbar{
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.18);
  border-bottom: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(6px);
  z-index: 1000;
}
.logo-small{
  width: clamp(120px, 18vw, 180px);
  max-height: 48px;
  object-fit: contain;
}
.topbar-right{
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-right .welcome{
  white-space: nowrap;
  opacity: .95;
}

.nav{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
}
.nav a{
  color:#ffffff;
  text-decoration:none;
  padding:8px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.25);
  background:rgba(255,255,255,0.08);
  backdrop-filter:blur(4px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
  white-space: nowrap;
}
.nav a .nav-icons{
  width: 26px;
  height: 26px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
}
.nav-icons { max-width: 30px; }


.content{
  width:min(680px,92vw);
  margin-inline:auto;
  display:grid;
  gap:clamp(16px,2.5vw,28px);
}

body.protected .content,
body.register  .content,
body.users     .content,
body.edit_user .content{
  padding-top: 80px;
}

.logo{
  max-width:100%;
  width:clamp(180px,40vw,380px);
  margin-bottom:clamp(16px,3vw,46px);
}

form{
  width:min(500px, 92vw);
  margin:0 auto;
  text-align:left;
}
label{ display:block; margin-top:.75rem; }
input{
  width:100%;
  padding:14px;
  margin-top:8px;
  border-radius:8px;
  border:1px solid #bbb;
  font-size:16px;
}
button{
  margin-top:1rem;
  padding:.75rem 1rem;
  border-radius:10px;
  border:1px solid #888;
  background:#f3f3f3;
  cursor:pointer;
}

.msg{
  padding:.8rem;
  background:#5f725e;
  border:1px solid #677b66;
  border-radius:10px;
  /*  margin:1rem 0;  */
  margin: 0 auto;
  color:#fff;
  word-break:break-word;
  width: min(500px, 92vw);
}
.msg.error, .msg {
  display: flex;
  align-items: center;      
  justify-content: center; 
  gap: 8px;
  min-height: 50px;         
  text-align: center;       
}

.msg-icons {
  width: 20px;
  height: 20px;
  flex-shrink: 0;        
}

.error{ background:#5f725e; border-color:#677b66; color:#fff;}
.muted{ color:#ddd; font-size:.95rem; }

.msg-list-users {
  width: 100%;
}

.table-wrap{
  width:min(100%, 1000px);
  margin:0 auto;
  overflow-x:auto;
}
.table{
  width:100%;
  border-collapse:collapse;
  text-align:left;
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.2);
}
.table th{ font-weight:600; }
.table th, .table td{
  padding:12px 10px;
  border-bottom:1px solid rgba(255,255,255,0.2);
}
.table thead th{
  position:sticky;
  top:0;
  background:rgba(255,255,255,0.08);
  backdrop-filter:blur(2px);
}

td a {
  text-decoration: none !important;
  color: #ffffff !important;
}

.login,
.home{
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto auto 1fr;
  justify-items: center;
  gap: 16px;
  padding: 0;
}
.login > .logo,
.home  > .logo{ grid-row: 2; }
.login > .content,
.home  > .content{
  grid-row: 3;
  width: min(500px, 92vw);
  margin: 0;
  display: block;
}

.edit-img, .delete-img { height: 20px; vertical-align: middle; }

.submit-btn {
  border: none;
  background: none;
  cursor: pointer;
  margin-top: 0;
  border-radius: 0;
  padding: 0;
}

.actions{
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  gap: 12px;
  /* max-width: 900px; */
  width: min(500px, 92vw);
  margin: 12px auto 0;
  align-items: stretch;
}
.actions form{
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}
.actions button{
  width: 100%;
  min-height: 44px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  font-size:16px;
}

.frm-login, .frm-add-new-user, .frm-edit-user{
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 30px;
}

.modal{
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,.55);
  z-index: 2000;
}
.modal[aria-hidden="false"]{ display: grid; }

.modal-box{
  background: #ffffff;
  color: #111;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.modal-box h3{ margin: 0 0 8px; font-weight: 600; }

.modal-actions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}
.modal-actions .btn-cancel,
.modal-actions .btn-danger{
  padding: .6rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}
.modal-actions .btn-cancel{
  background: #f3f3f3;
  color: #111;
  border-color: #bbb;
}
.modal-actions .btn-danger{
  background: #d32f2f;
  color: #fff;
  border-color: #b71c1c;
}

.welcome-name { font-weight: 600; }


@media (max-width: 700px){
  .actions{ grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px){
  
  button{ width:100%; }
  h1, h2 { font-size: 24px; }
  .table thead{ display:none; }
  .table, .table tbody, .table tr, .table td{ display:block; width:100%; }
  .table tr{
    margin-bottom:12px;
    border:1px solid rgba(255,255,255,0.2);
    border-radius:10px;
    background:rgba(255,255,255,0.04);
    overflow:hidden;
  }
  .table td{
    display:flex;
    justify-content:space-between;
    gap:16px;
    padding:10px 12px;
    border-bottom:1px dashed rgba(255,255,255,0.2);
  }
  .table td:last-child{ border-bottom:0; }
  .table td::before{
    content:attr(data-label);
    font-weight:600;
  }
  .table { border: none; background: none; }
  .table td[data-label="Actions"]{
    justify-content: flex-end;
    gap: 12px;
  }
  .table td[data-label="Actions"]::before{ margin-right: auto; }
  .table td[data-label="Actions"] a,
  .table td[data-label="Actions"] form{
    display: inline-flex;
    align-items: center;
  }
  .table td[data-label="Actions"] img{ display: block; }
  .delete-form{
    width: auto !important;
    max-width: none !important;
    margin: unset !important;
  }
}

@media (max-width: 460px){
  .actions{ grid-template-columns: 1fr; }
}

@media (max-width: 380px){
  .logo{ width: clamp(160px, 50vw, 320px); }
}

@media (max-width: 1024px){
  body.protected .content,
  body.register  .content,
  body.users     .content,
  body.edit_user .content{
    padding-top: 160px;
  }
  
  .topbar{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
  }
  .logo-small{
    margin: 0 auto;
    width: clamp(120px, 40vw, 180px);
    max-height: 48px;
    object-fit: contain;
  }
  .topbar-right{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  .topbar-right .welcome{
    text-align: center;
    white-space: nowrap;
  }
  .topbar .nav-inline{
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar .nav-inline::-webkit-scrollbar{ display: none; }
  .nav a {
    font-size: 14px;
    padding: 6px 10px;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 6px;
    min-height: 80px;
    width: 23%;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
  }
  .nav a .nav-icons{
    width: 24px;
    height: 24px;
    display: block;
    object-fit: contain;
  }
}
