/* =========================================================
   MAIN.CSS (Navy 2.0)
   Single source of truth for UI styling.
   Structure:
   1. Reset & Base
   2. CSS Variables (:root)
   3. Typography
   4. Layout
   5. Header
   6. Sidebar
   7. Card / Section
   8. Button
   9. Table
   10. Form
   11. Modal
   12. Utility classes
   13. Animation
========================================================= */

/* ============ 1) Reset & Base ============ */
*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}
img{ max-width: 100%; display: block; }
button, input, select, textarea{ font: inherit; }

/* ============ 2) CSS Variables (:root) ============ */
:root{
  /* Colors */
  --c-primary: #1E2A38;
  --c-secondary: #2F3E52;
  --c-accent: #2E5BFF;
  --c-bg: #F4F6F8;
  --c-card: #FFFFFF;
  --c-border: #D1D5DB;
  --c-success: #2E7D32;
  --c-error: #C62828;
  --c-warning: #ED6C02;

  /* Text */
  --c-text: #1E2A38;
  --c-text-muted: #5F6B7A;
  --c-text-invert: #FFFFFF;

  /* Spacing (8px scale) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* Radius */
  --r-1: 8px;
  --r-2: 10px;
  --r-3: 12px;

  /* Shadow (layered subtle) */
  --sh-1: 0 6px 16px rgba(30, 42, 56, 0.10);
  --sh-2: 0 12px 28px rgba(30, 42, 56, 0.14);
  --sh-3: 0 20px 40px rgba(30, 42, 56, 0.18);

  /* Focus ring */
  --ring: 0 0 0 3px rgba(46, 91, 255, 0.16);
}

/* ============ 3) Typography ============ */
body{ font-size: 14px; line-height: 1.5; }
h1{ font-size: 22px; font-weight: 700; }
h2{ font-size: 20px; font-weight: 700; }
h3{ font-size: 18px; font-weight: 700; }
h4{ font-size: 16px; font-weight: 600; }
h1, h2, h3, h4{ margin: 0 0 var(--sp-2); color: var(--c-primary); }
.title{ margin: var(--sp-2) 0 var(--sp-3); font-weight: 700; }
.label-b{ font-weight: 600; margin-bottom: 6px; }
.label-sm{ font-size: 13px; color: var(--c-text-muted); }
.ico{
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: -2px;
  margin-right: 8px;
  color: currentColor;
}

/* ============ 4) Layout ============ */
.app{
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.main{
  flex: 1;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
}
.status-footer{
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: #F8FAFC;
  border-top: 1px solid #D7DEE7;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
  color: #405469;
  font-size: 14px;
}
.status-footer__left,
.status-footer__right{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.status-footer__center{
  color: #1C5DFF;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.2px;
  text-align: center;
  white-space: nowrap;
}
.status-footer__right{
  justify-content: flex-end;
  color: #64778A;
  font-weight: 700;
}
.status-footer__status{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.status-footer__dot{
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #21B15F;
  box-shadow: 0 0 0 4px rgba(33, 177, 95, 0.12);
}
.status-footer__divider{
  color: #A8B5C3;
}
.status-footer__clock{
  display: inline-flex;
  align-items: center;
  min-width: 0;
  padding: 5px 10px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1px solid #D7DEE7;
  color: #203246;
  font-weight: 700;
}
.status-footer__clock .ico{
  width: 16px;
  height: 16px;
  color: #6E7F92;
}

/* ============ 5) Header ============ */
.header{
  min-height: 56px;
  background: linear-gradient(180deg, #233244, #1E2A38);
  color: var(--c-text-invert);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #16212D;
  box-shadow: var(--sh-1);
}
.header-grid{
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  width: 100%;
}
.header-title{
  text-align: center;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.header-left, .header-right{
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.header-right{
  justify-self: end;
}
.server-badge{
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 250px;
  max-width: 340px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.10);
}
.server-badge__label{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.78);
}
.server-badge__runtime{
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.10);
  font-size: 10px;
  color: #FFFFFF;
}
.server-badge__main{
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.server-badge__main span{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: #FFFFFF;
}
.server-badge__sub{
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-badge__actions{
  display: flex;
  gap: 6px;
}
.server-badge__copy{
  flex: 0 0 auto;
  height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  color: #FFFFFF;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.server-badge__copy:hover{
  background: rgba(255,255,255,0.22);
}
.server-badge__copy:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}
.server-badge__action{
  flex: 0 0 auto;
  height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: 999px;
  background: transparent;
  color: rgba(255,255,255,0.88);
  cursor: pointer;
  font-size: 12px;
}
.server-badge__action:hover{
  background: rgba(255,255,255,0.10);
}
.server-badge__details{
  margin: 0;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(7,16,26,0.28);
  color: #F3F8FF;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.45 Consolas, "Courier New", monospace;
}
.server-badge--login{
  width: 100%;
  max-width: none;
  margin-top: 14px;
  margin-bottom: 12px;
  background: rgba(8, 20, 32, 0.35);
}
body[data-page="index"] .header-right .server-badge{
  min-width: 220px;
  max-width: 300px;
  padding: 4px 8px;
  gap: 2px;
}
body[data-page="index"] .header-right .server-badge__label{
  font-size: 10px;
}
body[data-page="index"] .header-right .server-badge__runtime{
  font-size: 9px;
}
body[data-page="index"] .header-right .server-badge__main{
  gap: 6px;
}
body[data-page="index"] .header-right .server-badge__main span{
  font-size: 12px;
}
body[data-page="index"] .header-right .server-badge__copy{
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
}
body[data-page="index"] .header-right .server-badge__sub,
body[data-page="index"] .header-right .server-badge__actions,
body[data-page="index"] .header-right .server-badge__details{
  display: none !important;
}
.sidebar-status{
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
}
.server-badge--sidebar{
  width: 100%;
  max-width: none;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 14px;
  border: 1px solid #c5d1dd;
  background: linear-gradient(180deg, #eef4fb, #e5edf6);
  color: var(--c-primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 8px 18px rgba(30, 42, 56, 0.08);
}
.server-badge--sidebar .server-badge__main{
  gap: 6px;
  align-items: center;
}
.server-badge--sidebar .server-badge__main .ico{
  width: 16px;
  height: 16px;
  margin-right: 0;
  flex: 0 0 auto;
  color: #56708a;
}
.server-badge--sidebar .server-badge__main span{
  color: #13293d;
  font-size: 12px;
  font-weight: 700;
}
.header-quick{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.10);
}
.header-quick .input{
  height: 28px;
  padding: 0 6px;
  border: none;
  background: transparent;
  color: #FFFFFF;
  min-width: 200px;
}
.header-quick .input::placeholder{ color: rgba(255,255,255,0.7); }
.header-quick .input:focus{ box-shadow: none; }
@media (max-width: 980px){
  .header-quick{ display: none; }
  .server-badge{
    min-width: 0;
    max-width: 220px;
  }
  .sidebar-status{
    margin-top: var(--sp-3);
  }
  .header-title{
    font-size: 16px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
  }
  .user-trigger{
    max-width: 165px;
  }
  .user-trigger > span:first-child{
    display: inline-block;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body[data-page="index"] #btn-add-hoso,
  body[data-page="index"] #btn-import-hsta-excel,
  body[data-page="index"] #btn-import-hsc-excel{
    display: none !important;
  }
  body[data-page="index"] .records-toolbar{
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
  }
  body[data-page="index"] .records-toolbar .left,
  body[data-page="index"] .records-toolbar .right{
    flex-wrap: wrap;
    width: 100%;
  }
  body[data-page="index"] .status-footer{
    display: none;
  }
}
@media (max-width: 720px){
  .server-badge{
    min-width: 0;
    max-width: none;
  }
}
@media (max-width: 1500px){
  .header-quick{
    display: none;
  }
}
@media (max-height: 860px), (max-width: 1366px){
  .app{
    min-height: 0;
  }
  .main{
    padding: 16px;
  }
  .header{
    min-height: 48px;
  }
  .header-grid{
    padding: 6px 10px;
  }
  .header-title{
    font-size: 18px;
  }
  .icon-btn{
    width: 32px;
    height: 32px;
  }
  .server-badge{
    min-width: 210px;
    max-width: 285px;
    padding: 4px 8px;
    gap: 3px;
  }
  .server-badge__sub{
    display: none;
  }
  .server-badge__copy,
  .server-badge__action{
    height: 22px;
    padding: 0 8px;
    font-size: 11px;
  }
  .server-badge__details{
    max-height: 110px;
    overflow: auto;
    font-size: 11px;
  }
  .user-trigger{
    padding: 5px 8px;
    font-size: 13px;
  }
  .section{
    padding: 14px;
  }
  .filter-bar{
    margin-bottom: 12px;
  }
  .records-toolbar{
    padding: 10px 12px;
  }
  .records-pager{
    padding: 8px 10px;
  }
  .btn{
    height: 34px;
    padding: 0 12px;
  }
  .btn.xs{
    height: 24px;
    padding: 0 8px;
  }
  .input, .select, .textarea{
    height: 34px;
  }
}
.icon-btn{
  appearance: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-2);
  background: rgba(255,255,255,0.10);
  color: var(--c-text-invert);
  cursor: pointer;
  transition: background 0.15s ease;
}
.icon-btn:hover{ background: rgba(255,255,255,0.18); }

/* User menu */
.user-menu-box{ position: relative; }
.user-trigger{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.10);
  color: var(--c-text-invert);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.user-dropdown{
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: var(--c-card);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-2);
  box-shadow: var(--sh-2);
  padding: 6px;
  display: none;
  z-index: 10000;
}
.user-menu-box.open .user-dropdown{ display: block; }
.dropdown-item{
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-1);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}
.dropdown-item:hover{ background: #F1F4F8; }
.dropdown-item.danger{ color: var(--c-error); }

/* ============ 6) Sidebar ============ */
.sidebar{
  width: 240px;
  background: linear-gradient(180deg, #F7F9FB, #EEF2F6);
  border-right: 1px solid var(--c-border);
  padding: var(--sp-2);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.group-title{
  background: #E9EEF5;
  color: var(--c-primary);
  font-weight: 700;
  padding: 8px 10px;
  margin: var(--sp-2) 0 var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-2);
  font-size: 12px;
  letter-spacing: 0.4px;
}
.nav{ display: flex; flex-direction: column; gap: var(--sp-2); }
.nav a{
  text-decoration: none;
  color: var(--c-secondary);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  padding: 10px 12px;
  border-radius: var(--r-2);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.25;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.nav a:hover{
  background: #F1F5FB;
  transform: translateY(-1px);
  box-shadow: var(--sh-1);
}
.nav a.active,
.nav a[aria-current="page"]{
  background: #E8EFFF;
  border-color: #9DB2FF;
  color: var(--c-primary);
}

/* Sidebar collapsed / mobile */
.body--sidebar-collapsed .sidebar{
  width: 0;
  min-width: 0;
  padding: 0;
  border-right: none;
  overflow: hidden;
  transition: width 0.18s ease, padding 0.18s ease;
}
.body--sidebar-collapsed .main{ flex: 1; }
.sidebar-overlay{
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(30,42,56,0.35);
  display: none;
  z-index: 55;
}
.body--sidebar-open .sidebar-overlay{ display: block; }
.sidebar-handle{
  position: fixed;
  left: 6px;
  top: 64px;
  z-index: 40;
  display: none;
  padding: 6px 10px;
  border-radius: var(--r-2);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-1);
  cursor: pointer;
  user-select: none;
}
.body--sidebar-collapsed .sidebar-handle{ display: inline-flex; }

@media (max-width: 980px){
  .sidebar{
    position: fixed;
    inset: 56px auto 0 0;
    width: 280px;
    max-width: 86vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 60;
    box-shadow: var(--sh-2);
  }
  .body--sidebar-open .sidebar{ transform: translateX(0); }
  .sidebar-handle{ display: none !important; }
}

/* ============ 7) Card / Section ============ */
.section{
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: var(--sp-3);
  box-shadow: var(--sh-1);
}
.section--records{
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}
.section--records .records-progress{
  position: sticky;
  top: 48px;
  z-index: 9;
  background: #F7F9FC;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-border);
}

/* ============ 8) Button ============ */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid #1B3ED6;
  background: #2E5BFF;
  color: var(--c-text-invert);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(46, 91, 255, 0.20);
}
.btn + .btn{ margin-left: 5px; }
.btn:hover{
  transform: translateY(-1px);
  background: #2550E0;
  box-shadow: 0 10px 18px rgba(46, 91, 255, 0.24);
}
.btn:active{ transform: translateY(0); }
.btn.ghost{
  background: #FFFFFF;
  border: 1px solid var(--c-border);
  color: var(--c-secondary);
  box-shadow: none;
}
.btn.danger{
  background: #C62828;
  border-color: #A61F1F;
}
.btn.success{
  background: #2E7D32;
  border-color: #256628;
}
.btn.warning{
  background: #ED6C02;
  border-color: #C85B00;
}
.btn.xs{
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

/* ============ 9) Table ============ */
.table-wrap{
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-3);
  overflow: visible;
  box-shadow: var(--sh-1);
  flex: 0 0 auto;
  min-height: auto;
}
.table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table th, .table td{
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  line-height: 1.4;
}
.table th.select-col,
.table td.select-col{
  width: 36px;
  text-align: center;
  padding: 8px;
}
.table th.select-col input,
.table td.select-col input{
  width: 16px;
  height: 16px;
}
.table th{
  background: #EEF3F9;
  color: var(--c-primary);
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 700;
}
.table tr:nth-child(odd) td{ background: #FAFBFC; }
.table tr:nth-child(even) td{ background: #F4F7FA; }
.table tr:hover td{ background: #EEF4FF; }
.table td{ white-space: pre-wrap; }

/* ============ 10) Form ============ */
.input, .select, .textarea{
  width: 100%;
  border: 1px solid var(--c-border);
  padding: 0 12px;
  height: 38px;
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--c-text);
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus{
  border-color: #5B7CFF;
  box-shadow: var(--ring);
}
.textarea{ min-height: 100px; resize: vertical; padding: 10px 12px; height: auto; }
.filter-bar{
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 16px;
}
.records-toolbar{
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 12px 16px;
  background: #F7F9FC;
  border-bottom: 1px solid var(--c-border);
  border-top-left-radius: var(--r-3);
  border-top-right-radius: var(--r-3);
}
.records-toolbar .left{
  display: flex;
  align-items: center;
  gap: 5px;
}
.mt-pane-toolbar{
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.mt-pane-toolbar .mt-search{
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.mt-pane-toolbar .btn + .btn{
  margin-left: 5px;
}
.mt-pane-toolbar > div{
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Borrow/Loan modal layout (enterprise balance) */
.mt-grid{
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  align-items: start;
}
.mt-grid > div:nth-child(2){ display: none; }
.mt-col{
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.mt-title{
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--c-primary);
}
.mt-row{
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.mt-row .grow{ flex: 1; min-width: 0; }
.mt-actions{
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin: 12px 0 10px;
  justify-content: flex-start;
}
.mt-search{
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.mt-pane-toolbar{
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-card);
  box-shadow: var(--sh-1);
}
.mt-pane-toolbar .mt-search{
  margin-left: auto;
}
.mt-pane-toolbar .mt-search .input{
  min-width: 220px;
}
.mt-list{
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: #FFFFFF;
  max-height: 42vh;
  overflow: auto;
  padding: 8px;
  box-shadow: var(--sh-1);
  flex: 1;
}
.mt-list table{ width: 100%; border-collapse: separate; border-spacing: 0; }
.mt-list th, .mt-list td{
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
}
.mt-list thead th{
  position: sticky;
  top: 0;
  background: #F5F7FA;
  font-weight: 600;
}
.mt-ticket-table{
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: #FFFFFF;
  max-height: 52vh;
  overflow: auto;
  padding: 8px;
  box-shadow: var(--sh-1);
  flex: 1;
}
.mt-ticket-table table{ width: 100%; border-collapse: separate; border-spacing: 0; }
.mt-ticket-table th, .mt-ticket-table td{
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
}
.mt-ticket-table thead th{
  position: sticky;
  top: 0;
  background: #F5F7FA;
  font-weight: 600;
}
.mt-ticket-table th, .mt-ticket-table td{
  text-align: left;
  vertical-align: middle;
}
.mt-ticket-table thead th:nth-child(4),
.mt-ticket-table tbody td:nth-child(4),
.mt-ticket-table thead th:nth-child(5),
.mt-ticket-table tbody td:nth-child(5){
  text-align: center;
}

/* Borrow/Loan modal grouping cards (left column) */
.mt-col .mt-row{
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-card);
  padding: 16px;
  box-shadow: var(--sh-1);
}
.mt-col .mt-actions{
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-card);
  padding: 12px 16px;
  box-shadow: var(--sh-1);
}

/* Borrow/Loan modal button hierarchy */
#mt-borrow{ background: var(--c-accent); border-color: #1B3ED6; }
#mt-print{ background: #FFFFFF; color: var(--c-secondary); border-color: var(--c-border); box-shadow: none; }
#mt-clear{ background: var(--c-error); border-color: #A61F1F; }

/* Borrow/Loan modal footer */
.mt-grid + div{
  border-top: 1px solid var(--c-border);
  padding-top: 16px;
  margin-top: 8px;
}

/* Borrow/Loan modal refined spacing */
.mt-col .label-sm{ margin-bottom: 4px; }
.mt-col .form-row{ margin-bottom: 12px; }

/* Borrow/Loan modal table sizing */
.mt-list table,
.mt-ticket-table table{
  width: 100%;
  table-layout: auto;
}
.mt-list{ overflow: auto; }

/* HSC action buttons on one row */
#hscTableBody td:last-child{
  white-space: nowrap;
}
#hscTableBody td:last-child .btn{
  display: inline-flex;
  align-items: center;
}
#hscTableBody td:last-child .btn + .btn{
  margin-left: 6px;
}
.mt-ticket-table{ overflow: auto; }
.mt-list table th,
.mt-list table td,
.mt-ticket-table table th,
.mt-ticket-table table td{
  white-space: normal;
}
.mt-ticket-table table th:nth-child(1),
.mt-ticket-table table td:nth-child(1){
  min-width: 180px;
}
.mt-ticket-table table th:nth-child(2),
.mt-ticket-table table td:nth-child(2){
  min-width: 130px;
  white-space: normal;
  word-break: break-word;
}
.mt-ticket-table table th:nth-child(3),
.mt-ticket-table table td:nth-child(3){
  min-width: 220px;
  white-space: normal;
  word-break: break-word;
}
.mt-ticket-table table th:nth-child(4),
.mt-ticket-table table td:nth-child(4){
  min-width: 120px;
  text-align: center;
}
.mt-ticket-table table th:nth-child(5),
.mt-ticket-table table td:nth-child(5){
  min-width: 70px;
  text-align: center;
}

/* Subtle zebra + hover for modal tables */
.mt-list table tbody tr:nth-child(odd) td,
.mt-ticket-table table tbody tr:nth-child(odd) td{
  background: #FAFBFC;
}
.mt-list table tbody tr:hover td,
.mt-ticket-table table tbody tr:hover td{
  background: #EEF2F7;
}
.account-admin-modal{
  width: min(1320px, 96vw);
}
.account-admin-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.account-online-chip{
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #d6e2ef;
  background: linear-gradient(180deg, #f9fbff, #eef4fb);
  color: #35506b;
  font-size: 13px;
  font-weight: 700;
}
.account-admin-form{
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: end;
}
.account-admin-table-wrap{
  margin-top: 16px;
  max-height: 58vh;
  overflow: auto;
}
.account-admin-table{
  min-width: 1120px;
}
.account-admin-table th:nth-child(1),
.account-admin-table td:nth-child(1){
  width: 90px;
}
.account-admin-table th:nth-child(3),
.account-admin-table td:nth-child(3){
  width: 150px;
}
.account-admin-table th:nth-child(4),
.account-admin-table td:nth-child(4){
  width: 290px;
}
.account-admin-table td{
  vertical-align: middle;
}
.account-perm-cell{
  min-width: 260px;
}
.account-perm-grid{
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
}
.account-perm-toggle{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 78px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #d6dee8;
  border-radius: 10px;
  background: #fff;
  color: #31475d;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.account-perm-toggle input{
  margin: 0;
}
.account-admin-footer{
  text-align: right;
  margin-top: 16px;
}
.loan-workflow-modal{
  width: min(1500px, 96vw);
}
.loan-workflow-grid{
  grid-template-columns: 500px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
.loan-workflow-sidebar{
  min-width: 0;
}
.loan-workflow-main{
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 72vh;
  padding: 16px;
  border: 1px solid #d7e0eb;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff, #f3f7fb);
  box-shadow: var(--sh-1);
}
.loan-workflow-main .loan-workflow-tabs{
  justify-content: flex-end;
}
.loan-form-card,
.loan-form-actions{
  margin: 0;
}
.loan-mhs-picker{
  display: flex;
  gap: 8px;
  position: relative;
}
.loan-mhs-suggest{
  display: none;
  position: absolute;
  left: 0;
  right: 120px;
  top: 100%;
  background: #fff;
  border: 1px solid #d7e5f3;
  border-top: none;
  max-height: 260px;
  overflow: auto;
  z-index: 9999;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 10px 22px -16px rgba(14,30,52,.28);
}
.loan-clear-wrap{
  align-self: flex-end;
}
.loan-workflow-tabs{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.loan-tab{
  border-color: #c9d6e3;
  background: #f5f8fc;
  color: #31475d;
}
.loan-tab.is-active{
  background: #1e2a38;
  color: #fff;
  border-color: #1e2a38;
}
.loan-toolbar{
  margin-top: 2px;
  background: #fff;
}
.loan-checkbox{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--c-text);
  font-weight: 600;
}
.loan-request-row{
  cursor: pointer;
}
.loan-request-row.is-active td{
  background: #e8efff !important;
}
.loan-request-table{
  max-height: 34vh;
}
.loan-detail-card{
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--sh-1);
  min-height: 260px;
}
.loan-detail-head{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.loan-detail-code{
  font-size: 18px;
  font-weight: 700;
  color: var(--c-primary);
}
.loan-detail-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
#lw-detail-meta,
.loan-detail-meta{
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 12px 16px;
  color: var(--c-text);
  align-items: start;
}
#lw-detail-meta > span,
.loan-detail-meta > span,
.loan-detail-meta__item{
  display: block;
  min-width: 0;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.loan-detail-meta__label{
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted);
}
.loan-detail-meta__value{
  color: var(--c-primary);
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.loan-detail-note{
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--c-text-muted);
}
.loan-selected-table{
  max-height: 30vh;
}
.loan-detail-list{
  max-height: 28vh;
}
.loan-detail-list table{
  width: 100%;
  table-layout: fixed;
}
.loan-detail-list table th,
.loan-detail-list table td{
  text-align: center;
  vertical-align: middle;
}
.loan-detail-list table th:nth-child(1),
.loan-detail-list table td:nth-child(1){
  width: 44px;
}
.loan-detail-list table th:nth-child(2),
.loan-detail-list table td:nth-child(2){
  width: 90px;
}
.loan-detail-list table th:nth-child(3),
.loan-detail-list table td:nth-child(3){
  width: 180px;
}
.loan-detail-list table th:nth-child(4),
.loan-detail-list table td:nth-child(4){
  width: auto;
}
.loan-detail-list table th:nth-child(5),
.loan-detail-list table td:nth-child(5){
  width: 150px;
}
.loan-workflow-footer{
  text-align: right;
  margin-top: 16px;
}
.inventory-modal{
  width: min(1520px, 97vw);
}
.inventory-grid{
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 18px;
  min-height: 70vh;
}
.inventory-sidebar,
.inventory-main{
  min-width: 0;
}
.inventory-sidebar{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.inventory-card{
  margin: 0;
}
.inventory-session-table{
  max-height: calc(70vh - 148px);
}
.inventory-session-table table{
  table-layout: fixed;
}
.inventory-session-table th:nth-child(1),
.inventory-session-table td:nth-child(1){
  width: 180px;
  word-break: break-word;
}
.inventory-session-table th:nth-child(2),
.inventory-session-table td:nth-child(2){
  width: 130px;
}
.inventory-session-table th:nth-child(3),
.inventory-session-table td:nth-child(3){
  width: 140px;
}
.inventory-session-table th:nth-child(4),
.inventory-session-table td:nth-child(4){
  width: 70px;
  text-align: center;
}
.inventory-main .loan-detail-card{
  min-height: 100%;
}
.inventory-summary-grid{
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
}
.inventory-summary-card{
  border: 1px solid #d8e1eb;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f1f6fb);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inventory-summary-card span{
  font-size: 12px;
  color: var(--c-text-muted);
}
.inventory-summary-card b{
  font-size: 24px;
  color: var(--c-primary);
}
.inventory-filter-bar{
  padding: 12px;
}
.inventory-item-table{
  max-height: 48vh;
}
.inventory-item-table table th:nth-child(1),
.inventory-item-table table td:nth-child(1){
  min-width: 160px;
}
.inventory-item-table table th:nth-child(2),
.inventory-item-table table td:nth-child(2){
  min-width: 120px;
}
.inventory-item-table table th:nth-child(3),
.inventory-item-table table td:nth-child(3),
.inventory-item-table table th:nth-child(4),
.inventory-item-table table td:nth-child(4){
  min-width: 90px;
}
.inventory-item-table table th:nth-child(5),
.inventory-item-table table td:nth-child(5){
  min-width: 120px;
}
.inventory-item-table table th:nth-child(6),
.inventory-item-table table td:nth-child(6){
  min-width: 250px;
}
.records-pager{
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #F7F9FC;
  border-bottom: 1px solid var(--c-border);
  border-radius: var(--r-2);
}
.pager-buttons{ display: inline-flex; gap: 5px; flex-wrap: wrap; }
.pager-button{
  border: 1px solid var(--c-border);
  background: #FFFFFF;
  padding: 6px 10px;
  border-radius: var(--r-2);
  cursor: pointer;
}
.pager-button.active{
  font-weight: 700;
  background: #E8EFFF;
  border-color: #9DB2FF;
}
.pager-button:disabled{ opacity: 0.55; cursor: not-allowed; }

/* ============ 11) Modal ============ */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(30, 42, 56, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1500;
}
.modal-overlay.is-open{ display: flex; }
.modal{
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  width: min(1600px, 98vw);
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  box-shadow: var(--sh-3);
}
.modal h3{
  margin: 0 0 var(--sp-3);
  font-size: 18px;
  letter-spacing: 0.2px;
  color: var(--c-primary);
  font-weight: 700;
}

/* Context menu */
.context-menu{
  position: absolute;
  z-index: 2000;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-3);
  box-shadow: var(--sh-2);
  display: none;
  min-width: 220px;
  overflow: hidden;
}
.context-menu ul{ margin: 0; padding: 6px 0; list-style: none; }
.context-menu li{
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s ease;
}
.context-menu li:hover{ background: #F2F6FB; }

/* Badge */
.badge{
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--c-border);
  background: #F7FBFF;
  color: var(--c-primary);
}
.badge.warn{ background: #FFF5E8; border-color: #F1C186; color: #7A4A00; }
.badge.ok{ background: #ECFFF0; border-color: #A6E0B7; color: #176B2B; }

/* Dialog */
.dialog-overlay{
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(30, 42, 56, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
}
.dialog-overlay.open{ display: flex; }
.dialog{
  width: min(520px, 94vw);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-3);
  padding: var(--sp-3);
  box-shadow: var(--sh-2);
}
.dialog h4{ margin: 0 0 var(--sp-2); font-size: 18px; color: var(--c-primary); }
.dialog p{ margin: 0; color: var(--c-text-muted); white-space: pre-wrap; }
.dialog .dlg-input{
  margin-top: var(--sp-2);
  width: 100%;
  height: 36px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-2);
  padding: 0 10px;
}
.dialog .footer{
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  margin-top: var(--sp-3);
}

/* Toasts */
.toast-host{
  position: fixed;
  inset: auto 16px 16px auto;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, 92vw);
}
.toast{
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-3);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-2);
  color: var(--c-text);
  animation: toast-in 0.18s ease-out;
}
.toast .title{ font-weight: 700; margin: 0 0 2px; color: var(--c-primary); }
.toast .msg{ margin: 0; color: var(--c-text-muted); white-space: pre-wrap; }
.toast.info    { border-color:#9DB2FF; background: #F6F8FF; }
.toast.success { border-color:#9AD0A3; background: #F4FBF6; }
.toast.warn    { border-color:#F2C08D; background: #FFF7EF; }
.toast.danger  { border-color:#E6A5A5; background: #FFF4F4; }
.toast .close{
  appearance: none;
  border: none;
  background: transparent;
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}
.toast .progress{
  margin-top: 8px;
  height: 4px;
  border-radius: 999px;
  background: #EEF2F7;
  border: 1px solid var(--c-border);
  overflow: hidden;
}
.toast .progress div{
  height: 100%;
  background: linear-gradient(90deg, #2E5BFF, #1E2A38);
  width: 0%;
  transition: width linear;
}

/* Change Password (scoped styles) */
#changePwOverlay{
  position: fixed;
  inset: 0;
  background: rgba(30, 42, 56, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#changePwOverlay.is-open{ display: flex; }
#changePwOverlay .cp-card{
  width: min(540px, 94vw);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-3);
  padding: var(--sp-4);
  box-shadow: var(--sh-2);
}
#changePwOverlay .cp-title{
  margin: 0 0 var(--sp-3);
  font-size: 18px;
  font-weight: 700;
  color: var(--c-primary);
}
#changePwOverlay #changePwForm{
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-2);
}
#changePwOverlay .field{ display: grid; gap: 6px; }
#changePwOverlay .label-sm{
  font-size: 13px;
  color: var(--c-text-muted);
  font-weight: 600;
}
#changePwOverlay #cp-error{
  display: none;
  background: #FFF1F1;
  color: #8B1E1E;
  border: 1px solid #F0C2C2;
  border-radius: var(--r-2);
  padding: 8px 10px;
  font-size: 13px;
}
#changePwOverlay .actions{
  display: flex;
  gap: 5px;
  justify-content: flex-end;
  margin-top: var(--sp-2);
}

/* Label Modal (print) */
.label-modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  z-index: 1000;
}
.label-modal[aria-hidden="false"]{ display: block; }
.label-modal__dialog{
  background: #FFFFFF;
  width: min(1200px, 96vw);
  height: min(92vh, 950px);
  margin: 2vh auto;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  box-shadow: var(--sh-3);
  border-radius: var(--r-3);
  overflow: hidden;
}
.label-modal__left{
  background: #F7F8FA;
  padding: var(--sp-3);
  overflow: auto;
}
.label-modal__right{
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: var(--sp-3);
}
.form-row{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-row label{
  font: 600 14px/1.2 "Inter","Segoe UI",sans-serif;
  color: var(--c-primary);
}
.form-row input, .form-row select{
  height: 36px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-2);
  padding: 0 10px;
  font: 14px/1.2 "Inter","Segoe UI",sans-serif;
}
.actions{
  display: flex;
  gap: 5px;
  margin-top: var(--sp-2);
}

/* A4 preview */
.label-modal__right .sheet-wrap{
  height: calc(100vh - 150px);
  background: #F3F4F6;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-2);
}
.sheet-a4{
  width: 210mm;
  height: 297mm;
  background: #FFFFFF;
  border: 3mm solid #111;
  box-sizing: border-box;
  padding: 18mm 18mm 16mm;
  display: flex;
  flex-direction: column;
  gap: 7mm;
  font-family: "Times New Roman", Times, serif;
  color: #111;
}
.header-line{
  height: 12mm;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 24pt;
  font-family: "Times New Roman", Times, serif;
}
.header-line--supreme{
  display: none;
  height: 10mm;
  font-size: 19pt;
  letter-spacing: .4px;
}
.sheet-a4[data-print-style="supreme"] .header-line--supreme{
  display: flex;
}
.sheet-a4 .title{
  text-align: center;
  margin: 2mm 0 0;
  font-weight: 800;
  font-size: 48pt;
  font-family: "Times New Roman", Times, serif;
}
.boxno-wrap{
  height: 50mm;
  border: 1px solid #CBD5E1;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.boxno{
  font-weight: 800;
  font-size: 140pt;
  line-height: 1;
  font-family: "Times New Roman", Times, serif;
}
.pair-row{
  display: grid;
  grid-template-columns: 55mm 1fr;
  align-items: center;
  column-gap: 12mm;
}
.pair-row .label{
  font-weight: 700;
  font-size: 28pt;
  font-family: "Times New Roman", Times, serif;
}
.pair-row .value{
  min-height: 14mm;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 10mm;
  font-size: 28pt;
  font-family: "Times New Roman", Times, serif;
}
.single-row{
  min-height: 14mm;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8mm;
  font-size: 30pt;
  font-family: "Times New Roman", Times, serif;
}
.spacer{ flex: 1; }
.barcode-wrap{ text-align: center; margin-top: 12mm; }
.barcode-wrap svg, .barcode-wrap img{ width: 100%; height: 42mm; object-fit: contain; }
.barcode-text{
  margin-top: 4mm;
  font: 700 14pt Consolas, "Courier New", monospace;
  letter-spacing: 1px;
}

/* ============ 12) Utility classes ============ */
.grid-2col{ display: grid; grid-template-columns: 1fr 1fr; }
.gap16{ gap: 16px; }
.stack{ display: flex; flex-direction: column; }
.stack.gap16 > *{ margin-bottom: 16px; }
.stack.gap16 > *:last-child{ margin-bottom: 0; }
.line{ display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.lineList{ margin-top: 8px; display: flex; flex-direction: column; }
.listbox{ height: 160px; }
.dcq-block{
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  gap: 8px 10px;
  align-items: start;
}
.dcq-input{ grid-column: 1; grid-row: 1; }
.dcq-add{ grid-column: 2; grid-row: 1; }
.dcq-list{ grid-column: 1; grid-row: 2; height: 220px; }
.dcq-del{ grid-column: 2; grid-row: 2; align-self: start; }
.agency-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}
.agency-grid .box{
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 12px;
  background: #FFFFFF;
  border: 1px solid #D7DEE7;
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(30, 42, 56, 0.10);
}
.agency-grid .hd{
  font-size: 12.5px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #334155;
  margin-bottom: 2px;
}
.agency-grid .hd::after{
  content: "";
  display: block;
  margin-top: 8px;
  height: 1px;
  background: #E5E9F0;
}
.agency-grid .line{
  display: flex;
  gap: 10px;
  align-items: center;
}
.agency-grid .line .input{ flex: 1; }
.agency-grid .listbox{
  width: 100%;
  min-height: 0;
  background: #F9FBFD;
  border: 1px solid #D7DEE7;
  border-radius: 10px;
  padding: 8px;
  resize: vertical;
}

/* ============ 13) Animation ============ */
@keyframes toast-in{
  from{ opacity: 0; transform: translateY(6px) scale(0.98); }
  to{ opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Responsive ===== */
@media (max-width: 720px){
  .filter-bar{ flex-direction: column; align-items: stretch; }
  .records-toolbar .right{ display: none; }
  .section--records .table-wrap{ overflow-x: auto; }
  .table th, .table td{ padding: 8px; font-size: 14px; }
}

/* =========================================================
   Unified Popup Layout (Overdue / Labels / Records / Loans / Trace)
========================================================= */
/* Overdue modal (Mượn quá hạn) */
.ov-grid{
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  width: 100%;
}
.ov-left{
  background: #FFFFFF;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--sh-1);
}
.ov-right{
  background: #FFFFFF;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--sh-1);
  min-height: 320px;
}
.ov-actions{
  display: flex;
  gap: 5px;
  margin-top: 16px;
}
.ov-toolbar{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* Label modal (In nhãn hộp) */
.label-modal__dialog{
  border-radius: 12px;
  box-shadow: var(--sh-3);
}
.label-modal__left{
  background: #FFFFFF;
  border-right: 1px solid var(--c-border);
}
.label-modal__right{
  background: #FFFFFF;
}
.label-modal__left .form-row{ margin-bottom: 12px; }
.label-modal__left .actions{ gap: 5px; }

/* Records user (Người khai thác) */
#recordsUserOverlay .mt-pane-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: var(--sh-1);
}
#recordsUserOverlay .mt-search{
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 5px;
}
#recordsUserOverlay .mt-search .input{
  min-width: 320px;
  max-width: 520px;
}
#recordsUserOverlay .mt-pane-toolbar > div:last-child{
  display: flex;
  align-items: center;
  gap: 8px;
}
#recordsUserOverlay .records-pager{
  margin-top: 12px;
}
#recordsUserOverlay,
#ru-form-overlay .dialog{
  color: var(--c-text);
}
#recordsUserOverlay .input,
#ru-form-overlay .input{
  color: var(--c-text) !important;
  background: #FFFFFF !important;
}
#recordsUserOverlay .input::placeholder,
#ru-form-overlay .input::placeholder{
  color: #7D8EA0 !important;
}
#ru-form-overlay .label-b,
#ru-form-overlay h4{
  color: var(--c-primary) !important;
}

/* Loans active & Trace */
#activeLoansOverlay .mt-pane-toolbar,
#traceOverlay .mt-pane-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: var(--sh-1);
}
#activeLoansOverlay .mt-search,
#traceOverlay .mt-search{
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 5px;
}
#activeLoansOverlay .mt-search .input,
#traceOverlay .mt-search .input{
  min-width: 320px;
  max-width: 520px;
}
#activeLoansOverlay .mt-pane-toolbar > .btn,
#traceOverlay .mt-pane-toolbar > .btn{
  margin-left: auto;
}
#activeLoansOverlay .mt-ticket-table,
#traceOverlay .mt-ticket-table{
  border-radius: 12px;
  box-shadow: var(--sh-1);
}

/* ===== Role-based visibility ===== */
html[data-role="Người dùng"] .role-manager-up,
html[data-role="Người dùng"] .role-admin-only,
html[data-role="Quản lý vận hành"] .role-admin-only{
  display: none !important;
}

/* ===== Print ===== */
@media print{
  .btn, .nav, .sidebar, .records-toolbar, .records-pager, .records-progress, #loanContextMenu{ display: none !important; }
  .header-line, .boxno-wrap, .pair-row .value, .single-row{ border: none !important; }
  body *{ visibility: hidden !important; }
  #sheetA4, #sheetA4 *{ visibility: visible !important; }
  #sheetA4{ position: fixed; inset: 0; margin: auto; transform: none !important; box-shadow: none; }
}

/* ===== Login Page ===== */
.bg{
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(720px 420px at 12% 18%, rgba(255, 211, 132, 0.55), transparent 62%),
    radial-gradient(760px 460px at 88% 16%, rgba(113, 201, 255, 0.42), transparent 64%),
    radial-gradient(900px 520px at 52% 100%, rgba(186, 246, 214, 0.52), transparent 58%),
    linear-gradient(180deg, #fdf7ea 0%, #f4fbff 46%, #eef8f4 100%);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.bg-overlay{
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.34), rgba(255,255,255,0.08)),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.16) 0 18px, rgba(255,255,255,0.04) 18px 36px);
  opacity: 0.9;
  pointer-events: none;
}
.login-wrap{
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-card{
  position: relative;
  width: min(430px, 92vw);
  padding: 34px 30px 28px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.88));
  border: 1px solid rgba(255,255,255,0.72);
  box-shadow:
    0 24px 60px rgba(87, 123, 153, 0.18),
    0 10px 26px rgba(255, 197, 91, 0.12);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
.card-decoration{
  position: absolute;
  top: -88px;
  right: -44px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.95), rgba(255, 208, 99, 0.24) 48%, rgba(255, 208, 99, 0) 72%);
  pointer-events: none;
}
.card-glow{
  position: absolute;
  left: -68px;
  bottom: -92px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 224, 192, 0.28), rgba(124, 224, 192, 0) 66%);
  pointer-events: none;
}
.brand{
  position: relative;
  text-align: center;
  margin-bottom: 18px;
}
.brand-logo{
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(220, 232, 243, 0.95);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.92),
    0 12px 24px rgba(87, 184, 255, 0.18);
  object-fit: contain;
}
.brand h2{
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.4px;
  color: #1f3650;
}
.brand .sub{
  margin: 0;
  color: #5f7690;
  font-size: 14px;
}
.field{ margin-top: 12px; }
.field input{
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid #d8e4ef;
  background: rgba(255,255,255,0.92);
  color: #24384d;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75);
  transition: border 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.field input::placeholder{ color: #8da0b3; }
.field input:focus{
  border-color: #79bfff;
  box-shadow: 0 0 0 4px rgba(121, 191, 255, 0.18);
  background: #ffffff;
  transform: translateY(-1px);
}
.btn-primary{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  margin-top: 18px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  color: #FFFFFF;
  font-weight: 800;
  letter-spacing: 0.15px;
  background: linear-gradient(135deg, #ffb347 0%, #ffcf5a 42%, #57b8ff 100%);
  box-shadow:
    0 14px 28px rgba(87, 184, 255, 0.24),
    0 8px 18px rgba(255, 179, 71, 0.22);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
  overflow: hidden;
}
.btn-primary .sheen{
  position: absolute;
  inset: 0 auto 0 -34%;
  width: 32%;
  transform: skewX(-24deg);
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.55), rgba(255,255,255,0));
  opacity: 0.9;
}
.btn-primary:hover{
  transform: translateY(-1px);
  background: linear-gradient(135deg, #ffae3b 0%, #ffd45e 42%, #49afff 100%);
  box-shadow:
    0 18px 34px rgba(87, 184, 255, 0.28),
    0 12px 24px rgba(255, 179, 71, 0.24);
}
.setup-login-hint{
  margin-top: 14px;
  color: #687d91;
  font-size: 13px;
  text-align: center;
}
.setup-login-actions{
  margin-top: 16px;
  display: flex;
  justify-content: center;
}
.setup-login-actions .btn{
  min-width: 220px;
}
.setup-shell{
  min-height: 100vh;
  background:
    radial-gradient(720px 420px at 12% 18%, rgba(255, 211, 132, 0.28), transparent 62%),
    radial-gradient(760px 460px at 88% 16%, rgba(113, 201, 255, 0.22), transparent 64%),
    linear-gradient(180deg, #f8fbff 0%, #eff6fb 100%);
  padding: 24px;
}
.setup-header{
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.setup-kicker{
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #617990;
  margin-bottom: 6px;
}
.setup-title{
  margin: 0 0 6px;
  font-size: 30px;
  color: #1f3650;
}
.setup-sub{
  margin: 0;
  color: #5f7690;
}
.setup-header-actions{
  display: flex;
  gap: 8px;
  align-items: center;
}
.setup-main{
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.setup-stats{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.setup-stat{
  border: 1px solid #d7e2ed;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 14px 16px;
}
.setup-stat__value{
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
  color: #1f3650;
  word-break: break-word;
}
.setup-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.setup-grid .field:first-child:last-child,
.setup-grid .field:first-child:nth-last-child(1),
.setup-grid .field:first-child:nth-last-child(3){
  grid-column: 1 / -1;
}
.setup-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.setup-table-list{
  margin-top: 14px;
  border: 1px solid #d7e2ed;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  overflow: hidden;
}
.setup-table-list__head,
.setup-table-list__row{
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 16px;
}
.setup-table-list__head{
  background: #eef5fb;
  color: #5a7189;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.setup-table-list__row{
  border-top: 1px solid #e4edf5;
  color: #1f3650;
  word-break: break-word;
}
.setup-table-list__row:nth-child(even){
  background: rgba(239, 246, 251, 0.55);
}
.setup-table-list__row{
  cursor: context-menu;
}
.setup-table-list__row:hover{
  background: #eef4ff;
}
.setup-context-menu[hidden]{
  display: none;
}
.setup-table-browser-modal{
  width: min(1600px, 97vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.setup-table-browser__header{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.setup-table-browser__meta,
.setup-table-browser__footer{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.setup-table-browser__body{
  border: 1px solid #d7e2ed;
  border-radius: 14px;
  overflow: auto;
  max-height: 60vh;
  background: #fff;
}
.setup-table-browser__table{
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
.setup-table-browser__table th,
.setup-table-browser__table td{
  padding: 10px 12px;
  border-bottom: 1px solid #e4edf5;
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
}
.setup-table-browser__table thead th{
  position: sticky;
  top: 0;
  background: #eef5fb;
  color: #39526b;
  z-index: 1;
}
.setup-table-browser__table tbody tr:nth-child(odd) td{
  background: #fbfdff;
}
.setup-table-browser__table tbody tr:hover td{
  background: #eef4ff;
}
.setup-table-browser__table td.is-null{
  color: #8ea0b2;
  font-style: italic;
}
.setup-table-browser__actions{
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.setup-table-browser__actions .btn{
  padding: 8px 10px;
  min-height: 0;
  font-size: 13px;
}
.setup-table-browser__pill{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef5fb;
  color: #43607b;
  font-size: 12px;
  font-weight: 700;
}
.setup-row-editor-modal{
  width: min(920px, 95vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.setup-row-editor__form{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  overflow: auto;
  max-height: 62vh;
  padding-right: 4px;
}
.setup-row-editor__field{
  display: grid;
  gap: 6px;
}
.setup-row-editor__field--full{
  grid-column: 1 / -1;
}
.setup-row-editor__field label{
  font-size: 13px;
  font-weight: 700;
  color: #48627d;
}
.setup-row-editor__field textarea{
  min-height: 92px;
  resize: vertical;
}
.setup-row-editor__field .label-sm{
  margin-top: -2px;
}
@media (max-width: 520px){
  .login-card{
    width: min(100%, 92vw);
    padding: 28px 20px 22px;
    border-radius: 22px;
  }
  .brand h2{
    font-size: 24px;
  }
  .brand-logo{
    width: 54px;
    height: 54px;
    padding: 10px;
    border-radius: 16px;
  }
  .setup-shell{
    padding: 16px;
  }
  .setup-header{
    flex-direction: column;
  }
  .setup-stats,
  .setup-grid{
    grid-template-columns: 1fr;
  }
  .setup-table-list__head,
  .setup-table-list__row{
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .setup-table-browser__header,
  .setup-table-browser__meta,
  .setup-table-browser__footer{
    flex-direction: column;
    align-items: stretch;
  }
  .setup-row-editor__form{
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Home (Kho lưu trữ) – Enterprise Depth Upgrade
   Scoped to body[data-page="index"] to avoid side effects.
========================================================= */
body[data-page="index"] .header{
  background: linear-gradient(180deg, #26364A 0%, #1E2A38 100%);
  box-shadow: 0 10px 24px rgba(16, 28, 40, 0.25);
  border-bottom: 1px solid rgba(10, 18, 28, 0.35);
}
body[data-page="index"] .header-title{
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}
body[data-page="index"] .sidebar{
  background: linear-gradient(180deg, #F9FBFD 0%, #EEF3F8 100%);
  box-shadow: inset -1px 0 0 var(--c-border), 0 10px 26px rgba(30, 42, 56, 0.12);
}
body[data-page="index"] .nav a{
  background: #FFFFFF;
  border-color: #D8E0EA;
}
body[data-page="index"] .nav a .ico{ color: #6B7A8B; }
body[data-page="index"] .nav a:hover{
  background: #F3F7FD;
  box-shadow: 0 8px 18px rgba(30, 42, 56, 0.12);
}
body[data-page="index"] .nav a.active,
body[data-page="index"] .nav a[aria-current="page"]{
  background: #E9F0FF;
  border-color: #9DB2FF;
  color: var(--c-primary);
  box-shadow: inset 3px 0 0 #2E5BFF, 0 8px 18px rgba(46, 91, 255, 0.16);
}
body[data-page="index"] .nav a.active .ico,
body[data-page="index"] .nav a[aria-current="page"] .ico{
  color: #2E5BFF;
}

body[data-page="index"] .main{
  background: linear-gradient(180deg, #F4F6F8 0%, #EFF3F7 100%);
}
body[data-page="index"] .section{
  border-color: #D7DEE7;
  box-shadow: 0 10px 22px rgba(30, 42, 56, 0.12);
}
body[data-page="index"] .section--records{
  position: relative;
}
body[data-page="index"] .section--records::before{
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2E5BFF 0%, rgba(46, 91, 255, 0.00) 60%);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}
body[data-page="index"] .title{
  font-weight: 700;
  letter-spacing: 0.2px;
}
body[data-page="index"] .filter-bar{
  background: #FFFFFF;
  border: 1px solid #D7DEE7;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 8px 18px rgba(30, 42, 56, 0.10);
}
body[data-page="index"] .records-toolbar{
  background: linear-gradient(180deg, #F9FBFE 0%, #F1F5FA 100%);
  border-bottom: 1px solid #D7DEE7;
  box-shadow: inset 0 -1px 0 rgba(30, 42, 56, 0.05);
}
body[data-page="index"] .table-wrap{
  border-color: #D7DEE7;
  box-shadow: 0 12px 24px rgba(30, 42, 56, 0.12);
}
body[data-page="index"] .table th{
  background: #F2F6FB;
  color: #233244;
  font-weight: 700;
}
body[data-page="index"] .table tr:nth-child(odd) td{ background: #FBFCFE; }
body[data-page="index"] .table tr:nth-child(even) td{ background: #F5F8FC; }
body[data-page="index"] .table tr:hover td{ background: #EEF4FF; }
body[data-page="index"] .label-sm{
  color: #6A7788;
}

body.runtime-electron[data-page="index"]{
  font-size: 13px;
}
body.runtime-electron[data-page="index"] .header{
  min-height: 50px;
}
body.runtime-electron[data-page="index"] .header-grid{
  padding: 6px 10px;
}
body.runtime-electron[data-page="index"] .header-title{
  font-size: 17px;
  letter-spacing: 0.2px;
}
body.runtime-electron[data-page="index"] .icon-btn{
  width: 34px;
  height: 34px;
}
body.runtime-electron[data-page="index"] .user-trigger{
  padding: 5px 10px;
  font-size: 13px;
}
body.runtime-electron[data-page="index"] .app{
  min-height: 0;
}
body.runtime-electron[data-page="index"] .sidebar{
  width: 222px;
  padding: 6px;
  gap: 6px;
}
body.runtime-electron[data-page="index"] .group-title{
  margin: 6px 0 2px;
  padding: 7px 10px;
  font-size: 11px;
}
body.runtime-electron[data-page="index"] .nav{
  gap: 6px;
}
body.runtime-electron[data-page="index"] .nav a{
  padding: 8px 10px;
  font-size: 13px;
  min-height: 42px;
}
body.runtime-electron[data-page="index"] .nav a .ico{
  width: 18px;
  height: 18px;
  margin-right: 6px;
}
body.runtime-electron[data-page="index"] .sidebar-status{
  margin-top: 8px;
  padding-top: 0;
}
body.runtime-electron[data-page="index"] .main{
  padding: 16px;
}
body.runtime-electron[data-page="index"] .status-footer{
  height: 40px;
  flex-basis: 40px;
  padding: 0 14px;
  gap: 10px;
  font-size: 12px;
}
body.runtime-electron[data-page="index"] .status-footer__center{
  font-size: 17px;
}
body.runtime-electron[data-page="index"] .status-footer__clock{
  padding: 4px 8px;
}
body.runtime-electron[data-page="index"] .section{
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 10px;
}
body.runtime-electron[data-page="index"] .title{
  margin-bottom: 10px;
  font-size: 16px;
}
body.runtime-electron[data-page="index"] .filter-bar{
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
body.runtime-electron[data-page="index"] .records-toolbar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 12px;
}
body.runtime-electron[data-page="index"] .records-toolbar .left,
body.runtime-electron[data-page="index"] .records-toolbar .right{
  display: contents;
}
body.runtime-electron[data-page="index"] .records-toolbar .btn{
  height: 34px;
  padding: 0 11px;
  font-size: 12px;
}
body.runtime-electron[data-page="index"] .records-toolbar .btn .ico{
  width: 16px;
  height: 16px;
  margin-right: 4px;
}
body.runtime-electron[data-page="index"] .btn{
  height: 36px;
  padding: 0 13px;
  font-size: 13px;
}
body.runtime-electron[data-page="index"] .btn.xs{
  height: 26px;
  padding: 0 9px;
  font-size: 11px;
}
body.runtime-electron[data-page="index"] .input,
body.runtime-electron[data-page="index"] .select{
  height: 36px;
}
body.runtime-electron[data-page="index"] .table th,
body.runtime-electron[data-page="index"] .table td{
  padding: 8px 10px;
  font-size: 13px;
}
body.runtime-electron[data-page="index"] .records-progress{
  padding: 6px 10px;
}

/* =========================================================
   Help Page (HDSD)
========================================================= */
body[data-page="help"] .main{
  background: linear-gradient(180deg, #F4F6F8 0%, #EFF3F7 100%);
}
.help-main{ gap: 16px; }
.help-hero{
  background: #FFFFFF;
  border: 1px solid #D7DEE7;
  box-shadow: 0 10px 22px rgba(30, 42, 56, 0.12);
}
.help-hero-title{
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.help-hero-sub{
  color: var(--c-text-muted);
  margin-bottom: 12px;
}
.help-search{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.help-search-input{
  flex: 1;
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: #FFFFFF;
}
.help-search-input .input{
  border: none;
  height: 32px;
  padding: 0;
}
.help-search-input .input:focus{
  box-shadow: none;
}
.help-search-count{
  font-size: 13px;
  color: var(--c-text-muted);
}
.help-layout{
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}
.help-toc{
  position: sticky;
  top: 72px;
  align-self: start;
  background: #FFFFFF;
  border: 1px solid #D7DEE7;
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--sh-1);
}
.help-toc-title{
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--c-primary);
}
.help-toc a{
  display: block;
  text-decoration: none;
  color: var(--c-secondary);
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.help-toc a:hover{
  background: #F2F6FB;
  border-color: #D7DEE7;
}
.help-content{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.help-section h2{
  margin-bottom: 8px;
}
.help-section h3{
  margin-top: 10px;
  margin-bottom: 6px;
}
.help-section ul{ margin: 8px 0 0 18px; }
.help-section ol{ margin: 8px 0 0 18px; }
.help-note,
.help-warn,
.help-example{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--c-border);
  background: #F9FBFF;
}
.help-warn{
  border-color: #F1C6C6;
  background: #FFF6F6;
  color: #7A1B1B;
}
.help-example{
  border-color: #CFE2FF;
  background: #F5F9FF;
  color: #243B6B;
}
@media (max-width: 980px){
  .help-layout{ grid-template-columns: 1fr; }
  .help-toc{ position: static; }
}

/* =========================================================
   Enterprise Refined (Optional)
   - Reduce accent saturation ~5%
   - Slightly flatter header
   - Softer shadows
   To enable: uncomment this block.
========================================================= */
/*
:root{
  --c-accent: #2A54F0;
  --ring: 0 0 0 3px rgba(42, 84, 240, 0.14);
  --sh-1: 0 4px 12px rgba(30, 42, 56, 0.08);
  --sh-2: 0 8px 20px rgba(30, 42, 56, 0.12);
  --sh-3: 0 16px 32px rgba(30, 42, 56, 0.16);
}
.header{
  background: #1E2A38;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.table th{
  background: #F1F4F7;
  font-weight: 600;
}
.btn{
  background: var(--c-accent);
  border-color: #2046CC;
  box-shadow: 0 4px 12px rgba(42, 84, 240, 0.16);
}
.btn:hover{
  background: #2449D9;
  box-shadow: 0 8px 16px rgba(42, 84, 240, 0.20);
}
*/

body[data-page="record-view"]{
  background:
    radial-gradient(circle at top left, rgba(52, 152, 219, 0.18), transparent 34%),
    linear-gradient(180deg, #F8FBFF 0%, #EEF4FA 100%);
  min-height: 100vh;
}
body[data-page="record-view"] .record-page{
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
body[data-page="record-view"] .record-page__header{
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
body[data-page="record-view"] .record-page__kicker{
  color: #2E5BFF;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
body[data-page="record-view"] .record-page__title{
  margin: 6px 0;
}
body[data-page="record-view"] .record-page__sub{
  color: var(--c-text-muted);
}
body[data-page="record-view"] .record-page__hero{
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  background:
    linear-gradient(135deg, rgba(46, 91, 255, 0.08), rgba(46, 91, 255, 0.02)),
    #FFFFFF;
}
body[data-page="record-view"] .record-page__hero-label{
  font-size: 12px;
  color: #6A7788;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
body[data-page="record-view"] .record-page__hero-code{
  font-size: 34px;
  font-weight: 800;
  color: #1D2B3A;
  margin: 4px 0 10px;
}
body[data-page="record-view"] .record-page__hero-title{
  font-size: 18px;
  line-height: 1.5;
  color: #233244;
  max-width: 680px;
}
body[data-page="record-view"] .record-page__hero-tags{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
body[data-page="record-view"] .record-page__tag{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #F3F7FC;
  border: 1px solid #D7DEE7;
  color: #314356;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}
body[data-page="record-view"] .record-detail-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
body[data-page="record-view"] .record-detail-item{
  border: 1px solid #D7DEE7;
  border-radius: 12px;
  background: #FFFFFF;
  padding: 12px 14px;
}
body[data-page="record-view"] .record-detail-item__label{
  font-size: 12px;
  font-weight: 700;
  color: #6A7788;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
body[data-page="record-view"] .record-detail-item__value{
  color: #233244;
  word-break: break-word;
  line-height: 1.55;
}
body[data-page="record-view"] .record-detail-item__empty{
  color: #97A4B5;
}
.record-qr-modal{
  width: min(720px, 94vw);
}
.record-qr-modal__body{
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  align-items: start;
}
.record-qr-modal__image{
  width: 100%;
  max-width: 240px;
  border: 1px solid #D7DEE7;
  border-radius: 12px;
  background: #FFFFFF;
  padding: 10px;
}
.record-qr-modal__link{
  min-height: 110px;
  resize: vertical;
}
.record-qr-modal__hint{
  color: var(--c-text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.record-edit-qr{
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 14px;
  margin: 10px 0 16px;
  padding: 12px;
  border: 1px solid #D7DEE7;
  border-radius: 12px;
  background: #F8FBFF;
}
.record-edit-qr__media{
  display: flex;
  align-items: center;
  justify-content: center;
}
.record-edit-qr__media img{
  width: 112px;
  height: 112px;
  object-fit: contain;
  background: #FFFFFF;
  border: 1px solid #D7DEE7;
  border-radius: 10px;
  padding: 8px;
}
.record-edit-qr__title{
  font-size: 15px;
  font-weight: 700;
  color: #233244;
  margin-bottom: 6px;
}
.record-edit-qr__sub{
  color: #6A7788;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}
.record-edit-qr__actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 720px){
  body[data-page="record-view"] .record-page__header{
    flex-direction: column;
  }
  body[data-page="record-view"] .record-page__hero{
    flex-direction: column;
  }
  body[data-page="record-view"] .record-page__hero-tags{
    justify-content: flex-start;
  }
  body[data-page="record-view"] .record-detail-grid{
    grid-template-columns: 1fr;
  }
  .record-qr-modal__body{
    grid-template-columns: 1fr;
  }
  .record-qr-modal__image{
    margin: 0 auto;
  }
  .record-edit-qr{
    grid-template-columns: 1fr;
  }
}

body[data-page="record-single"]{
  background:
    radial-gradient(circle at top left, rgba(52, 152, 219, 0.18), transparent 34%),
    linear-gradient(180deg, #F8FBFF 0%, #EEF4FA 100%);
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  -webkit-overflow-scrolling: touch;
}
body[data-page="record-single"] .record-page{
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}
body[data-page="record-single"] .record-page__header{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
body[data-page="record-single"] .record-page__kicker{
  color: #2E5BFF;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
body[data-page="record-single"] .record-page__title{
  margin: 4px 0 6px;
  font-size: clamp(30px, 8vw, 44px);
  line-height: 1.05;
}
body[data-page="record-single"] .record-page__sub{
  color: #516173;
  font-size: 18px;
}
body[data-page="record-single"] .record-page__hero{
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  background:
    linear-gradient(135deg, rgba(46, 91, 255, 0.08), rgba(46, 91, 255, 0.02)),
    #FFFFFF;
  border: 1px solid #D7DEE7;
}
body[data-page="record-single"] .record-page__hero-label{
  font-size: 12px;
  color: #6A7788;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
body[data-page="record-single"] .record-page__hero-code{
  font-size: clamp(34px, 10vw, 52px);
  font-weight: 800;
  line-height: 1;
  color: #1D2B3A;
  margin: 6px 0 8px;
}
body[data-page="record-single"] .record-page__hero-title{
  font-size: clamp(20px, 5.6vw, 28px);
  line-height: 1.45;
  color: #233244;
}
body[data-page="record-single"] .record-page__hero-tags{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
body[data-page="record-single"] .record-page__tag{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFFFF;
  border: 1px solid #CCD7E5;
  color: #223449;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.3;
}
body[data-page="record-single"] .record-page .section{
  border-radius: 16px;
}
body[data-page="record-single"] .record-detail-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
body[data-page="record-single"] .record-detail-item{
  border: 1px solid #D7DEE7;
  border-radius: 12px;
  background: #FFFFFF;
  padding: 12px;
}
body[data-page="record-single"] .record-detail-item__label{
  font-size: 12px;
  font-weight: 700;
  color: #6A7788;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
body[data-page="record-single"] .record-detail-item__value{
  color: #233244;
  word-break: break-word;
  line-height: 1.6;
  font-size: 22px;
}
body[data-page="record-single"] .record-detail-item__empty{
  color: #97A4B5;
}

@media (max-width: 720px){
  body[data-page="record-single"] .record-page{
    padding: 10px 0 22px;
  }
  body[data-page="record-single"] .record-page__header{
    padding: 0 10px;
  }
  body[data-page="record-single"] .record-page__content .section{
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  body[data-page="record-single"] .record-page__hero-tags{
    gap: 6px;
  }
  body[data-page="record-single"] .record-page__tag{
    width: 100%;
  }
  body[data-page="record-single"] .record-detail-item{
    padding: 10px;
  }
  body[data-page="record-single"] .record-detail-item__value{
    font-size: 19px;
    line-height: 1.55;
  }
}

/* =========================================================
   Mobile hardening (global)
   Keep this block near end to override legacy responsive rules.
========================================================= */
@media (max-width: 980px){
  body[data-page="index"]{
    overflow-y: auto;
  }
  body[data-page="index"] .header{
    min-height: 52px;
  }
  body[data-page="index"] .header-grid{
    padding: 6px 8px;
    gap: 6px;
  }
  body[data-page="index"] .header-title{
    font-size: 16px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
  }
  body[data-page="index"] .main{
    padding: 10px;
  }
  body[data-page="index"] .section{
    padding: 12px;
    border-radius: 12px;
  }
  body[data-page="index"] .section--records{
    overflow: visible;
  }
  body[data-page="index"] .filter-bar{
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  body[data-page="index"] .filter-bar > div{
    width: 100% !important;
    min-width: 0 !important;
    flex-wrap: wrap;
  }
  body[data-page="index"] .filter-bar .btn{
    flex: 1 1 140px;
  }
  body[data-page="index"] .records-toolbar{
    position: static;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
  }
  body[data-page="index"] .records-toolbar .left,
  body[data-page="index"] .records-toolbar .right{
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  body[data-page="index"] .records-toolbar .btn{
    flex: 1 1 220px;
  }
  body[data-page="index"] .records-toolbar .role-admin-only{
    display: none !important;
  }
  body[data-page="index"] .records-pager{
    position: static;
    padding: 10px;
    gap: 8px;
  }
  body[data-page="index"] .records-pager > *{
    min-width: 0;
  }
  body[data-page="index"] .table-wrap{
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  body[data-page="index"] #Data-kho{
    min-width: 980px;
  }
  body[data-page="index"] .records-progress{
    position: static;
  }
  body[data-page="index"] .status-footer{
    display: none !important;
  }

  .modal-overlay{
    align-items: flex-start;
    padding: 10px;
    overflow-y: auto;
  }
  .modal{
    width: 100% !important;
    max-height: none;
    min-height: 0;
    padding: 14px;
    border-radius: 12px;
    margin: 0;
  }
  .dialog{
    width: 100%;
    border-radius: 12px;
  }
  .form-compact{
    grid-template-columns: 1fr !important;
  }
  .account-admin-head{
    flex-direction: column;
    align-items: flex-start;
  }
  .account-admin-form{
    grid-template-columns: 1fr !important;
  }
  .account-admin-table{
    min-width: 980px;
  }
  .account-perm-grid{
    flex-wrap: wrap;
  }
  .mt-grid{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .mt-row{
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .mt-row .grow{
    width: 100%;
  }
  .mt-actions{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
  }
  .mt-pane-toolbar{
    padding: 12px;
    align-items: stretch;
  }
  .mt-pane-toolbar > div{
    width: 100%;
    min-width: 0;
  }
  .mt-pane-toolbar .mt-search{
    width: 100%;
    margin-left: 0;
  }
  .mt-pane-toolbar .mt-search .input{
    min-width: 0;
    width: 100%;
  }
  .loan-workflow-grid{
    grid-template-columns: 1fr;
  }
  .loan-workflow-main{
    min-height: auto;
    padding: 14px;
  }
  .loan-workflow-main .loan-workflow-tabs{
    justify-content: flex-start;
  }
  .loan-mhs-picker{
    flex-wrap: wrap;
  }
  .loan-mhs-suggest{
    right: 0;
  }
  .inventory-grid{
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .inventory-summary-grid{
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
  #lw-detail-meta,
  .loan-detail-meta{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #lw-detail-meta > span:nth-child(4),
  .loan-detail-meta > span:nth-child(4){
    grid-column: span 2;
  }
  #recordsUserOverlay .mt-search .input,
  #activeLoansOverlay .mt-search .input,
  #traceOverlay .mt-search .input{
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 640px){
  #lw-detail-meta,
  .loan-detail-meta{
    grid-template-columns: 1fr;
  }
  #lw-detail-meta > span:nth-child(4),
  .loan-detail-meta > span:nth-child(4){
    grid-column: span 1;
  }
}

@media (max-width: 720px){
  body[data-page="index"] .header-title{
    font-size: 15px;
  }
  body[data-page="index"] .user-trigger{
    max-width: 155px;
    padding: 5px 9px;
    font-size: 13px;
  }
  body[data-page="index"] .user-trigger > span:first-child{
    max-width: 106px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body[data-page="index"] .records-toolbar .btn{
    flex: 1 1 100%;
  }
  body[data-page="index"] .records-pager .pager-buttons{
    width: 100%;
  }
}

/* ===== Box Info Page ===== */
body[data-page="box-info"]{
  overflow-y: auto;
  background: linear-gradient(180deg, #f4f7fb, #edf3fa);
}
body[data-page="setup"]{
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  min-height: 100vh;
}
body[data-page="box-info"] .box-wrap{
  max-width: 1120px;
  margin: 16px auto 28px;
  padding: 0 12px;
}
body[data-page="box-info"] .box-title{
  margin-bottom: 8px;
  font-size: 24px;
}
body[data-page="box-info"] .box-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}
body[data-page="box-info"] .box-item{
  border: 1px solid #d7e0eb;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 12px 14px;
  box-shadow: 0 8px 18px rgba(30, 42, 56, 0.08);
}
body[data-page="box-info"] .box-item .k{
  font-size: 12px;
  color: #5a6a7b;
  margin-bottom: 4px;
}
body[data-page="box-info"] .box-item .v{
  font-weight: 800;
  font-size: 18px;
  color: #1c2f45;
  word-break: break-word;
}
body[data-page="box-info"] .box-actions{
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
body[data-page="box-info"] #boxStatus{
  display: inline-block;
  padding: 6px 10px;
  background: #eef4ff;
  border: 1px solid #ccd9f3;
  border-radius: 999px;
  color: #2b4a78;
  font-weight: 600;
}
body[data-page="box-info"] .table-wrap{
  margin-top: 12px;
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
body[data-page="box-info"] .box-record-cards{
  display: none;
  gap: 10px;
}
body[data-page="box-info"] .box-record-card{
  border: 1px solid #d7e0eb;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
  box-shadow: 0 8px 18px rgba(30, 42, 56, 0.07);
}
body[data-page="box-info"] .box-record-card .line{
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 6px;
}
body[data-page="box-info"] .box-record-card .line-full{
  grid-template-columns: 1fr;
}
body[data-page="box-info"] .box-record-card .k{
  color: #5a6a7b;
  font-size: 12px;
  font-weight: 700;
}
body[data-page="box-info"] .box-record-card .v{
  color: #1c2f45;
  font-weight: 600;
  word-break: break-word;
}
body[data-page="box-info"] #boxRecords{
  min-width: 900px;
}
body[data-page="box-info"] #boxRecords th{
  white-space: nowrap;
}
body[data-page="box-info"] #boxRecords td{
  vertical-align: top;
}
@media (max-width: 980px){
  body[data-page="box-info"] .box-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px){
  body[data-page="box-info"] .box-grid{
    grid-template-columns: 1fr;
  }
  body[data-page="box-info"] .box-title{
    font-size: 20px;
  }
  body[data-page="box-info"] .table-wrap{
    display: none;
  }
  body[data-page="box-info"] .box-record-cards{
    display: grid;
  }
}

/* ===== Logs overlay table ===== */
#logs-table{
  width: 100%;
  table-layout: fixed;
  min-width: 1320px;
}
#logs-table th,
#logs-table td{
  vertical-align: top;
}
#logs-table th:nth-child(1),
#logs-table td:nth-child(1){
  width: 150px;
}
#logs-table th:nth-child(2),
#logs-table td:nth-child(2){
  width: 90px;
}
#logs-table th:nth-child(3),
#logs-table td:nth-child(3){
  width: 80px;
}
#logs-table th:nth-child(4),
#logs-table td:nth-child(4){
  width: 120px;
}
#logs-table th:nth-child(5),
#logs-table td:nth-child(5){
  width: 130px;
}
#logs-table th:nth-child(6),
#logs-table td:nth-child(6){
  width: 170px;
}
#logs-table th:nth-child(7),
#logs-table td:nth-child(7){
  width: 100px;
}
#logs-table th:nth-child(8),
#logs-table td:nth-child(8){
  width: 70px;
}
#logs-table .logs-detail-cell{
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
#logs-table .logs-detail-pre{
  margin: 0;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font: 12px/1.45 Consolas, "Courier New", monospace;
}
