/* ==========================================================================
   Voyager ERP — App Shell & Page Layout (Desktop Application Style)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Login — centered dialog, like a native app sign-in window
   -------------------------------------------------------------------------- */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--color-bg-canvas);
}
.login-brand-pane { display: none; }
.login-form-pane { display: flex; align-items: center; justify-content: center; padding: 1rem; width: 100%; }
.login-card {
  width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-card-header {
  background: var(--color-primary); color: #fff; padding: 0.9rem 1.2rem;
  font-family: var(--font-display); font-weight: 700; font-size: 0.95rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.login-card-body { padding: 1.2rem 1.2rem 1.4rem; }

/* --------------------------------------------------------------------------
   Top bar — menu-bar style, dense
   -------------------------------------------------------------------------- */
.app-topnav {
  height: var(--topnav-height); background: var(--color-white); border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 0.6rem; padding: 0 0.6rem; position: sticky; top: 0; z-index: 50;
}
.app-logo {
  display: flex; align-items: center; gap: 0.4rem; font-family: var(--font-display);
  font-weight: 700; font-size: 0.88rem; color: var(--color-text-dark); white-space: nowrap;
}
.app-logo .mark {
  width: 22px; height: 22px; border-radius: 3px; background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle-btn {
  border: 1px solid transparent; background: transparent; width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: var(--color-text-muted);
}
.sidebar-toggle-btn:hover { background: var(--color-bg-tint); border-color: var(--color-border); }

.company-selector { min-width: 190px; max-width: 220px; height: 28px; padding: 0.2rem 0.5rem; font-size: 0.78rem; }

.global-search { flex: 1; max-width: 300px; position: relative; }
.global-search input {
  width: 100%; padding: 0.32rem 0.6rem 0.32rem 1.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-bg-canvas); font-size: 0.78rem;
}
.global-search input:focus { outline: none; border-color: var(--color-primary); background: #fff; }
.global-search .icon { position: absolute; left: 0.5rem; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }

.topnav-actions { display: flex; align-items: center; gap: 0.3rem; margin-left: auto; }
.icon-btn {
  width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); position: relative;
}
.icon-btn:hover { background: var(--color-bg-tint); border-color: var(--color-border); }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--color-secondary); border: 1px solid #fff; }
.user-chip {
  display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.5rem 0.15rem 0.15rem;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 0.78rem;
}
.user-chip:hover { border-color: var(--color-border); background: var(--color-bg-tint); }
.user-avatar {
  width: 22px; height: 22px; border-radius: 3px; background: var(--color-bg-tint); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.65rem;
}

.app-body { display: flex; min-height: calc(100vh - var(--topnav-height) - var(--menubar-height)); }

/* --------------------------------------------------------------------------
   Sidebar — tree-style navigation, Explorer-like
   -------------------------------------------------------------------------- */
.app-sidebar {
  width: var(--sidebar-width); background: var(--color-white); border-right: 1px solid var(--color-border);
  padding: 0.5rem 0.4rem; flex-shrink: 0; transition: width 0.15s ease; overflow-x: hidden; overflow-y: auto;
}
.app-sidebar.collapsed { width: var(--sidebar-width-collapsed); }

.nav-section-label {
  font-size: 0.63rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--color-text-muted); padding: 0.55rem 0.4rem 0.2rem; white-space: nowrap;
}
.app-sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0.15rem 0; overflow: hidden; }

.nav-item {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.45rem; border-radius: var(--radius-sm);
  color: var(--color-text-dark); font-size: 0.8rem; font-weight: 400; white-space: nowrap; margin-bottom: 1px; position: relative;
}
.nav-item .nav-icon { flex-shrink: 0; width: 16px; display: flex; justify-content: center; color: var(--color-text-muted); }
.nav-item svg { width: 14px; height: 14px; }
.nav-item:hover { background: var(--color-bg-tint); }
.nav-item.active { background: var(--color-primary); color: #fff; font-weight: 600; }
.nav-item.active .nav-icon { color: #fff; }
.nav-item .nav-label-text { overflow: hidden; text-overflow: ellipsis; }
.app-sidebar.collapsed .nav-label-text, .app-sidebar.collapsed .nav-badge { display: none; }
.nav-badge {
  margin-left: auto; font-size: 0.58rem; font-weight: 700; color: var(--color-text-muted);
  background: var(--color-bg-canvas); border: 1px solid var(--color-border); padding: 0.05rem 0.3rem; border-radius: 2px;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.2); border-color: transparent; color: #fff; }

.app-main { flex: 1; padding: 0.9rem 1.1rem 1.6rem; min-width: 0; }

/* --------------------------------------------------------------------------
   Pulldown menu bar — classic Windows-app style (File/Edit/View...)
   -------------------------------------------------------------------------- */
.app-menubar {
  display: flex; align-items: stretch; background: var(--color-white);
  border-bottom: 1px solid var(--color-border); height: 27px; padding: 0 0.3rem;
  position: sticky; top: var(--topnav-height); z-index: 45; font-size: 0.76rem;
}
.menubar-item { position: relative; display: flex; }
.menubar-label {
  display: flex; align-items: center; height: 100%; padding: 0 0.65rem;
  cursor: pointer; color: var(--color-text-dark); border: 1px solid transparent; user-select: none;
}
.menubar-label:hover { background: var(--color-bg-tint); border-color: var(--color-border); }
.menubar-item.open .menubar-label { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.menubar-dropdown {
  display: none; position: absolute; top: 100%; left: 0; min-width: 210px;
  background: #fff; border: 1px solid var(--color-border); box-shadow: var(--shadow-lg); z-index: 100; padding: 0.2rem 0;
}
.menubar-item.open .menubar-dropdown { display: block; }
.menubar-dropdown a {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.32rem 0.7rem;
  font-size: 0.78rem; color: var(--color-text-dark); white-space: nowrap;
}
.menubar-dropdown a .nav-icon { width: 14px; display: flex; color: var(--color-text-muted); flex-shrink: 0; }
.menubar-dropdown a:hover { background: var(--color-primary); color: #fff; text-decoration: none; }
.menubar-dropdown a:hover .nav-icon { color: #fff; }
.menubar-dropdown a.active { font-weight: 700; color: var(--color-primary); background: var(--color-bg-tint); }
.menubar-dropdown a.active:hover { color: #fff; background: var(--color-primary); }
.menubar-dropdown .menubar-badge {
  margin-left: auto; font-size: 0.6rem; font-weight: 700; color: var(--color-text-muted);
  background: var(--color-bg-canvas); border: 1px solid var(--color-border); padding: 0.03rem 0.28rem; border-radius: 2px;
}
.menubar-dropdown a:hover .menubar-badge { background: rgba(255,255,255,0.25); border-color: transparent; color: #fff; }

/* --------------------------------------------------------------------------
   Dashboard hero — plain stat boxes with a thin accent bar (no ticket-stub look)
   -------------------------------------------------------------------------- */
.hero-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin-bottom: 1rem; }
@media (max-width: 992px) { .hero-row { grid-template-columns: 1fr; } }

.boarding-pass {
  position: relative; display: flex; background: #fff; border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); overflow: hidden; border: 1px solid var(--color-border); border-left: 3px solid var(--color-primary);
}
.boarding-pass .bp-main { flex: 1; padding: 0.7rem 0.9rem; }
.boarding-pass .bp-stub { display: none; }
.boarding-pass .bp-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--color-text-muted); margin-bottom: 0.25rem; display: flex; align-items: center; gap: 0.3rem;
}
.boarding-pass .bp-value { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--color-text-dark); margin-bottom: 0.15rem; }
.boarding-pass .bp-delta { font-size: 0.7rem; font-weight: 600; }
.boarding-pass .bp-delta.up { color: var(--color-success); }
.boarding-pass .bp-delta.down { color: var(--color-danger); }

/* --------------------------------------------------------------------------
   Metric tiles
   -------------------------------------------------------------------------- */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 0.6rem; }
.metric-tile { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; }
.metric-tile .m-label { font-size: 0.68rem; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 0.3rem; display: flex; align-items: center; gap: 0.3rem; }
.metric-tile .m-value { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--color-text-dark); }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 1.1rem 0 0.5rem; }
.section-heading h2 { font-size: 0.88rem; font-weight: 700; }
.section-heading .hint { font-size: 0.72rem; color: var(--color-text-muted); }

.chart-card { padding: 0.75rem 0.9rem 0.5rem; height: 100%; }
.chart-card canvas { max-height: 240px; }

/* --------------------------------------------------------------------------
   Grids / tables — dense, alternating rows, sortable-header look
   -------------------------------------------------------------------------- */
.table-card { padding: 0; overflow: hidden; }
.table-card table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.table-card thead th {
  text-align: left; padding: 0.4rem 0.7rem; background: #EEF1F6; color: var(--color-text-dark); font-weight: 700;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.02em; border-bottom: 1px solid var(--color-border); border-top: 1px solid var(--color-border);
}
.table-card tbody td { padding: 0.36rem 0.7rem; border-bottom: 1px solid #EEF1F5; }
.table-card tbody tr:nth-child(even) { background: #FAFBFD; }
.table-card tbody tr:hover { background: var(--color-bg-tint); }

.skeleton {
  background: linear-gradient(90deg, var(--color-bg-tint) 25%, #fff 37%, var(--color-bg-tint) 63%);
  background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: 2px;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.coming-soon-badge {
  font-size: 0.58rem; font-weight: 700; text-transform: uppercase; background: var(--color-bg-tint);
  color: var(--color-secondary); padding: 0.05rem 0.3rem; border-radius: 2px; margin-left: 0.3rem;
}

/* --------------------------------------------------------------------------
   Entry forms
   -------------------------------------------------------------------------- */
.entry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.65rem 0.9rem; }
.entry-grid .span-2 { grid-column: span 2; }
@media (max-width: 700px) { .entry-grid .span-2 { grid-column: span 1; } }
.entry-section-title {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--color-text-muted); margin: 1rem 0 0.55rem; padding-top: 0.85rem; border-top: 1px solid var(--color-border);
}
.entry-section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.computed-field {
  background: var(--color-bg-canvas); border: 1px dashed var(--color-border); border-radius: var(--radius-sm);
  padding: 0.36rem 0.55rem; font-weight: 700; font-family: var(--font-display); color: var(--color-primary); font-size: 0.85rem;
}
.entry-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--color-border); }
.voucher-lines-editor table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.voucher-lines-editor th { text-align: left; padding: 0.3rem 0.45rem; font-size: 0.65rem; text-transform: uppercase; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); }
.voucher-lines-editor td { padding: 0.25rem 0.45rem; vertical-align: middle; }
.voucher-lines-editor input, .voucher-lines-editor select { padding: 0.32rem 0.5rem; font-size: 0.8rem; }
.balance-indicator { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 700; padding: 0.22rem 0.55rem; border-radius: 2px; font-size: 0.74rem; }
.toast-success {
  position: fixed; top: 0.8rem; right: 0.8rem; z-index: 999; background: var(--color-success); color: #fff;
  padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-weight: 600; font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   Drill-down modal — report line -> underlying vouchers -> voucher lines
   -------------------------------------------------------------------------- */
.dd-overlay {
  display: none; position: fixed; inset: 0; background: rgba(20, 28, 45, 0.35); z-index: 500;
  align-items: center; justify-content: center;
}
.dd-overlay.open { display: flex; }
.dd-panel {
  width: min(760px, 92vw); max-height: 82vh; background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
.dd-header {
  background: var(--color-primary); color: #fff; padding: 0.55rem 0.8rem; display: flex;
  align-items: center; justify-content: space-between; flex-shrink: 0;
}
.dd-title { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; }
.dd-subtitle { font-size: 0.7rem; opacity: 0.85; margin-top: 0.1rem; }
.dd-close { background: transparent; border: none; color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0.2rem 0.4rem; }
.dd-close:hover { opacity: 0.75; }
.dd-body { overflow-y: auto; padding: 0; }
.dd-empty { padding: 1.5rem; text-align: center; color: var(--color-text-muted); font-size: 0.82rem; }

.dd-voucher { border-bottom: 1px solid #EEF1F5; }
.dd-voucher:last-child { border-bottom: none; }
.dd-voucher-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.8rem; cursor: pointer; font-size: 0.79rem; }
.dd-voucher-head:hover { background: var(--color-bg-tint); }
.dd-vno { font-family: var(--font-mono); font-size: 0.71rem; color: var(--color-text-muted); width: 130px; flex-shrink: 0; }
.dd-date { width: 90px; color: var(--color-text-muted); font-size: 0.75rem; flex-shrink: 0; }
.dd-narr { flex: 1; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-amt { width: 110px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.dd-lines { display: none; padding: 0 0.8rem 0.55rem 0.8rem; }
.dd-lines.open { display: block; }
.dd-lines table { width: 100%; font-size: 0.75rem; border-collapse: collapse; }
.dd-lines th, .dd-lines td { padding: 0.25rem 0.5rem; text-align: right; }
.dd-lines th:first-child, .dd-lines td:first-child { text-align: left; }
.dd-lines thead th { color: var(--color-text-muted); font-weight: 600; border-bottom: 1px solid var(--color-border); }

.drillable { cursor: pointer; }
.drillable:hover { background: var(--color-bg-tint) !important; }
