/* AUREA admin dashboard */
:root { --sidebar: 244px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--blue-100), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 26px;
  padding: 30px 26px; box-shadow: var(--shadow); animation: fadeUp 0.5s var(--ease) both; }
.login-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.login-card h1 { font-size: 23px; color: var(--navy); letter-spacing: -0.02em; margin-bottom: 4px; }
.login-card .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--blue); margin-bottom: 6px; }
.login-card .muted { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* ---------- form controls ---------- */
.fld { margin-bottom: 14px; }
.fld label { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.in, .sel, .ta {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: #fbfcff; padding: 10px 13px;
  font-size: 14.5px; transition: border-color 0.2s, box-shadow 0.2s; min-height: 42px;
}
.ta { resize: vertical; min-height: 92px; }
.in:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--blue-600); background: #fff; box-shadow: 0 0 0 4px rgba(10, 75, 196, 0.1); }
.fld.bad .in, .fld.bad .sel { border-color: var(--urgent); }
.fld .msg { color: var(--urgent); font-size: 12px; margin-top: 4px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.btn {
  border: 0; border-radius: 12px; padding: 10px 18px; font-weight: 600; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--blue-600), var(--navy)); box-shadow: 0 6px 16px rgba(1, 56, 158, 0.22);
  transition: transform 0.15s var(--ease), opacity 0.2s; min-height: 42px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--line); box-shadow: none; }
.btn.danger { background: #fff; color: var(--urgent); border: 1.5px solid #f8c9cb; box-shadow: none; }
.btn.sm { padding: 6px 12px; font-size: 13px; min-height: 34px; border-radius: 10px; }
.form-msg { font-size: 13px; margin: 0 0 12px; color: var(--urgent); min-height: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 24px; }
.side-brand b { display: block; font-size: 15px; color: var(--navy); letter-spacing: 0.02em; }
.side-brand small { color: var(--muted); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 14.5px; transition: all 0.18s var(--ease);
}
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav a:hover { background: var(--bg); color: var(--navy); }
.nav a.on { background: var(--blue-50); color: var(--blue); }
.side-foot { margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--line); }
.who { font-size: 13.5px; font-weight: 600; color: var(--navy); }
.who small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.logout { margin-top: 10px; width: 100%; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  background: rgba(245, 247, 252, 0.88); backdrop-filter: blur(10px); border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 22px; letter-spacing: -0.02em; color: var(--navy); flex: 1; }
html[data-lang='kh'] .topbar h1 { font-size: 20px; }
.burger { display: none; border: 1.5px solid var(--line); background: #fff; border-radius: 11px; width: 42px; height: 42px; place-items: center; }
.content { padding: 8px 28px 48px; max-width: 1280px; animation: fadeUp 0.35s var(--ease) both; }

/* ---------- cards & tables ---------- */
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat small { color: var(--muted); font-size: 12.5px; font-weight: 500; display: block; }
.stat b { display: block; font-size: 30px; letter-spacing: -0.03em; color: var(--navy); margin-top: 4px; line-height: 1.2; }
.stat::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--blue)); }
.stat.urgent { --accent: var(--urgent); } .stat.urgent b { color: var(--urgent); }
.stat.progress { --accent: var(--medium); } .stat.resolved { --accent: var(--normal); } .stat.new { --accent: var(--blue-600); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-pad { padding: 20px; }
.panel h2 { font-size: 15px; color: var(--navy); margin-bottom: 14px; }

.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) 1fr 1fr auto; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); align-items: center; }
.filters .in, .filters .sel { min-height: 40px; padding: 8px 11px; font-size: 13.5px; }
.tools { display: flex; justify-content: flex-end; gap: 8px; padding: 0 14px 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 12px 14px; background: #fafbff; white-space: nowrap; }
html[data-lang='kh'] th { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
td { padding: 13px 14px; border-top: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
tbody tr { transition: background 0.15s; cursor: pointer; }
tbody tr:hover { background: #f8faff; }
.rid-link { font-weight: 700; color: var(--blue); white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 44px 16px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager .grp { display: flex; gap: 8px; }

/* ---------- detail ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none; margin: 4px 0 14px; }
.back:hover { color: var(--navy); }
.detail { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: start; }
.d-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.d-head h2 { font-size: 22px; color: var(--navy); margin: 0 6px 0 0; }
.meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; margin-bottom: 18px; }
.meta small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.meta span { font-weight: 600; font-size: 14.5px; }
.block-t { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
html[data-lang='kh'] .block-t { text-transform: none; letter-spacing: 0; font-size: 13px; }
.text { white-space: pre-wrap; word-break: break-word; background: #fafbff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); cursor: zoom-in; transition: transform 0.2s var(--ease); }
.photos img:hover { transform: scale(1.02); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid var(--line); margin-left: 5px; }
.timeline li:last-child { padding-bottom: 0; border-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--blue-600); }
.timeline li.st-resolved::before { border-color: var(--normal); }
.timeline li.st-rejected::before { border-color: var(--s-rejected); }
.timeline li.st-in_progress::before { border-color: var(--medium); }
.timeline li.st-reviewing::before { border-color: var(--s-reviewing); }
.timeline b { font-size: 14px; color: var(--navy); }
.timeline small { display: block; color: var(--muted); font-size: 12.5px; }

/* ---------- analytics ---------- */
.an-top { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.an-top .fld { margin: 0; }
.an-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 34px; gap: 10px; align-items: center; margin-bottom: 11px; font-size: 13.5px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: 999px; background: var(--blue-50); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-600), var(--navy)); transition: width 0.7s var(--ease); }
.bar-row b { text-align: right; color: var(--navy); }
.trend { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 10px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.trend .col i { width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--blue-600), var(--navy)); min-height: 3px; transition: height 0.7s var(--ease); }
.trend .col span { font-size: 11px; color: var(--muted); }
.trend .col em { font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--navy); }
.problem-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.problem-row:first-of-type { border-top: 0; }
.problem-row small { color: var(--muted); display: block; font-size: 12.5px; }
.problem-row b { font-size: 18px; color: var(--navy); }

/* ---------- settings ---------- */
.set-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px; align-items: start; }
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.user-row:first-of-type { border-top: 0; }
.user-row small { color: var(--muted); display: block; }
.user-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- misc ---------- */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); opacity: 0; background: var(--navy); color: #fff;
  padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); transition: all 0.3s var(--ease); z-index: 100; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--urgent); }
.lightbox { position: fixed; inset: 0; background: rgba(8, 16, 40, 0.86); display: grid; place-items: center; z-index: 90; padding: 20px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 14px; }
.lightbox button { position: absolute; top: 16px; right: 20px; background: rgba(255, 255, 255, 0.16); border: 0; color: #fff; font-size: 28px; width: 44px; height: 44px; border-radius: 50%; }
.skeleton { color: var(--muted); padding: 40px; text-align: center; }
.scrim { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(3, 1fr); }
  .filters .search { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform 0.28s var(--ease); box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8, 16, 40, 0.4); z-index: 50; }
  .burger { display: grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 4px 16px 40px; }
  .detail, .set-grid, .an-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat b { font-size: 26px; }
  .stat:first-child { grid-column: 1 / -1; }
  .filters { grid-template-columns: 1fr 1fr; padding: 12px; }
  .filters .search { grid-column: 1 / -1; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { padding: 12px 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  td { border: 0; padding: 0; font-size: 13.5px; }
  td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; margin-bottom: 1px; }
  td.c-id, td.c-action { grid-column: 1 / -1; }
  td.c-action { display: none; }
  .meta { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: minmax(80px, 38%) 1fr 30px; }
}

/* ---------- print: replicates the paper form ---------- */
.print-sheet { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  body * { visibility: hidden; }
  .print-sheet, .print-sheet * { visibility: visible; }
  .print-sheet { display: block; position: absolute; left: 0; top: 0; width: 100%; color: #000; font-size: 10.5pt; line-height: 1.45; }
  .print-sheet h1 { font-size: 16pt; text-align: center; margin: 0; }
  .print-sheet h2 { font-size: 14pt; text-align: center; margin: 2px 0; }
  .print-sheet .pc { text-align: center; margin: 0 0 8px; color: #333; }
  .print-sheet h3 { font-size: 12.5pt; margin: 14px 0 4px; border-bottom: 1px solid #000; padding-bottom: 2px; }
  .print-sheet p { margin: 3px 0; }
  .pbox { display: inline-block; width: 13px; height: 13px; border: 1.5px solid #000; text-align: center; line-height: 12px; font-size: 11px; vertical-align: middle; }
  .pbig { border: 1px solid #000; min-height: 48px; padding: 5px 8px; white-space: pre-wrap; word-break: break-word; }
  .psign { display: flex; justify-content: space-between; gap: 20px; margin-top: 18px; }
}
