/* Living Films E-Office — one stylesheet, no framework */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6b7a;
  --border: #d8dde3;
  --accent: #7a3e22;        /* Living Films brown */
  --accent-strong: #5b2e19;
  --accent-soft: #f6eee9;
  --ok: #1d7a46;   --ok-soft: #e6f4ec;
  --warn: #9a6200; --warn-soft: #fff4dc;
  --bad: #b42318;  --bad-soft: #fdeceb;
  --info: #175cd3; --info-soft: #e8f0fe;
  --radius: 8px;
  --sidebar: 230px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", "Noto Sans Thai", "Sarabun", Tahoma, system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
small, .muted { color: var(--muted); }
code { background: #eef0f3; padding: 0 .3em; border-radius: 4px; }

/* ---------- layout: sidebar + full-width content ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: #2b2522; color: #e9e3df; padding: 1rem .75rem 2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: block; color: #fff; font-weight: 700; font-size: 1.05rem; padding: .25rem .5rem 1rem; }
.brand small { display: block; color: #c9b9af; font-weight: 400; }
.nav-group { margin: .75rem 0 .25rem; padding: 0 .5rem; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: #a8988f; }
.sidebar a.nav {
  display: flex; justify-content: space-between; align-items: center;
  color: #efe8e4; padding: .42rem .6rem; border-radius: 6px; font-size: .93rem;
}
.sidebar a.nav:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar a.nav.active { background: var(--accent); color: #fff; }
.sidebar .count { background: rgba(255,255,255,.18); border-radius: 10px; padding: 0 .45rem; font-size: .75rem; }
.sidebar .user { border-top: 1px solid rgba(255,255,255,.12); margin-top: 1.25rem; padding: .9rem .5rem 0; font-size: .85rem; color: #d9cec8; }
.sidebar .user form { display: inline; }
.sidebar .user button { background: none; border: 0; color: #f2c9b5; cursor: pointer; padding: 0; font: inherit; }
.main { min-width: 0; padding: 1.25rem 1.75rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem 1rem; justify-content: space-between; align-items: flex-end; margin-bottom: 1rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.35); }
  .menu-toggle { display: inline-flex; position: sticky; top: 0; z-index: 20; margin: 0 0 .75rem; }
  .main { padding: 1rem 1rem 3rem; }
}

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; display: block; color: inherit; }
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: .5rem .6rem; border-bottom: 1px solid #eceff2; text-align: left; vertical-align: top; }
table.t th { background: #f8f9fa; font-weight: 600; font-size: .82rem; color: #3d4652; white-space: nowrap; position: sticky; top: 0; }
table.t tbody tr:hover { background: #fbf8f6; }
table.t tfoot td { font-weight: 700; background: #f8f9fa; border-top: 2px solid var(--border); }
table.t .num, .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t td.nowrap, .nowrap { white-space: nowrap; }
table.t.compact th, table.t.compact td { padding: .3rem .45rem; }
.neg { color: var(--bad); }
.zero { color: var(--info); }

/* ---------- badges & alerts ---------- */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-pending   { background: var(--warn-soft); color: var(--warn); border-color: #f1d9a6; }
.badge-on_hold   { background: #f1ecff; color: #5b3cc4; }
.badge-approved  { background: var(--ok-soft); color: var(--ok); }
.badge-denied    { background: var(--bad-soft); color: var(--bad); }
.badge-processed { background: var(--info-soft); color: var(--info); }
.badge-completed { background: #e7eef8; color: #1e3a5f; }
.badge-cancelled { background: #eceff2; color: #59636e; text-decoration: line-through; }
.badge-open { background: var(--warn-soft); color: var(--warn); }
.badge-in_progress { background: var(--info-soft); color: var(--info); }
.badge-done { background: var(--ok-soft); color: var(--ok); }
.chip { display: inline-block; font-size: .78rem; padding: 0 .4rem; border-radius: 4px; background: #eef0f3; margin: 0 .15rem .15rem 0; white-space: nowrap; }
.chip.approved { background: var(--ok-soft); color: var(--ok); }
.chip.denied { background: var(--bad-soft); color: var(--bad); }
.chip.on_hold { background: #f1ecff; color: #5b3cc4; }
.alert { padding: .65rem .9rem; border-radius: var(--radius); margin-bottom: .75rem; border: 1px solid; }
.alert-success { background: var(--ok-soft); border-color: #b7dfc6; color: #145c34; }
.alert-error { background: var(--bad-soft); border-color: #f4c2bd; color: #8c1c13; }
.alert-warning { background: var(--warn-soft); border-color: #f1d9a6; color: #7a4d00; }
.alert-info { background: var(--info-soft); border-color: #bcd2fb; color: #123f94; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .2rem; }
.field { margin-bottom: .8rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: .45rem .55rem; border: 1px solid #c4cbd3; border-radius: 6px; font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #e7c7b6; border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
input.num { text-align: right; }
.check { display: flex; gap: .4rem; align-items: center; font-weight: 400; }
.check input { width: auto; }
.row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .9rem; border-radius: 6px; border: 1px solid #c4cbd3;
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #155d35; }
.btn-danger { background: #fff; border-color: #e7a19a; color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: .2rem .55rem; font-size: .82rem; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font: inherit; }
.inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.filters .field { margin: 0; min-width: 140px; flex: 1 1 140px; max-width: 240px; }
.filters .field.wide { max-width: 320px; flex-basis: 220px; }
.items-table input, .items-table select { padding: .3rem .4rem; }
.items-table td { padding: .25rem .3rem; }
.totals { margin-left: auto; max-width: 420px; }
.totals td { padding: .25rem .4rem; }
.totals .grand td { font-size: 1.05rem; font-weight: 700; border-top: 2px solid var(--border); }
.approver-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .4rem; }
.approver-list label { display: flex; gap: .45rem; align-items: center; font-weight: 400; border: 1px solid var(--border); border-radius: 6px; padding: .35rem .5rem; background: #fff; }
.approver-list label input { width: auto; }
.approver-list .principal { margin-left: auto; font-size: .78rem; color: var(--muted); display: flex; gap: .25rem; align-items: center; }
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 10; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 6px; max-height: 260px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.ac-list div { padding: .35rem .55rem; cursor: pointer; }
.ac-list div:hover, .ac-list div.on { background: var(--accent-soft); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .35rem 0 .35rem .9rem; border-left: 2px solid var(--border); position: relative; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .75rem; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.msg { border-bottom: 1px solid #eceff2; padding: .5rem 0; }
.msg:last-child { border-bottom: 0; }
.pager { display: flex; gap: .4rem; align-items: center; margin-top: .75rem; }
.auth-box { max-width: 380px; margin: 9vh auto; }
.auth-box .card { padding: 1.5rem; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.hide { display: none !important; }
details > summary { cursor: pointer; font-weight: 600; }

@media print {
  .sidebar, .page-head .actions, .no-print, .menu-toggle, form button { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  body { background: #fff; font-size: 11px; }
  .card, .table-wrap { border: 0; padding: 0; }
  table.t th { position: static; }
  a { color: inherit; }
}
