/* ระบบบัญชี fb88 - stylesheet (CSS3) */
:root {
  --navy: #2b3f7a;
  --navy-dark: #1f2f5e;
  --line: #b7c4dc;
  --bar-black: #000;
  --bar-gray: #6b6b6b;
  --red: #e00000;
  --blue: #0b64c0;
  --yellow: #ffff99;
  --pink: #ffcccc;
  --gray-cell: #cfcfcf;
  --lightblue: #99ccff;
  --green-row: #9ccc92;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Tahoma, "Sarabun", "Leelawadee UI", sans-serif;
  font-size: 14px;
  color: #222;
  background: #fff;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ top bars */
.topbar {
  display: flex; align-items: center; height: 40px; background: var(--bar-black); color: #fff;
  padding: 0 0 0 6px; position: sticky; top: 0; z-index: 50;
}
.topbar .home {
  width: 46px; height: 28px; border-radius: 14px; background: #777 url(/img/home.svg) center/18px no-repeat;
  display: inline-block; margin-right: 8px;
}
.topbar .home:hover { background-color: #999; }
.topbar nav { display: flex; height: 100%; }
.topbar nav a {
  color: #fff; padding: 0 15px; display: flex; align-items: center; font-weight: bold; font-size: 15px;
}
.topbar nav a:hover, .topbar nav a.active { background: #333; text-decoration: none; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 18px; height: 100%; font-size: 16px; }
.topbar .right a { color: #fff; }
.topbar .speaker { width: 22px; height: 18px; background: url(/img/speaker.svg) center/contain no-repeat; display: inline-block; }
.topbar .drop {
  width: 38px; height: 100%; background: #555; display: flex; align-items: center; justify-content: center;
  border-top-left-radius: 4px; border-top-right-radius: 4px; cursor: pointer; position: relative;
}
.topbar .drop::after { content: ""; border: 6px solid transparent; border-top-color: #fff; margin-top: 6px; }
.topbar .drop-menu {
  position: absolute; right: 0; top: 40px; background: #333; min-width: 220px; display: none; flex-direction: column;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.topbar .drop.open .drop-menu { display: flex; }
.topbar .drop-menu a { padding: 10px 14px; font-size: 14px; border-bottom: 1px solid #444; }

.subbar {
  display: flex; align-items: center; min-height: 50px; background: var(--bar-gray); padding: 0 8px; flex-wrap: wrap;
}
.subbar a {
  color: #fff; font-weight: bold; padding: 7px 8px; margin: 0 2px; border-radius: 4px; font-size: 15px;
}
.subbar a:hover, .subbar a.active { background: #555; text-decoration: none; }
.subbar a.disabled { color: #aaa; pointer-events: none; }
.subbar .right { margin-left: auto; display: flex; gap: 6px; }
.subbar .right a { font-weight: normal; font-size: 16px; }

main { padding: 10px 4px 30px; }

/* ------------------------------------------------------------ panels */
.panel {
  border: 2px solid var(--line); border-radius: 6px 6px 2px 2px; margin: 0 0 18px; background: #fff; overflow: hidden;
}
.panel-head {
  display: flex; align-items: stretch; min-height: 44px;
  background: linear-gradient(#f3f6fb 0%, #c8d4ea 35%, #90a6cf 55%, #c7d3ea 100%);
}
.panel-title {
  align-self: flex-start; margin: 4px 0 6px 14px; padding: 5px 38px 5px 38px; color: #fff; font-weight: bold; font-size: 16px;
  background: linear-gradient(#6f89c4, #2b3f7a 60%, #3a5596); border-radius: 8px 8px 8px 8px;
  position: relative; box-shadow: 0 1px 2px rgba(0,0,0,.35); white-space: nowrap;
}
.panel-title::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #cfd8ea);
}
.panel-title .hl { color: #ffe400; }
.tools { margin-left: auto; display: flex; align-items: stretch; }
.tools > * { border-left: 1px solid #dbe3f1; display: flex; align-items: center; padding: 0 8px; background: rgba(255,255,255,.35); }
.tools select { margin: 0; }
.panel-body { padding: 0; }
.panel-body.pad { padding: 8px; }

/* ------------------------------------------------------------ buttons & inputs */
.btn {
  font: inherit; font-size: 16px; padding: 4px 12px; border: 1px solid #777; border-radius: 3px; cursor: pointer; color: #111;
  background: linear-gradient(#fdfdfd, #e3e3e3);
}
.btn:hover { background: linear-gradient(#fff, #d6e4f7); }
.btn:disabled { color: #999; border-color: #bbb; cursor: default; background: #eee; }
.btn-sm { font-size: 13px; padding: 2px 14px; min-width: 110px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  font: inherit; font-size: 16px; padding: 3px 5px; border: 1px solid #888; border-radius: 3px; background: #fff; color: #111;
}
input[readonly], input:disabled, select:disabled, textarea:disabled, textarea[readonly] { background: #eee; color: #555; }
input.num { text-align: right; }
textarea { width: 100%; resize: vertical; }
.w60 { width: 60px; } .w80 { width: 80px; } .w120 { width: 120px; } .w160 { width: 160px; }
.w200 { width: 200px; } .w240 { width: 240px; } .w300 { width: 300px; } .w400 { width: 400px; } .wfull { width: 100%; }

.icon-btn {
  width: 34px; height: 34px; border: 0; cursor: pointer; background: transparent center/26px no-repeat; padding: 0;
}
.icon-btn.refresh { background-image: url(/img/refresh.svg); }
.icon-btn.search { background-image: url(/img/search.svg); }
.ico { display: inline-block; width: 22px; height: 22px; vertical-align: middle; background: center/contain no-repeat; border: 0; cursor: pointer; padding: 0; }
.ico.edit { background-image: url(/img/edit.svg); }
.ico.del { background-image: url(/img/del.svg); }
.ico.plus { background-image: url(/img/plus.svg); width: 18px; height: 18px; }
.ico.check { background-image: url(/img/check.svg); cursor: default; }
.ico.info { background-image: url(/img/info.svg); width: 18px; height: 18px; }
.ico.note { background-image: url(/img/note.svg); width: 18px; height: 18px; }
.ico.play { background-image: url(/img/play.svg); }
.ico.search { background-image: url(/img/search.svg); }
.ico.phone { background-image: url(/img/phone.svg); width: 18px; height: 18px; cursor: default; }
.ico + .ico { margin-left: 10px; }

/* แสดง/ซ่อนรหัสผ่าน: core.js ครอบ input[type=password] ทุกช่องด้วย .pw-wrap */
.pw-wrap { position: relative; display: inline-block; vertical-align: middle; }
.pw-wrap > input { padding-right: 32px; }
.pw-toggle {
  position: absolute; top: 50%; right: 4px; width: 24px; height: 24px; transform: translateY(-50%);
  border: 0; padding: 0; cursor: pointer; background: transparent url(/img/eye.svg) center/20px no-repeat;
}
.pw-toggle.on { background-image: url(/img/eye-off.svg); }
.pw-toggle:focus-visible { outline: 2px solid #2a74c9; border-radius: 3px; }
.login-field .pw-wrap { display: block; }
.login-field .pw-wrap > input { padding-right: 48px; }
.login-field .pw-toggle { right: 10px; width: 30px; height: 30px; background-size: 24px; }

/* ------------------------------------------------------------ form tables */
.frm { border-bottom: 1px solid var(--line); }
.fr { display: grid; grid-template-columns: 150px 1fr; border-bottom: 1px solid var(--line); min-height: 46px; }
.fr:last-child { border-bottom: 0; }
.fr > label { display: flex; align-items: center; justify-content: center; padding: 4px 6px; border-right: 1px solid var(--line); text-align: center; }
.fr > .fc { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 5px 6px; }
.hint { color: var(--red); font-size: 14px; }
.frm.narrow .fr { grid-template-columns: 110px 1fr; }
.search-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.split > .left { border-right: 1px solid var(--line); }
.split .paste { padding: 6px; }
.split .paste textarea { height: 260px; }
.paste-red textarea { border: 2px solid var(--red); }

/* ------------------------------------------------------------ grid tables */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  background: var(--navy); color: #fff; font-weight: bold; padding: 6px 6px; border: 1px solid #5d6fa2; white-space: nowrap; font-size: 16px;
}
table.grid td { border: 1px solid var(--line); padding: 5px 6px; font-size: 16px; }
table.grid tbody tr:hover td { background-color: #eef4ff; }
table.grid td.c, table.grid th.c { text-align: center; }
table.grid td.r { text-align: right; white-space: nowrap; }
table.grid td.no { text-align: center; width: 50px; }
table.grid tr.off td { background: #ddd; color: #666; }
table.grid tr.group td { background: var(--green-row); font-weight: bold; }
table.grid tr.bank-group td { background: #ffd9e0; font-weight: bold; }
table.grid tr.total td, table.grid tfoot td { font-weight: bold; background: #f4f6fb; }
table.grid tr.total-navy td { background: var(--navy); color: #fff; font-weight: bold; }
table.grid tr.add-row td { background: #fde2dc; }
table.grid td.empty { text-align: center; color: #777; padding: 14px; }
table.grid .sub th { font-size: 14px; }
table.grid input[type=text] { width: 100%; }
.neg { color: var(--red) !important; }
.bold { font-weight: bold; }
.blue { color: var(--blue); }
.bg-yellow { background: var(--yellow) !important; }
.bg-gray { background: var(--gray-cell) !important; }
.bg-pink { background: var(--pink) !important; }
.bg-lightblue { background: var(--lightblue) !important; }
.bg-green { background: #c9f0c0 !important; }
th.bg-sky { background: #5d7fc4 !important; }
.daily-link { color: var(--blue); font-weight: bold; cursor: pointer; }
.cell-plus { display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.muted { color: #777; font-size: 13px; }

/* pager */
.pager { display: flex; align-items: center; gap: 6px; font-weight: bold; font-size: 16px; }
.pager select { font-size: 15px; padding: 1px 3px; }

/* ------------------------------------------------------------ modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 50px 10px;
}
.modal {
  background: #fff; border: 2px solid #9fbbe0; border-radius: 6px; width: min(1100px, 96vw); max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.modal-head {
  background: linear-gradient(#97bfe4, #6ea1d4 55%, #8fb8e2); color: #fff; font-weight: bold; font-size: 18px; padding: 9px 18px;
  display: flex; align-items: center; border-radius: 4px 4px 0 0;
}
.modal-head .x { margin-left: auto; background: transparent; border: 0; color: #fff; font-size: 24px; cursor: pointer; line-height: 1; }
.modal-body { padding: 14px 18px; overflow: auto; }

/* toast */
#toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px;
}
#toast div { background: #2b7a3a; color: #fff; padding: 10px 16px; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
#toast div.err { background: #b3261e; }

/* permission states */
.no-perm { padding: 20px; font-size: 18px; }
body.readonly [data-write] { display: none !important; }

/* login */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 28px 20px; background: #f0f2f5;
}
.login-shell {
  width: min(980px, 100%); display: grid; grid-template-columns: 1.08fr 420px;
  align-items: center; gap: 72px;
}
.login-intro { padding-bottom: 34px; }
.brand-mark { color: #1877f2; font: 700 64px/1 Arial, sans-serif; letter-spacing: -3px; }
.login-intro h1 { max-width: 510px; margin: 20px 0 10px; color: #1c1e21; font-size: 28px; line-height: 1.25; }
.login-intro p { margin: 0; color: #606770; font-size: 18px; line-height: 1.5; }
.login-card {
  padding: 18px 18px 24px; border-radius: 8px; background: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .12); text-align: center;
}
.login-card h2 { margin: 2px 0 18px; color: #1c1e21; font-size: 22px; }
.login-form { display: grid; gap: 12px; }
.login-field { display: grid; gap: 5px; text-align: left; color: #606770; font-size: 13px; font-weight: bold; }
.login-field input {
  width: 100%; min-height: 52px; padding: 14px 16px; border: 1px solid #ccd0d5;
  border-radius: 6px; color: #1c1e21; font-size: 16px; outline: 0;
}
.login-field input:focus { border-color: #1877f2; box-shadow: 0 0 0 2px #e7f3ff; }
.login-submit {
  min-height: 48px; margin-top: 4px; border: 0; border-radius: 6px; cursor: pointer;
  background: #1877f2; color: #fff; font-size: 18px; font-weight: bold;
}
.login-submit:hover { background: #166fe5; }
.login-help { display: inline-block; margin: 18px 0 4px; color: #1877f2; font-size: 14px; }
.login-card .err { min-height: 24px; padding-top: 8px; color: var(--red); font-size: 13px; }
@media (max-width: 760px) {
  .login-page { align-items: flex-start; padding: 52px 16px 28px; }
  .login-shell { display: block; max-width: 420px; }
  .login-intro { padding: 0 10px 24px; text-align: center; }
  .brand-mark { font-size: 52px; }
  .login-intro h1 { margin-top: 14px; font-size: 22px; }
  .login-intro p { font-size: 16px; }
}

/* home */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.home-grid .panel ul { list-style: none; margin: 0; padding: 8px 14px; }
.home-grid .panel li { padding: 5px 0; border-bottom: 1px dashed #d6deec; }

/* permission radios */
.rwn { display: flex; justify-content: center; gap: 22px; }
.rwn input { width: 18px; height: 18px; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .fr { grid-template-columns: 110px 1fr; }
  .topbar nav a { padding: 0 8px; font-size: 13px; }
  .topbar .right { font-size: 13px; gap: 8px; }
}
@media print {
  .topbar, .subbar, .tools, [data-write] { display: none !important; }
}
