:root {
  --navy: #003B71;
  --navy-2: #15324b;
  --blue: #0377af;
  --gold: #f1c50e;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #dbe3ec;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: 'Ubuntu', sans-serif; color: var(--navy-2); }
a { color: inherit; text-decoration: none; }
code { background: #e2e8f0; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }

/* Buttons */
.abtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: .18s;
  white-space: nowrap;
}
.abtn--primary { background: var(--blue); color: #fff; }
.abtn--primary:hover { background: var(--navy); }
.abtn--gold { background: var(--gold); color: var(--navy); }
.abtn--gold:hover { background: #ffe055; }
.abtn--outline { background: transparent; border-color: rgba(255,255,255,.45); color: #fff; }
.abtn--outline:hover { background: rgba(255,255,255,.15); }
.abtn--light { background: #fff; border-color: var(--border); color: var(--text); }
.abtn--light:hover { background: #f8fafc; border-color: var(--blue); }
.abtn--ghost { background: transparent; color: #cbd5e1; }
.abtn--ghost:hover { color: #fff; background: rgba(255,255,255,.1); }
.abtn--danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.abtn--danger:hover { background: var(--danger); color: #fff; }
.abtn--sm { padding: .35rem .65rem; font-size: .75rem; }
.abtn--full { width: 100%; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  padding: 1.5rem;
}
.login-screen[hidden] { display: none; }
.login-card {
  background: #fff;
  width: min(400px, 100%);
  padding: 2.2rem;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  text-align: center;
}
.login-logo { width: 110px; height: 110px; margin: 0 auto 1rem; display: block; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold); background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.login-card h1 { font-size: 1.5rem; }
.login-sub { color: var(--muted); font-size: .85rem; margin-bottom: 1.5rem; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: .75rem; }
.login-card label { font-size: .8rem; font-weight: 700; color: var(--navy-2); }
.login-card input {
  width: 100%;
  padding: .75rem .9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.login-err { color: var(--danger); font-size: .8rem; font-weight: 600; }
.login-hint { margin-top: 1.2rem; font-size: .75rem; color: var(--muted); }
.login-back { display: inline-block; margin-top: .9rem; font-size: .8rem; color: var(--blue); font-weight: 600; }

/* Header */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy-2);
  color: #fff;
  padding: .7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
  flex-wrap: wrap;
}
.admin-header__left { display: flex; align-items: center; gap: .75rem; }
.admin-header__logo { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); background: #fff; flex: none; }
.admin-header__left strong { display: block; font-size: .95rem; line-height: 1.1; }
.mode-badge { font-size: .7rem; color: #cbd5e1; display: inline-block; }
.admin-header__actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.unsaved-dot { font-size: .76rem; color: var(--gold); font-weight: 700; }
.sidebar-toggle {
  display: none;
  background: rgba(255,255,255,.12);
  border: 0;
  color: #fff;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
}

.offline-banner {
  background: #fef9c3;
  color: #713f12;
  border-bottom: 1px solid #fde047;
  padding: .6rem 1.25rem;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.offline-banner[hidden] { display: none; }

/* Layout */
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 58px);
}
.admin-sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 1rem .75rem;
  position: sticky;
  top: 58px;
  height: calc(100vh - 58px);
  overflow-y: auto;
}
.admin-sidebar nav { display: flex; flex-direction: column; gap: .25rem; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  text-align: left;
  padding: .62rem .85rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}
.nav-btn:hover { background: #f1f5f9; }
.nav-btn.is-active { background: var(--navy); color: #fff; }

.admin-main {
  padding: 1.6rem clamp(1rem, 3vw, 2.4rem) 4rem;
  max-width: 1060px;
  width: 100%;
}

/* Section cards */
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}
.sec-head h2 { font-size: 1.45rem; }
.sec-desc { font-size: .84rem; color: var(--muted); margin-top: .2rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.15rem;
  box-shadow: 0 2px 6px rgba(15,23,42,.04);
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid #eef2f6;
  flex-wrap: wrap;
}
.panel__head h3 { font-size: 1rem; }
.panel__tools { display: flex; gap: .35rem; flex-wrap: wrap; }

/* Forms */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .32rem; margin-bottom: .75rem; }
.field label { font-size: .76rem; font-weight: 700; color: var(--navy-2); }
.field input[type="text"],
.field input[type="url"],
.field input[type="number"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%;
  padding: .58rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .84rem;
  background: #fff;
  color: var(--text);
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(3,119,175,.12);
}
.check-row {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: .75rem;
}
.check-row input { width: 17px; height: 17px; accent-color: var(--blue); }
.color-row { display: flex; align-items: center; gap: .5rem; }
.color-row input[type="color"] { width: 42px; height: 34px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 2px; background: #fff; }
.hint { font-size: .76rem; color: var(--muted); }

/* Media Picker */
.media-picker {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem;
}
.media-preview {
  width: 96px;
  height: 72px;
  border-radius: 6px;
  background: #e2e8f0;
  overflow: hidden;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
}
.media-preview img, .media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-preview--icon { width: 56px; height: 56px; font-size: 1.7rem; background: #fff; }
.media-preview--icon img { object-fit: contain; padding: 3px; }
.media-preview--icon svg { width: 28px; height: 28px; fill: var(--blue); }
.media-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .45rem; }
.media-btns { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Icon Picker */
.icon-picker {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem;
  display: flex;
  gap: .85rem;
  align-items: center;
  flex-wrap: wrap;
}
.icon-picker__controls { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: .45rem; }
.icon-picker__row { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.icon-picker__row select, .icon-picker__row input { flex: 1; min-width: 120px; }

/* Video preview */
.yt-preview {
  margin-top: .6rem;
  border-radius: 8px;
  overflow: hidden;
  max-width: 420px;
  aspect-ratio: 16/9;
  background: #000;
}
.yt-preview iframe, .yt-preview video { width: 100%; height: 100%; border: 0; display: block; }

/* Gallery multi-upload */
.upload-drop {
  border: 2px dashed var(--blue);
  background: #eff6ff;
  border-radius: 10px;
  padding: 1.3rem;
  text-align: center;
  margin-bottom: 1.1rem;
}
.upload-drop p { font-size: .85rem; margin-bottom: .6rem; color: var(--navy-2); font-weight: 600; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15,23,42,.65);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff;
  width: min(760px, 100%);
  max-height: 85vh;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal__head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal__close {
  background: none;
  border: 0;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.modal__body { padding: 1rem 1.25rem; overflow-y: auto; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
  margin-top: .75rem;
}
.media-tile {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  transition: .15s;
}
.media-tile:hover { border-color: var(--blue); transform: translateY(-2px); }
.media-tile__thumb { height: 92px; display: grid; place-items: center; overflow: hidden; background: #e2e8f0; }
.media-tile__thumb img, .media-tile__thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-tile__name { font-size: .68rem; padding: .35rem .45rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-tile__del { border: 0; background: #fee2e2; color: var(--danger); font-size: .7rem; font-weight: 700; padding: .25rem; cursor: pointer; }

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  background: var(--navy-2);
  color: #fff;
  padding: .75rem 1.2rem;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,.25);
}
.toast.is-ok { background: var(--success); }
.toast.is-err { background: var(--danger); }

@media (max-width: 860px) {
  .sidebar-toggle { display: inline-grid; place-items: center; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 58px;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .22s;
    box-shadow: 4px 0 20px rgba(0,0,0,.18);
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
