:root {
  --green: #071d16;
  --green-2: #0c2c21;
  --gold: #f5b82e;
  --ink: #11211b;
  --muted: #5d6b63;
  --line: #e2e8e2;
  --bg: #f4f7f3;
  --card: #ffffff;
  --danger: #c0392b;
  --ok: #1f8a4c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(7, 29, 22, 0.08);
}

* { box-sizing: border-box; }

/* Make the [hidden] attribute win over the explicit display rules below
   (e.g. .login-view / .modal-backdrop use display:grid). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.brand-mark svg { width: 100%; height: 100%; fill: var(--gold); }

/* Notice ------------------------------------------------------------------ */
.notice {
  background: #fff4d6;
  border-bottom: 1px solid #eccf7a;
  padding: 12px 18px;
  font-size: 0.92rem;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.notice code { background: rgba(7,29,22,0.07); padding: 1px 6px; border-radius: 6px; }

/* Buttons ----------------------------------------------------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #fff; }
.btn-danger { background: transparent; border-color: #e6c3bd; color: var(--danger); }
.btn-danger:hover { background: #fce9e6; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Login ------------------------------------------------------------------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #0c2c21 0%, #071d16 60%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .brand-mark { width: 44px; height: 44px; background: var(--green); border-radius: 12px; display: grid; place-items: center; padding: 8px; }
.login-brand strong { display: block; letter-spacing: 0.12em; }
.login-brand small { color: var(--muted); letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.68rem; }
.login-card label, .modal-form label, .kv-field { display: grid; gap: 6px; }
.login-card label span, .modal-form label span, .kv-field > span { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.login-error { color: var(--danger); font-size: 0.88rem; min-height: 1.1em; margin: 0; }
.login-note { color: var(--muted); font-size: 0.82rem; margin: 0; }

input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
textarea { resize: vertical; min-height: 84px; }

/* App shell --------------------------------------------------------------- */
.admin-header {
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.admin-brand { display: flex; align-items: center; gap: 10px; }
.admin-brand .brand-mark { width: 32px; height: 32px; }
.admin-brand strong { letter-spacing: 0.06em; }
.admin-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-user { color: #c8d6cd; font-size: 0.85rem; }
.admin-header .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.3); }
.admin-header .btn-ghost:hover { background: rgba(255,255,255,0.1); }

.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  background: var(--green);
  overflow-x: auto;
}
.tab {
  font: inherit;
  font-weight: 600;
  color: #c8d6cd;
  background: transparent;
  border: 0;
  border-radius: 10px 10px 0 0;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: #fff; }
.tab.active { background: var(--bg); color: var(--green); }

.admin-main { padding: 22px clamp(12px, 4vw, 40px); max-width: 1100px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 1.3rem; }

/* Lists ------------------------------------------------------------------- */
.list { display: grid; gap: 12px; }
.row-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.row-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: #eef3ee; flex: none; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-main h3 { margin: 0 0 2px; font-size: 1rem; }
.row-main p { margin: 0; color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 8px; flex: none; }
.badge { font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge-on { background: #e3f6ea; color: var(--ok); }
.badge-off { background: #f1f1f1; color: #8a8a8a; }
.empty { color: var(--muted); padding: 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Key/value forms --------------------------------------------------------- */
.kv-form { display: grid; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.kv-field { gap: 6px; }
.kv-save { justify-self: start; }

/* Modal ------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 29, 22, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}
.modal-card {
  background: var(--card);
  border-radius: 18px;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-head, .modal-foot { padding: 16px 20px; display: flex; align-items: center; }
.modal-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-foot { justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
.modal-close { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-form { padding: 20px; display: grid; gap: 14px; overflow: auto; }
.modal-form .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check-field { display: flex; align-items: center; gap: 10px; }
.check-field input { width: auto; }
.preview-thumb { width: 80px; height: 80px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.gallery-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 2px; }
.gthumb { position: relative; }
.gthumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.gthumb button { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; cursor: pointer; line-height: 1; font-size: 0.9rem; }
.order-actions { flex-direction: column; align-items: flex-end; gap: 8px; }
.order-status-select { padding: 6px 10px; font: inherit; }

/* Toast ------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--green);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 60;
  font-weight: 600;
}
.toast.error { background: var(--danger); }

@media (max-width: 560px) {
  .modal-form .row-2 { grid-template-columns: 1fr; }
  .row-card { flex-wrap: wrap; }
}
