/* ระบบจัดการเว็บไซต์งานพัสดุ — admin */
:root {
  --navy: #17306b; --navy-deep: #0f1f47; --navy-soft: #e8edf8;
  --gold: #e0a526; --gold-soft: #fbf1d9; --paper: #f4f6fa; --line: #dce1ea;
  --ink: #1c2333; --muted: #5b6478; --ok: #2f7d5b; --ok-soft: #e4f2ea; --red: #b4372f; --red-soft: #fbe7e5;
  --f-head: "Anuphan", "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 400 1rem/1.65 var(--f-body); color: var(--ink); background: var(--paper); }
h1, h2, h3 { font-family: var(--f-head); color: var(--navy-deep); line-height: 1.35; }
a { color: var(--navy); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
code { background: var(--navy-soft); padding: .05rem .35rem; border-radius: 4px; }

/* layout */
.admin { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.a-side { background: var(--navy-deep); color: #c9d3ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.a-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.a-brand img { width: 36px; height: 36px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.a-brand span { font: 600 1.05rem/1.25 var(--f-head); display: flex; flex-direction: column; }
.a-brand small { font: 400 .78rem var(--f-body); color: #9fb0d4; }
.a-side ul { list-style: none; margin: .6rem 0; padding: 0 .6rem; }
.a-side nav a, .a-side-foot a, .a-side-foot button {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 7px; color: #c9d3ea;
  text-decoration: none; font: 500 .95rem var(--f-body); background: none; border: 0; width: 100%; cursor: pointer; text-align: left;
}
.a-side nav a:hover, .a-side-foot a:hover, .a-side-foot button:hover { background: rgba(255,255,255,.07); color: #fff; }
.a-side a[aria-current] { background: var(--gold); color: var(--navy-deep); }
.a-side-foot { margin-top: auto; padding: .6rem; border-top: 1px solid rgba(255,255,255,.08); }
.a-side-foot form { margin: 0; }
.a-main { min-width: 0; }
.a-top { display: flex; align-items: center; gap: 1rem; padding: 1rem 2rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.a-top h1 { font-size: 1.3rem; margin: 0; flex: 1; }
.a-user { color: var(--muted); font-size: .9rem; }
.a-menu { display: none; background: none; border: 1px solid var(--line); border-radius: 7px; padding: .3rem; cursor: pointer; color: var(--navy); }
.a-content { padding: 1.75rem 2rem 4rem; max-width: 1200px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.05rem; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: 500 .95rem var(--f-body); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-deep); color: #fff; }
.btn.ghost { border-color: transparent; }
.btn.block { width: 100%; justify-content: center; padding: .7rem; }
.back { font-size: .92rem; }
.back::before { content: "‹ "; }
.quick { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.5rem; }

/* alerts */
.alert { padding: .7rem 1rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid; }
.alert.ok { background: var(--ok-soft); border-color: #b8dcc8; color: #1f5a40; }
.alert.err { background: var(--red-soft); border-color: #efc1bc; color: #8a241e; }
.notice { background: var(--gold-soft); border: 1px solid #efdcae; border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1.5rem; }
.notice a { margin-left: .5rem; font-weight: 600; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; display: flex; flex-direction: column; }
.stats span { color: var(--muted); font-size: .9rem; }
.stats b { font: 700 1.9rem var(--f-head); color: var(--navy-deep); font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.3rem; }
.panel h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.panel h2.mt { margin-top: 1.4rem; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; flex-direction: column; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.plist a { text-decoration: none; color: var(--ink); font-weight: 500; }
.plist a:hover { color: var(--navy); text-decoration: underline; }
.plist small { color: var(--muted); }
.plist.small li { font-size: .9rem; }

/* toolbar / table */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.toolbar .muted { margin: 0; max-width: 60em; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.filters input, .filters select { font: inherit; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; background: var(--paper); color: var(--muted); font-weight: 600; font-size: .85rem; padding: .65rem .85rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .65rem .85rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td a { color: var(--ink); text-decoration: none; font-weight: 500; }
.table td a:hover { color: var(--navy); text-decoration: underline; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty { text-align: center; color: var(--muted); padding: 2rem; }
.table tr.is-off td { color: #98a0b0; }
.table tr.is-off td a { color: #8790a3; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions a, .row-actions button { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 6px; color: var(--muted); background: none; border: 0; cursor: pointer; vertical-align: middle; }
.row-actions a:hover, .row-actions button:hover { background: var(--navy-soft); color: var(--navy); }
.row-actions button.danger:hover { background: var(--red-soft); color: var(--red); }
.row-actions form, td > form { display: inline; margin: 0; }
.status { border: 0; border-radius: 999px; padding: .15rem .65rem; font: 500 .82rem var(--f-body); cursor: pointer; }
.status.on { background: var(--ok-soft); color: var(--ok); }
.status.off { background: #eceef2; color: var(--muted); }
.chip { font-size: .75rem; background: var(--gold-soft); color: #8a5e00; padding: 0 .4rem; border-radius: 4px; }
.chip-warn { background: var(--navy-soft); color: var(--navy); }
.mini { width: 72px; height: 44px; object-fit: cover; border-radius: 5px; display: block; }
.mini-empty { display: grid; place-items: center; background: var(--paper); color: #9aa3b5; }
.fbadge { display: inline-block; font: 600 .66rem/1 var(--f-body); padding: .22rem .38rem; border-radius: 4px; vertical-align: middle; }
.fbadge-pdf { background: var(--red-soft); color: var(--red); } .fbadge-xls { background: var(--ok-soft); color: var(--ok); }
.fbadge-word { background: var(--navy-soft); color: var(--navy); } .fbadge-other { background: #eef0f4; color: var(--muted); }
.pager { display: flex; gap: .3rem; justify-content: center; margin-top: 1.25rem; }
.pager a, .pager span { min-width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 6px; text-decoration: none; background: #fff; border: 1px solid var(--line); color: var(--ink); }
.pager .cur { background: var(--navy); color: #fff; border-color: var(--navy); }

/* forms */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem 1.75rem; max-width: 900px; }
.narrow-card { max-width: 560px; }
.form { display: flex; flex-direction: column; gap: 1.05rem; }
.form label, .editor-field .label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .95rem; }
.form label em, .editor-field em { color: var(--red); font-style: normal; }
.form input:not([type=checkbox]):not([type=file]), .form select, .form textarea {
  font: 400 1rem var(--f-body); padding: .6rem .75rem; border: 1px solid #cdd3df; border-radius: 7px; background: #fff; color: var(--ink); width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-soft); }
.form input[readonly] { background: var(--paper); color: var(--muted); }
.form input[type=file] { font: inherit; font-size: .92rem; }
.hint { color: var(--muted); font-weight: 400; font-size: .84rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.checks { display: flex; gap: 1.5rem; flex-wrap: wrap; }
label.inline { flex-direction: row !important; align-items: center; gap: .45rem !important; font-weight: 400 !important; }
label.inline input { width: 1.1rem; height: 1.1rem; accent-color: var(--navy); }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; padding-top: .5rem; border-top: 1px solid var(--line); margin-top: .25rem; }
.form-h { font-size: 1.05rem; margin: .75rem 0 -.25rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.form-h:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.file-field { border: 1px dashed #c3cad8; border-radius: 9px; padding: .9rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.file-field legend { font-weight: 600; padding: 0 .35rem; font-size: .95rem; }
.file-current { margin: 0; font-size: .92rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; word-break: break-all; }
.thumbs { display: flex; flex-wrap: wrap; gap: .6rem; }
.thumb { width: 120px; font-size: .82rem !important; }
.thumb img { width: 120px; height: 84px; object-fit: cover; border-radius: 6px; }
.thumb span { display: flex; align-items: center; gap: .3rem; }
[hidden] { display: none !important; }

/* editor */
.editor { border: 1px solid #cdd3df; border-radius: 8px; overflow: hidden; background: #fff; }
.editor:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-soft); }
.editor-bar { display: flex; flex-wrap: wrap; gap: .2rem; padding: .35rem; background: var(--paper); border-bottom: 1px solid var(--line); }
.editor-bar button { font: 500 .85rem var(--f-body); background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: .2rem .55rem; cursor: pointer; min-width: 2rem; }
.editor-bar button:hover { border-color: var(--navy); color: var(--navy); }
.editor-bar button.on { background: var(--navy); color: #fff; }
.editor-area { min-height: 280px; max-height: 60vh; overflow-y: auto; padding: .9rem 1.1rem; outline: none; line-height: 1.75; }
.editor-area h3 { font-size: 1.15rem; }
.editor-area blockquote { border-left: 4px solid var(--gold); background: var(--gold-soft); margin: .5rem 0; padding: .4rem .9rem; }
.editor textarea.editor-src { width: 100%; min-height: 280px; border: 0; border-radius: 0; font: .9rem/1.6 ui-monospace, Menlo, monospace; padding: .9rem; }
.editor textarea.editor-src:focus { box-shadow: none; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; background: var(--navy-deep); background-image: linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px); background-size: 48px 48px; }
.login-card { background: #fff; width: 100%; max-width: 420px; border-radius: 14px; padding: 2rem 2rem 1.5rem; box-shadow: 0 30px 60px -25px rgba(0,0,0,.6); }
.login-card h1 { font-size: 1.35rem; margin: .5rem 0 .2rem; }
.login-logo { width: 64px; height: 64px; object-fit: contain; }
.login-back { text-align: center; font-size: .9rem; margin: 1.25rem 0 0; }

@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .a-side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .a-side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .a-menu { display: block; }
  .a-top, .a-content { padding-inline: 1rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .cols, .grid2 { grid-template-columns: 1fr; }
  .card { padding: 1.1rem; }
}
