/* =====================================================================
   Finance Hub - Stylesheet (Black & White)
   Same layout/typography family as Operation Hub, monochrome palette.
   ===================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
:root {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-soft: #f0f0f1;
  --text: #0a0a0a;
  --text-muted: #71717a;
  --primary: #111111;
  --primary-dark: #000000;
  --accent: #111111;
  /* Status tones kept monochrome — differentiate by fill darkness + border, not hue */
  --tone-strong: #111111;   /* done / paid / active */
  --tone-mid: #52525b;      /* in-progress / info */
  --tone-soft: #a1a1aa;     /* pending / draft */
  --sidebar-bg: #0a0a0a;
  --sidebar-w: 240px;
  --footer-h: 48px;
}
html, body { height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }

.hidden { display: none !important; }

/* ============================== AUTH ============================== */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg); padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 16px;
  padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 12px;
  background: #0a0a0a; color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center; letter-spacing: 0.5px;
}
.auth-brand h1 { font-size: 22px; }
.auth-brand p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.auth-card h2 { font-size: 18px; margin-bottom: 8px; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.5; }
.auth-footnote { font-size: 12px; color: var(--text-muted); margin-top: 20px; line-height: 1.5; padding-top: 16px; border-top: 1px solid var(--border-soft); }

.user-pick-list { display: flex; flex-direction: column; gap: 8px; }
.user-pick {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  transition: all 0.15s; background: #fff; text-align: left; width: 100%;
}
.user-pick:hover { border-color: #0a0a0a; background: #fafafa; }
.user-pick .pa {
  width: 38px; height: 38px; border-radius: 50%; background: #111; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-pick .pm { flex: 1; min-width: 0; }
.user-pick .pm .pn { font-size: 14px; font-weight: 600; }
.user-pick .pm .pr { font-size: 11px; color: var(--text-muted); }

/* ============================== APP SHELL ============================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: #0a0a0a; color: #fff;
  position: fixed; top: 0; left: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 10px; border-right: 1px solid rgba(255,255,255,0.06);
}
/* workspace card (top) */
.brand, .ws-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; flex-shrink: 0; margin-bottom: 6px; user-select: none; }
.ws-avatar { width: 32px; height: 32px; border-radius: 7px; background: #fff; color: #0a0a0a; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; letter-spacing: 0.3px; }
.ws-meta { display: flex; flex-direction: column; min-width: 0; }
.ws-name { font-size: 13.5px; font-weight: 700; color: #fff; line-height: 1.25; }
.ws-sub { font-size: 11px; color: rgba(255,255,255,0.5); line-height: 1.3; }

/* search in sidebar */
.nav-search { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin: 2px 2px 8px; border-radius: 8px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.10); }
.nav-search .ns-icon { color: rgba(255,255,255,0.45); flex-shrink: 0; }
.nav-search input { flex: 1; background: transparent; border: none; outline: none; color: #fff; font-size: 13px; min-width: 0; }
.nav-search input::placeholder { color: rgba(255,255,255,0.38); }

nav#navList { flex: 1; overflow-y: auto; padding: 2px 0; display: flex; flex-direction: column; gap: 1px; scrollbar-width: none; }
nav#navList::-webkit-scrollbar { display: none; }
.nav-group { display: flex; flex-direction: column; }
.nav-section {
  appearance: none; -webkit-appearance: none; background: none; border: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: rgba(255,255,255,0.4);
  padding: 12px 10px 5px; font-weight: 700;
}
.nav-section:hover { color: rgba(255,255,255,0.7); }
.nav-chevron { margin-left: auto; font-size: 14px; line-height: 1; transition: transform 0.2s; transform: rotate(90deg); color: rgba(255,255,255,0.35); }
.nav-group.collapsed .nav-chevron { transform: rotate(0deg); }
.nav-group-items-wrap { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.25s ease; }
.nav-group.collapsed .nav-group-items-wrap { grid-template-rows: 0fr; }
.nav-group-items { overflow: hidden; min-height: 0; display: flex; flex-direction: column; gap: 1px; }
nav#navList.searching .nav-group-items-wrap { grid-template-rows: 1fr; }
nav#navList.searching .nav-chevron { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 0 2px; border-radius: 7px; cursor: pointer;
  transition: background 0.13s, color 0.13s; font-size: 13px; color: rgba(255,255,255,0.7); user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item:hover .icon { color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 600; }
.nav-item.active .icon { color: #fff; }
.nav-item .icon { font-size: 14px; width: 18px; text-align: center; color: rgba(255,255,255,0.55); transition: color 0.13s; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: #fff; color: #0a0a0a; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
}

.user-info {
  flex-shrink: 0; padding: 8px; margin-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.12); color: #fff; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .role { font-size: 11px; color: rgba(255,255,255,0.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon {
  background: rgba(255,255,255,0.06); color: #fff; border: 1px solid rgba(255,255,255,0.12);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,0.16); }

.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: 100vh;
  padding: 0 32px; min-width: 0; overflow-x: hidden;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap;
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.entity-switch, .role-switch { display: flex; align-items: center; gap: 8px; }
.entity-switch label, .role-switch label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.notif-bell { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 8px; width: 36px; height: 34px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.notif-bell:hover { background: #f4f4f5; border-color: #d4d4d8; }
.notif-count { position: absolute; top: -6px; right: -6px; background: #111; color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.notif-item { display: flex; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; align-items: flex-start; }
.notif-item:hover { background: #fafafa; border-color: #111; }
.notif-item .ni-ico { font-size: 16px; width: 22px; text-align: center; }
.notif-item .ni-t { font-weight: 600; font-size: 13px; }
.notif-item .ni-s { font-size: 12px; color: var(--text-muted); }
.notif-item.sev-danger { border-left: 3px solid #b91c1c; }
.notif-item.sev-warn { border-left: 3px solid #a1a1aa; }
.var-pos { color: #b91c1c; font-weight: 700; }
.var-neg { color: #111; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-size: 11px; font-weight: 700; color: var(--text-muted); text-align: center; padding: 4px 0; text-transform: uppercase; }
.cal-cell { border: 1px solid var(--border-soft); border-radius: 8px; min-height: 74px; padding: 5px 6px; background: #fff; }
.cal-cell.today { border-color: #111; }
.cal-cell .cd { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.cal-cell.muted-cell { background: #fafafa; }
.cal-pill { display: block; font-size: 10px; padding: 2px 5px; border-radius: 5px; margin-top: 3px; background: #f4f4f5; border: 1px solid var(--border); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-pill.od { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }

.sync-banner { background: #f4f4f5; color: #3f3f46; padding: 8px 16px; border-radius: 8px; font-size: 12px; margin-bottom: 16px; border: 1px solid var(--border); }

#pageContainer { flex: 1; padding-bottom: 32px; }

.page-footer {
  margin-top: auto; padding: 14px 0;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-muted); background: var(--bg);
}

/* ============================== PAGE LAYOUT ============================== */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Buttons */
.btn { padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: #18181b; border: 1px solid var(--border); }
.btn-secondary:hover { background: #f4f4f5; border-color: #d4d4d8; }
.btn-success { background: #111; color: #fff; border-color: #111; }
.btn-success:hover { background: #000; }
.btn-danger { background: #fff; color: #b91c1c; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-dark { background: #111; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Cards */
.card { background: var(--surface); border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); border: 1px solid var(--border); }
.card-title { font-size: 13px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }

/* Grids */
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* Stat cards */
.stat-card { padding: 16px 18px; }
.stat-card .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--text); margin-top: 6px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card.stat-accent { border-left: 3px solid #111; }
.stat-card.clickable { cursor: pointer; transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
.stat-card.clickable:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-color: #111; }
.big-num { font-size: 32px; font-weight: 700; color: var(--text); margin-top: 8px; font-variant-numeric: tabular-nums; }

/* Date/period range */
.date-range { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.date-range select, .date-range input { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 600px; }
table th { text-align: left; padding: 10px 12px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; border-bottom: 2px solid var(--border); background: #fafafa; white-space: nowrap; }
table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table tr:last-child td { border-bottom: none; }
table tbody tr:hover td { background: #fafafa; }
table .num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table .empty, .empty { text-align: center; color: var(--text-muted); padding: 32px 16px; }
table .mono, .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.row-link { color: #111; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.row-link:hover { color: #000; }

/* Sub-tabs */
.sub-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; flex-wrap: nowrap; }
.sub-tab {
  appearance: none; -webkit-appearance: none;
  background: none !important; border: none !important; border-radius: 0 !important;
  box-shadow: none !important; outline: none !important; margin: 0; font-family: inherit;
  padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent !important; white-space: nowrap; transition: color 0.15s, border-color 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: #111; border-bottom-color: #111 !important; }
.sub-tab .sub-count { background: #f4f4f5; border: 1px solid var(--border); color: #52525b; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 0 6px; }
.subpage-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; gap: 8px; }

/* Status badges — monochrome */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.2px; white-space: nowrap; }
.badge-strong { background: #111; color: #fff; }
.badge-mid    { background: #e4e4e7; color: #18181b; }
.badge-soft   { background: #fff; color: #71717a; border: 1px solid var(--border); }
.badge-outline{ background: #fff; color: #111; border: 1px solid #111; }
.badge-danger { background: #fff; color: #b91c1c; border: 1px solid #fca5a5; }
.badge-warn   { background: #fafafa; color: #3f3f46; border: 1px dashed #a1a1aa; }

/* Form */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #3f3f46; margin-bottom: 6px; }
.form-group label .req { color: #b91c1c; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; transition: border-color 0.15s; background: #fff; color: var(--text); }
.form-control:focus { outline: none; border-color: #111; box-shadow: 0 0 0 3px rgba(0,0,0,0.07); }
.form-control.inline { display: inline-block; width: auto; padding: 6px 10px; font-size: 13px; }
textarea.form-control { min-height: 70px; resize: vertical; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.req-doc { display:flex; align-items:center; gap:8px; padding:8px 10px; border:1px dashed var(--border); border-radius:8px; margin-bottom:6px; font-size:12px; }
.req-doc.filled { border-style: solid; border-color:#111; background:#fafafa; }

.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.full { width: 100%; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #f4f4f5; font-size: 11px; color: #3f3f46; border: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { color: var(--text); font-weight: 500; }

/* Approval trail */
.trail { list-style: none; border-left: 2px solid var(--border); margin-left: 8px; }
.trail li { position: relative; padding: 6px 0 14px 18px; font-size: 12px; }
.trail li::before { content:''; position:absolute; left:-7px; top:9px; width:10px; height:10px; border-radius:50%; background:#111; }
.trail li .ta { font-weight: 600; }
.trail li .tm { color: var(--text-muted); }

/* Chart */
.chart-wrap { position: relative; height: 280px; width: 100%; }
.chart-wrap canvas { max-width: 100% !important; }

/* ============================== MODAL ============================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 999; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { background: #fff; border-radius: 12px; width: 100%; max-width: 600px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-card.wide { max-width: 880px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; }
.modal-header .btn-icon { background: #f4f4f5; color: var(--text); border: none; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; background: #fafafa; }

/* ============================== TOAST ============================== */
#toastRoot { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0a0a0a; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); transform: translateX(120%); opacity: 0; transition: all 0.25s; max-width: 360px; }
.toast.show { transform: translateX(0); opacity: 1; }
.toast.toast-success { background: #111; }
.toast.toast-error { background: #b91c1c; }
.toast.toast-warn { background: #3f3f46; }
.toast.toast-info { background: #27272a; }

.empty-page { padding: 60px 20px; text-align: center; color: var(--text-muted); }

/* ============================== MOBILE HAMBURGER ============================== */
.mobile-menu-btn { display: none; position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; z-index: 1001; background: #0a0a0a; color: #fff; border: none; width: 44px; height: 44px; border-radius: 10px; cursor: pointer; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.mobile-menu-btn:active { transform: scale(0.95); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998; opacity: 0; transition: opacity 0.25s; }
.sidebar-backdrop.active { opacity: 1; }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar { width: 280px; transform: translateX(-100%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); z-index: 999; box-shadow: 4px 0 24px rgba(0,0,0,0.3); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.active { display: block; }
  .main { margin-left: 0; padding: 0 16px; }
  .topbar { padding: 56px 0 14px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .page-title { font-size: 18px; }
  .stat-card .value { font-size: 20px; }
  .big-num { font-size: 26px; }
  .card { padding: 14px 16px; }
  .btn { padding: 10px 18px; font-size: 14px; min-height: 40px; }
  .btn-sm { padding: 7px 12px; font-size: 12px; min-height: 32px; }
  .form-control { font-size: 16px; padding: 12px; min-height: 44px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-card { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 100px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  table { font-size: 12px; }
  #toastRoot { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: 100%; }
  .nav-item { padding: 13px 24px; min-height: 46px; }
}
