:root {
  --dark: #0b2a4f; --accent: #009e8c; --accent-soft: #e0f4f1; --red: #d92d20;
  --ink: #1d2a3a; --muted: #5f6b7a; --line: #e3e8ef; --bg: #f3f6f9;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Tajawal", system-ui, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.7; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; margin-top: 10px; }
.error { color: var(--red); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #fff;
  border: 0; border-radius: 10px; padding: 10px 20px; font-family: inherit; font-weight: 700; font-size: .98rem; cursor: pointer; transition: .2s;
}
.btn:hover { filter: brightness(.94); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-sm { padding: 6px 14px; font-size: .88rem; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, var(--dark), #12406f); }
.auth-box { background: #fff; width: min(420px, 100%); border-radius: 22px; padding: 34px 28px; display: grid; gap: 14px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); text-align: center; }
.auth-logo { width: 110px; margin: 0 auto; border-radius: 16px; }
.auth-box h1 { font-size: 1.4rem; color: var(--dark); }
.auth-box label { display: grid; gap: 4px; text-align: right; font-weight: 700; font-size: .92rem; }
.back { color: var(--muted); font-size: .9rem; }

/* top bar */
.top { background: var(--dark); color: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tabs a { padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: .92rem; color: #cfe0f0; }
.tabs a:hover { background: rgba(255,255,255,.08); }
.tabs a.on { background: var(--accent); color: #fff; }
.top-actions { display: flex; gap: 8px; }
.top .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); padding: 6px 14px; font-size: .88rem; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 26px 16px 120px; }
.panel-head { margin-bottom: 18px; }
.panel-head h1 { font-size: 1.6rem; color: var(--dark); }
.card { background: #fff; border-radius: 16px; padding: 22px; margin-bottom: 16px; box-shadow: 0 4px 18px -10px rgba(0,0,0,.18); }
.card h3 { margin-bottom: 10px; color: var(--dark); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin-bottom: 4px; }
.field { display: grid; gap: 4px; align-content: start; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-weight: 700; font-size: .92rem; }
.field small { color: var(--muted); font-size: .8rem; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 1rem;
  background: #fbfcfd; color: var(--ink); outline: none; transition: border-color .2s;
}
input:focus, textarea:focus { border-color: var(--accent); background: #fff; }
textarea { resize: vertical; }
.upload-row { display: flex; gap: 8px; align-items: center; }
.upload-row input[type="text"] { flex: 1; }
.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.add { margin-bottom: 16px; }
.item { padding: 0; overflow: hidden; }
.item summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; cursor: pointer; font-weight: 700; }
.item summary::-webkit-details-marker { display: none; }
.item summary::before { content: "◀"; font-size: .7rem; color: var(--muted); transition: transform .2s; }
.item[open] summary::before { transform: rotate(-90deg); }
.item-title { flex: 1; }
.item[open] summary { border-bottom: 1px solid var(--line); }
.item .grid { padding: 18px; }
.item-tools { display: flex; gap: 4px; }
.item-tools button { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 32px; cursor: pointer; font-size: .85rem; }
.item-tools button:hover { background: #fff; }
.item-tools .del:hover { background: #fde8e7; border-color: #f5b5b0; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-row div { background: var(--accent-soft); border-radius: 12px; padding: 12px 16px; flex: 1; min-width: 160px; }
.stat-row b { font-size: 1.4rem; color: var(--dark); display: block; }
.stat-row small { display: block; color: var(--muted); }

.savebar {
  position: fixed; bottom: 0; inset-inline: 0; background: #fff; border-top: 1px solid var(--line); z-index: 30;
  display: flex; align-items: center; justify-content: center; gap: 18px; padding: 12px 16px; box-shadow: 0 -8px 24px -14px rgba(0,0,0,.2);
}
.savebar.dirty #saveState { color: #c2410c; font-weight: 700; }
.savebar.dirty .btn { animation: nudge 1.6s infinite; }
@keyframes nudge { 50% { box-shadow: 0 0 0 6px rgba(0,158,140,.2); } }

.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--dark); color: #fff;
  padding: 10px 20px; border-radius: 12px; font-weight: 700; opacity: 0; pointer-events: none; transition: .3s; z-index: 40; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--red); }

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .top-in { gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tabs a { white-space: nowrap; }
  .savebar { justify-content: space-between; }
}
