/* Reset */
* { box-sizing: border-box; }
:root { --app-font-size: 12px; --filters-offset: 96px; --header-row-height: 32px; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; font-size: var(--app-font-size, 12px); }
html, body { overflow-x: hidden; }

/* Guest (Login) */
.login-bg { min-height: 100vh; background: url('/assets/images/login_background.jpg') center/cover no-repeat, #f3f4f6; display: flex; align-items: center; justify-content: center; }
.login-card { width: 420px; background: rgba(255,255,255,0.92); backdrop-filter: blur(8px); border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,.1); padding: 28px; }
.login-logo { display:block; width: 160px; height:auto; margin: 0 auto 12px; }
.login-title { text-align: center; color: #9b1c1c; margin: 8px 0 18px; font-weight: 700; letter-spacing: .5px; }
.login-header { height: 72px; background: #fff; display:flex; align-items:center; justify-content:center; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.login-header-logo { height: 44px; width:auto; }
.login-bg { position: relative; }
.login-curve { position:absolute; left:0; top:0; bottom:0; width:min(2.6vw, 26px); background: linear-gradient(180deg, #b91c1c 0%, #8f1515 100%); clip-path: ellipse(220% 180% at -80% 100%); z-index:1; }
.login-card { position: relative; z-index: 2; }
@media (max-width: 768px) {
  .login-curve { width: min(3vw, 18px); clip-path: ellipse(250% 210% at -90% 100%); }
  .login-card { width: 90%; }
}
.login-form .form-group { margin-bottom: 14px; }
.login-form label { display: block; color: #374151; font-size: 14px; margin-bottom: 6px; }
.login-form input { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.form-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.forgot-link { font-size: var(--app-font-size, 12px); color: #6b7280; text-decoration: none; }
.btn-primary { background: #b91c1c; color: #fff; border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; }
.btn-primary:hover { background: #991b1b; }

/* Dashboard */
.dashboard-bg { background: #e5e7eb; }
.app-header { background:#fff; border-bottom:1px solid #e5e7eb; box-shadow:0 2px 8px rgba(0,0,0,.06); position:sticky; top:0; z-index:10; }
.app-header-inner { width:100%; max-width:none; margin:0; padding:0 4px; height:64px; display:flex; align-items:center; justify-content:space-between; }
.app-left { display:flex; align-items:center; gap:6px; }
.app-logo { height:44px; width:auto; display:block; }
.app-link { color:#1f2937; text-decoration:none; font-weight:600; }
.app-link.is-active { color:#b91c1c; }
.app-right { display:flex; align-items:center; gap:12px; }
.font-size-control { display:flex; align-items:center; gap:6px; }
.font-size-label { color:#6b7280; font-weight:600; font-size: var(--app-font-size, 12px); }
.font-size-select { border:1px solid #d1d5db; border-radius:8px; height:32px; padding:4px 8px; font-size: var(--app-font-size, 12px); background:#fff; }
.app-user-name { color:#374151; }
.app-logout { background:#b91c1c; color:#fff; border:0; border-radius:999px; padding:8px 14px; cursor:pointer; }
.app-logout:hover { background:#991b1b; }
.dashboard-wrapper { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 64px); }
.sidebar { background: #b91c1c; color: #fff; padding: 14px 12px; position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; font-size: var(--app-font-size, 12px); }
.brand { font-weight: 700; margin-bottom: 8px; font-size: 12px; letter-spacing: .2px; }
.tree { display:flex; flex-direction:column; gap:6px; }
.tree .tree-item { display:block; color:#fff; text-decoration:none; padding:6px 8px; border-radius:8px; font-size: var(--app-font-size, 12px); }
.tree .tree-item:hover { background: rgba(255,255,255,.15); }
.tree details { border-radius:8px; }
.tree summary { cursor:pointer; padding:6px 8px; border-radius:8px; background: rgba(255,255,255,.12); font-weight:600; font-size: var(--app-font-size, 12px); }
.tree summary:hover { background: rgba(255,255,255,.2); }
.tree summary::-webkit-details-marker { display:none; }
.tree details > div { margin-top:4px; padding-left:8px; display:flex; flex-direction:column; gap:3px; }
.tree .active { background: rgba(255,255,255,.25); font-weight:700; }
.content { padding: 18px; }
.page-titlebar { margin-bottom: 8px; }
.page-title { font-weight: 700; color: #1f2937; }

.orders-frame { width:100%; overflow: visible; }
.orders-frame .submitted-filters { width: 100%; min-width: unset; }
.orders-frame .submitted-wrapper { width: max-content; min-width: 100%; }
.orders-frame .submitted-table { width: max-content; min-width: 100%; }
/* Enable horizontal scroll inside page content area */
.content { overflow-x: hidden; max-width: calc(100vw - 240px); }
/* Scroll container at panel-box */
.panel-box.scrollable { height: calc(100vh - 64px); width: 100%; overflow-x: hidden; overflow-y: auto; }
.orders-scroll { width: 100%; overflow-x: auto; overflow-y: auto; }
.table-top-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; height: 8px; }
.table-top-scroll-inner { height: 1px; }

.coming-container { display: flex; align-items: flex-start; justify-content: center; padding: 12px 24px; margin-top: 0; }
.coming-card { background: #fff; border-radius: 16px; box-shadow: 0 6px 18px rgba(0,0,0,.08); padding: 24px; max-width: 720px; width: 100%; text-align: center; margin: 0 auto; }
.coming-icon { width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #fff3cd; color: #b45309; margin: 0 auto 12px; border: 1px solid #fde68a; }
.coming-title { font-weight: 700; color: #1f2937; font-size: 16px; margin-bottom: 6px; }
.coming-text { color: #6b7280; font-size: var(--app-font-size, 12px); margin-bottom: 12px; }
.coming-actions { display: flex; align-items: center; justify-content: center; gap: 8px; }
.coming-page .page-titlebar { display:flex; justify-content:center; margin-bottom: 6px; }
.coming-page .page-title { text-align:center; }
.filters { display:flex; align-items:center; justify-content:center; gap:28px; margin: 8px 0 18px; padding:12px 8px; background: linear-gradient(180deg, rgba(0,0,0,0.02), rgba(0,0,0,0)); border-radius:12px; }
.date-field { display:flex; flex-direction:column; gap:6px; }
.date-label { font-size:12px; font-weight:700; color:#6b7280; letter-spacing:.5px; text-transform:uppercase; }
.date-input { display:flex; align-items:center; gap:10px; }
.date-input input[type="date"] { height:40px; padding:0 12px; border:1px solid #e5e7eb; border-radius:10px; box-shadow:0 2px 6px rgba(0,0,0,.06); background:#fff; color:#1f2937; }
.date-input input[type="date"]::-webkit-calendar-picker-indicator { opacity:0; }
.date-icon { width:36px; height:36px; border:1px solid #ef4444; color:#ef4444; background:#fff; border-radius:10px; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; box-shadow:0 2px 6px rgba(0,0,0,.06); }
.date-icon:hover { background:#fff5f5; border-color:#dc2626; color:#dc2626; }
.date-arrow { color:#6b7280; font-weight:700; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card { background: #fff; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.06); padding: 16px; }
.card-title { color: #6b7280; font-size: var(--app-font-size, 12px); }
.card-value { font-size: 20px; font-weight: 700; color: #1f2937; }
.card-sub { color: #6b7280; font-size: var(--app-font-size, 12px); }
.card-total .total-bar { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.card-total .total-title { color:#ef4444; font-weight:700; letter-spacing:.4px; }
.card-total .total-toggle { border:1px solid #e5e7eb; background:#fff; color:#6b7280; border-radius:8px; padding:4px 8px; line-height:1; cursor:pointer; }
.card-total .total-value { font-size:22px; font-weight:800; }
.card-total .total-link { color:#2563eb; text-decoration:none; }
.card-total .total-link:hover { text-decoration:underline; }
.card-total .total-breakdown .row { display:flex; justify-content:space-between; padding:6px 0; border-top:1px solid #f1f5f9; color:#374151; }
.card-list .stat-row { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid #e5e7eb; color:#1f2937; }
.table-section { background:#fff; margin-top:18px; border-radius:12px; box-shadow:0 4px 12px rgba(0,0,0,.06); padding:16px; }
.table-title { font-weight:600; margin-bottom:8px; }
.tax-table { width:100%; border-collapse: collapse; }
.tax-table th, .tax-table td { border:1px solid #e5e7eb; padding:8px; text-align:left; font-size: var(--app-font-size, 12px); }
.charts { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.chart-box { background:#fff; border-radius:12px; box-shadow:0 4px 12px rgba(0,0,0,.06); padding:12px; }
.chart-box canvas { height: 320px !important; }

/* HKD Info */
.hkd-info { display:flex; flex-direction:column; gap:14px; }
.hkd-titlebar { border:1px solid #f59e0b; background:#fffaf0; padding:10px 12px; border-radius:8px; }
.hkd-title { font-weight:700; color:#b45309; letter-spacing:.2px; }
.panel { border:1px solid #e5e7eb; border-radius:10px; overflow:hidden; padding:10px; }
.panel-header { display:flex; align-items:center; justify-content:space-between; padding:6px 8px 10px; border-bottom:1px solid #e5e7eb; }
.panel-title { font-weight:700; color:#374151; letter-spacing:.2px; }
.panel-green { background:#f0fdf4; border-color:#bbf7d0; }
.panel-blue { background:#f0f7ff; border-color:#bfdbfe; }
.hkd-table { width:100%; border-collapse:collapse; background:#fff; }
.hkd-table th, .hkd-table td { padding:10px 12px; border-bottom:1px solid #e5e7eb; vertical-align:top; font-size: var(--app-font-size, 12px); color:#1f2937; }
.hkd-table th { width:280px; font-weight:600; color:#374151; }
.hkd-table tbody tr:nth-child(odd) { background:#fafcff; }
.hkd-table thead th { background:#f9fafb; font-weight:700; color:#1f2937; }
.hkd-select { appearance:none; padding:6px 10px; border:1px solid #d1d5db; border-radius:8px; background:#fff; font-size: var(--app-font-size, 12px); height:32px; }
.hkd-select:focus { border-color:#2563eb; box-shadow:0 0 0 2px rgba(37,99,235,.15); outline:0; }

.account-group-rows { display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.account-col { display:flex; flex-direction:column; gap:6px; }
.account-col label { font-weight:600; color:#374151; }
.account-col .hkd-select { width:100%; }
.account-group, .object-group, .md-group, .doc-group { background:#eef2ff; border:1px solid #c7d2fe; border-radius:12px; padding:12px; }
.account-group > label, .object-group > label, .md-group > label, .doc-group > label { display:block; font-weight:700; color:#0f172a; margin-bottom:8px; }
@media (max-width: 768px) {
  .account-group-rows { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .hkd-table th { width: 180px; }
}
.entry-flow { background:#fff; border-radius:12px; box-shadow:0 4px 12px rgba(0,0,0,.06); padding:12px; margin-bottom:12px; }
.flow-row { display:grid; grid-template-columns: repeat(3, 1fr); gap:12px; }
.flow-col label { display:block; font-size: var(--app-font-size, 12px); color:#6b7280; margin-bottom:6px; }
.entry-form .grid-2 { display:grid; grid-template-columns: repeat(2, 1fr); gap:12px; }
.entry-form .grid-3 { display:grid; grid-template-columns: repeat(3, 1fr); gap:10px; }
.entry-form .span-2 { grid-column: 1 / -1; }
.entry-form .form-group { display:flex; flex-direction:column; gap:6px; }
.entry-form .form-group:focus-within { background:#fff; box-shadow:0 0 0 2px rgba(37,99,235,.12), 0 4px 10px rgba(0,0,0,.06); border-radius:8px; padding:6px; }
.entry-form .form-group input, .entry-form .form-group select { padding:6px 10px; border:1px solid #d1d5db; border-radius:6px; font-size: var(--app-font-size, 12px); height:32px; background:#fff; }
.entry-form .form-group input:focus, .entry-form .form-group select:focus { border-color:#2563eb; box-shadow:0 0 0 2px rgba(37,99,235,.15); outline:0; }
.entry-form .form-group.required label::after { content:' *'; color:#ef4444; }
.entry-form .form-group.blue label { color:#2563eb; font-weight:600; }
/* Keep Save button always visible within input panel */
.entry-form { padding-bottom: 16px; }
.entry-form .form-actions { position: sticky; bottom: 0; background:transparent; padding:6px 8px; border-top:0; box-shadow:none; z-index: 5; width:100%; display:flex; justify-content:flex-end; align-items:center; }
.switch { position:relative; display:inline-block; width:42px; height:24px; }
.switch input { opacity:0; width:0; height:0; }
.slider { position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0; background:#e5e7eb; transition:.2s; border-radius:999px; }
.slider:before { position:absolute; content:""; height:18px; width:18px; left:3px; bottom:3px; background:white; transition:.2s; border-radius:50%; }
.switch input:checked + .slider { background:#34d399; }
.switch input:checked + .slider:before { transform: translateX(18px); }
.serial-row { display:flex; gap:8px; align-items:center; }
.serial-row input[type="text"] { flex: 1; }
.dup { border-color:#ef4444 !important; }
.notice-success { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; border-radius:8px; padding:10px 12px; margin-bottom:12px; }
/* Entry panels */
.entry-panels { display:block; gap:0; }
.panel-box { background:#fff; border-radius:12px; box-shadow:0 4px 12px rgba(0,0,0,.06); padding:12px; }
.panel-scroll { height:auto; overflow:visible; }
.entry-panels > .panel-box.panel-scroll:nth-child(2) { height:auto; }
.submitted-filters { display:grid; grid-template-columns: repeat(4, 1fr) auto; gap:12px; align-items:end; margin-bottom:10px; position:sticky; top:0; background:#fff; padding:12px; border-radius:12px; box-shadow:0 4px 12px rgba(0,0,0,.06); z-index:10; width:100%; box-sizing:border-box; }
.filter-actions { display:flex; align-items:center; justify-content:flex-end; position:relative; }
.column-config { display:none; position:absolute; right:0; top:calc(100% + 6px); background:#fff; border:1px solid #e5e7eb; border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.18); padding:10px; width:280px; max-height:60vh; overflow:auto; z-index:100; }
.column-config.open { display:block; }
.column-config label { display:flex; align-items:center; gap:8px; font-size: var(--app-font-size, 12px); color:#374151; padding:4px 0; }
.filter-item { display:flex; flex-direction:column; gap:6px; }
.filter-item.flex-1 { flex:1; }
.submitted-wrapper { overflow: visible; }
.column-config { /* popup style overridden above */ }
.submitted-table { width: max-content; min-width: 100%; border-collapse: collapse; }
.submitted-table th, .submitted-table td { border:1px solid #e5e7eb; padding:8px; font-size: var(--app-font-size, 12px); color:#1f2937; }
.submitted-table thead th { position: sticky; top: 0; background: #f9fafb; z-index:12; }
.submitted-table thead .header-filters th { background:#fff; position:sticky; top: var(--header-row-height); z-index:12; }
.table-filter-input { width:100%; padding:6px 8px; border:1px solid #d1d5db; border-radius:6px; font-size: var(--app-font-size, 12px); height:30px; background:#fff; }
/* Top filters input style */
.submitted-filters input[type="date"], .submitted-filters input[type="text"], .submitted-filters select {
  width:100%; padding:8px 10px; border:1px solid #d1d5db; border-radius:8px; height:36px; font-size: var(--app-font-size, 12px); box-shadow:0 2px 6px rgba(0,0,0,.05);
}
.submitted-filters label { font-size: var(--app-font-size, 12px); color:#6b7280; font-weight:600; margin-bottom:6px; display:block; }
/* Modal overlay for column selection */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.35); display:none; align-items:center; justify-content:center; z-index:100; }
.modal-overlay.open { display:flex; }
.modal { background:#fff; border-radius:12px; box-shadow:0 12px 32px rgba(0,0,0,.18); width:min(720px, 90vw); max-height:80vh; display:flex; flex-direction:column; }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid #e5e7eb; }
.modal-title { font-weight:700; color:#1f2937; }
.modal-close { background:transparent; border:0; font-size:22px; cursor:pointer; }
.modal-content { padding:12px 16px; display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.modal-content label { display:flex; align-items:center; gap:8px; font-size:14px; color:#374151; }
.modal-actions { padding:12px 16px; border-top:1px solid #e5e7eb; display:flex; justify-content:flex-end; }
