:root { --primary: #0b2e6f; --line: #dde3ee; --muted: #5d6679; --bg: #f2f5fa; --danger: #c62828; }
* { box-sizing: border-box; }
body { margin: 0; font-family: "Figtree", system-ui, sans-serif; background: var(--bg); color: #16213a; font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
code { background: #eef1f7; padding: .1em .35em; border-radius: 4px; }
h1 { font-size: 1.6rem; margin: 0; color: var(--primary); }
.thaana { font-family: "Faruma", "MV Faseyha", "Noto Sans Thaana", sans-serif; }
.ic { width: 20px; height: 20px; flex: none; }

input[type=text], input[type=password], input[type=date], input[type=time], textarea, select {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: inherit;
}
input.thaana, textarea.thaana { font-size: 16px; line-height: 1.8; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
input[type=date], input[type=time] { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; background: var(--primary); color: #fff; border: 0;
  padding: .65rem 1.2rem; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn-light { background: #fff; color: var(--primary); border: 1px solid var(--line); }
.btn-light:hover { background: #f6f8fc; filter: none; }
.btn-plain { background: none; color: var(--muted); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f1c9c9; }
.btn-danger:hover { background: #fdeeee; filter: none; }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; }
small { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
.alert { padding: .8rem 1rem; border-radius: 8px; margin: 0 0 1.25rem; }
.alert-ok { background: #e3f6ea; color: #14532d; }
.alert-err { background: #fde8e8; color: #7f1d1d; }
.lead { color: var(--muted); margin: .35rem 0 0; }

/* ---------- Login ---------- */
.auth { max-width: 380px; margin: 8vh auto; background: #fff; padding: 2rem; border-radius: 14px; box-shadow: 0 8px 30px rgba(16,33,72,.08); text-align: center; }
.auth img { margin: 0 auto; object-fit: contain; }
.auth h1 { font-size: 1.25rem; margin: .75rem 0 1rem; }
.auth form { text-align: start; display: grid; gap: .9rem; }
.auth label { font-weight: 600; font-size: .9rem; }
.auth input { margin-top: .3rem; }
.hint { color: var(--muted); }
.back { display: inline-block; margin-top: 1.25rem; color: var(--muted); font-size: .9rem; }

/* ---------- Shell ---------- */
.topbar-a {
  position: sticky; top: 0; z-index: 20; height: 56px; background: var(--primary); color: #fff;
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem;
}
.bar-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; flex: 1; }
.bar-brand img { object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.bar-links { display: flex; gap: 1.25rem; font-size: .92rem; }
.bar-links a:hover { text-decoration: underline; }
.burger { display: none; cursor: pointer; }
.burger .ic { width: 26px; height: 26px; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 56px); }
.side { background: #fff; border-right: 1px solid var(--line); padding: 1rem .75rem 2rem; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.side a { display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: 8px; font-weight: 600; color: #34405a; font-size: .93rem; }
.side a:hover { background: var(--bg); }
.side a.on { background: color-mix(in srgb, var(--primary) 10%, white); color: var(--primary); }
.side a .ic { color: var(--primary); opacity: .8; }
.side-group { display: block; margin: 1.1rem .7rem .35rem; font-size: .75rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.panel { padding: 1.75rem 2rem 4rem; max-width: 1080px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.crumb { color: var(--muted); font-size: .9rem; display: inline-block; margin-bottom: .3rem; }
.crumb:hover { color: var(--primary); }

/* ---------- Dashboard ---------- */
.quick-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.5rem 0 .5rem; }
.dash-group { font-size: 1rem; color: var(--muted); margin: 2rem 0 .75rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.tile { display: flex; gap: .85rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; }
.tile:hover { border-color: var(--primary); }
.tile .ic { width: 30px; height: 30px; color: var(--primary); }
.tile strong { display: block; }

/* ---------- Lists ---------- */
.items { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.items li { display: flex; align-items: center; gap: 1rem; padding: .8rem 1rem; }
.items li + li { border-top: 1px solid var(--line); }
.items li.is-hidden { background: #fafbfd; }
.items li.is-hidden .item-main strong { color: var(--muted); }
.items img, .noimg { width: 72px; height: 52px; object-fit: cover; border-radius: 6px; flex: none; background: var(--bg); }
.item-ic { width: 40px; height: 40px; display: grid; place-items: center; background: var(--bg); border-radius: 8px; flex: none; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-main strong { color: var(--primary); }
.item-main .thaana { font-size: .95rem; color: #34405a; }
.item-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main:hover strong { text-decoration: underline; }
.item-actions { display: flex; gap: .4rem; align-items: center; flex: none; }
.item-actions form { display: flex; gap: .2rem; margin: 0; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: var(--primary); font-size: .7rem; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.empty-a { background: #fff; border: 1px dashed var(--line); border-radius: 12px; padding: 3rem; text-align: center; color: var(--muted); }

/* ---------- Forms ---------- */
fieldset { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .5rem 1.4rem; margin: 0 0 1.25rem; scroll-margin-top: 70px; }
legend { font-weight: 800; color: var(--primary); padding: 0 .4rem; font-size: 1.05rem; }
.row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1.25rem; align-items: start; padding: 1rem 0; }
.row + .row { border-top: 1px solid #eef1f6; }
.row-label { font-weight: 600; padding-top: .55rem; }
.row-label small { margin-top: .25rem; }
.req { font-style: normal; font-size: .72rem; color: var(--danger); font-weight: 600; margin-inline-start: .3rem; }
.row-check .row-label { padding-top: .2rem; }
.bi { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-rich .row-input { grid-column: 1 / -1; }
.row-rich { grid-template-columns: 1fr; gap: .5rem; }
.row-rich .row-label { padding-top: 0; }
.row-rich .bi { grid-template-columns: 1fr; }
.sub > span { display: block; font-size: .78rem; color: var(--muted); font-weight: 700; margin-bottom: .25rem; }

.upload { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.preview { width: 120px; height: 84px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #f6f8fc; }
.empty-prev { display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.row-image input[type=file] + small { margin-top: .3rem; }
.check { display: flex; gap: .4rem; align-items: center; font-size: .85rem; color: var(--muted); margin-top: .5rem; }
.file-cur { color: var(--primary); text-decoration: underline; font-weight: 600; word-break: break-all; }
input[type=color] { width: 64px; height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }
.slug { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; max-width: 460px; }
.slug span { padding: 0 .1rem 0 .75rem; color: var(--muted); white-space: nowrap; }
.slug input { border: 0; padding-inline-start: .1rem; }

.icon-pick { display: flex; flex-wrap: wrap; gap: .35rem; }
.icon-pick label { cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick .ic { width: 40px; height: 40px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; color: #34405a; }
.icon-pick input:checked + .ic { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, white); color: var(--primary); }
.icon-pick input:focus-visible + .ic { outline: 2px solid var(--primary); }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd6e3; border-radius: 26px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.save-bar { position: sticky; bottom: 0; padding: 1rem 0; display: flex; gap: .6rem; background: linear-gradient(transparent, var(--bg) 35%); z-index: 5; }
.save-bar .btn:first-child { padding: .8rem 2rem; box-shadow: 0 6px 18px rgba(16,33,72,.2); }

.jump { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; }
.jump a { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; color: var(--primary); }
.jump a:hover { border-color: var(--primary); }

/* ---------- Rich text editor ---------- */
.rte { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.rte-bar { border-radius: 10px 10px 0 0; }
.rte:focus-within { outline: 2px solid var(--primary); border-color: transparent; }
.rte.is-busy { opacity: .6; pointer-events: none; }
.rte-bar { display: flex; flex-wrap: wrap; gap: .2rem; padding: .4rem; background: #f6f8fc; border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 2; }
.rte-bar button, .rte-bar select { border: 1px solid transparent; background: none; border-radius: 6px; padding: .3rem .55rem; font: inherit; font-size: .85rem; cursor: pointer; color: #26324d; width: auto; }
.rte-bar select { border-color: var(--line); background: #fff; padding: .25rem .4rem; }
.rte-bar button:hover { background: #fff; border-color: var(--line); }
.rte-bar button.on { background: var(--primary); color: #fff; }
.rte-bar button:disabled, .rte-bar select:disabled { opacity: .35; }
.rte-sep { width: 1px; background: var(--line); margin: .2rem .25rem; }
.rte-area { min-height: 260px; max-height: 70vh; overflow-y: auto; padding: 1rem 1.2rem; line-height: 1.7; outline: none; }
.rte-area.thaana { font-size: 17px; line-height: 2; }
.rte-area > :first-child { margin-top: 0; }
.rte-area h2 { font-size: 1.35rem; color: var(--primary); margin: 1.2em 0 .4em; }
.rte-area h3 { font-size: 1.12rem; color: var(--primary); margin: 1em 0 .3em; }
.rte-area p { margin: 0 0 .8em; }
.rte-area img { max-width: 100%; height: auto; border-radius: 6px; }
.rte-area blockquote { margin: 0 0 .8em; padding: .5rem 1rem; border-inline-start: 4px solid #f2b705; background: #f6f8fc; }
.rte-area a { color: var(--primary); }
.rte-source { border: 0 !important; border-radius: 0 !important; min-height: 260px; font-family: ui-monospace, Consolas, monospace !important; font-size: 13px !important; direction: ltr; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .burger { display: block; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; top: 56px; left: 0; bottom: 0; width: 260px; height: auto; z-index: 15; transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 24px rgba(0,0,0,.12); }
  .nav-toggle:checked ~ .shell .side { transform: none; }
  .panel { padding: 1.25rem 1rem 4rem; }
  .row, .bi { grid-template-columns: 1fr; gap: .5rem; }
  .row-label { padding-top: 0; }
  .items li { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-end; }
  .bar-links a:first-child { display: none; }
}
