/* ==========================================================================
   app.css — application shell: login gate, sidebar, topbar, content, drawer
   ========================================================================== */

#app { min-height: 100vh; }

/* ============ LOGIN GATE ============ */
.login-screen { position: fixed; inset: 0; z-index: var(--z-login); display: grid;
  grid-template-columns: 1.05fr 1fr; background: var(--bg); }
.login-aside { position: relative; overflow: hidden; padding: var(--sp-7);
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--navy-800); color: #fff;
  border-right: 3px solid var(--accent-500); }
.login-aside .brand-mark { width: 168px; }
.login-aside .aside-mid { max-width: 460px; }
.login-aside h1 { color: #fff; font-size: clamp(2rem, 4vw, var(--fs-4xl)); letter-spacing: var(--track-tight); font-weight: 800; }
.login-aside h1 .accent { color: var(--accent-400); }
.login-aside p.lede { color: rgba(255,255,255,0.72); font-size: var(--fs-lg); margin-top: var(--sp-3); line-height: 1.6; }
.login-aside .pills { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-5); }
.login-aside .pill { font-size: var(--fs-sm); font-weight: 600; font-family: var(--font-display);
  padding: 7px 14px; border-radius: var(--r-full); background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16); color: #eef0ff; }
.login-aside .foot { font-size: var(--fs-xs); color: rgba(255,255,255,0.5); letter-spacing: var(--track-wide); text-transform: uppercase; }

.login-main { display: grid; place-items: center; padding: var(--sp-6); }
.login-card { width: 100%; max-width: 392px; }
.login-card .logo-row { display: none; }
.login-card h2 { font-size: var(--fs-2xl); }
.login-card .sub { color: var(--text-muted); margin-top: 4px; margin-bottom: var(--sp-5); }
.login-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.login-error { display: none; align-items: center; gap: var(--sp-2); padding: var(--sp-3);
  border-radius: var(--r-sm); background: var(--danger-bg); color: var(--danger);
  font-size: var(--fs-sm); font-weight: 500; }
.login-error.show { display: flex; animation: rise var(--dur) var(--ease-out) both; }
.login-error svg { width: 16px; height: 16px; flex: none; }
.login-hint { margin-top: var(--sp-5); padding: var(--sp-4); border: 1px dashed var(--border-strong);
  border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.login-hint b { font-family: var(--font-display); }
.login-hint .creds { display: grid; gap: 6px; margin-top: var(--sp-2); }
.login-hint .creds button { text-align: left; display: flex; justify-content: space-between; gap: var(--sp-3);
  padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border);
  font-size: var(--fs-sm); transition: border-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.login-hint .creds button:hover { border-color: var(--primary); transform: translateX(2px); }
.login-hint .creds .role { font-weight: 700; font-family: var(--font-display); color: var(--text); }
.login-hint .creds .em { color: var(--text-muted); }

@media (max-width: 880px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-card .logo-row { display: flex; justify-content: center; margin-bottom: var(--sp-5); }
  .login-card .logo-row img { width: 150px; }
}

/* ============ APP LAYOUT ============ */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.app-shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---- Sidebar ---- */
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); z-index: 40; }
.sidebar .side-top { display: flex; align-items: center; gap: var(--sp-3); height: var(--topbar-h);
  padding: 0 var(--sp-4); border-bottom: 1px solid var(--sidebar-border); }
.sidebar .side-logo { height: 30px; width: auto; }
.collapsed .sidebar .side-logo.full { display: none; }
.sidebar .side-logo.mark { display: none; height: 30px; }
.collapsed .sidebar .side-logo.mark { display: block; }
.sidebar nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3); }
.nav-group { margin-bottom: var(--sp-5); }
.nav-group .group-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: var(--track-wide);
  text-transform: uppercase; color: var(--text-faint); padding: 0 var(--sp-3); margin-bottom: var(--sp-2); }
.collapsed .nav-group .group-label { opacity: 0; height: 4px; margin: 0; }
.nav-item { display: flex; align-items: center; gap: var(--sp-3); height: 42px; padding: 0 var(--sp-3);
  border-radius: var(--r-sm); color: var(--sidebar-item); font-family: var(--font-display); font-weight: 600;
  font-size: var(--fs-base); position: relative; margin-bottom: 2px; white-space: nowrap;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: var(--sidebar-item-active-bg); color: var(--sidebar-item-active); }
.nav-item.active::before { content: ""; position: absolute; left: -3px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 3px; background: var(--primary); }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item .ni-badge { margin-left: auto; font-size: var(--fs-xs); font-weight: 700; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: var(--r-full); background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; }
.collapsed .nav-item { justify-content: center; padding: 0; }
.collapsed .nav-item .ni-label, .collapsed .nav-item .ni-badge { display: none; }
.sidebar .side-foot { padding: var(--sp-3); border-top: 1px solid var(--sidebar-border); }
.user-chip { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); border-radius: var(--r-md);
  width: 100%; transition: background-color var(--dur) var(--ease-out); }
.user-chip:hover { background: rgba(255, 255, 255, 0.07); }
.user-chip .uc-meta { text-align: left; min-width: 0; }
.user-chip .uc-name { font-weight: 700; font-family: var(--font-display); font-size: var(--fs-sm);
  color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .uc-role { font-size: var(--fs-xs); color: rgba(255, 255, 255, 0.6); text-transform: capitalize; }
.collapsed .user-chip .uc-meta { display: none; }

/* ---- Topbar ---- */
.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center;
  gap: var(--sp-3); padding: 0 var(--sp-5); border-bottom: 1px solid var(--border);
  background: var(--topbar-bg); backdrop-filter: blur(12px); }
.topbar .page-title { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-xl);
  letter-spacing: var(--track-snug); color: var(--text-strong); }
.topbar .page-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.topbar .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--text-muted); position: relative;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .ping { position: absolute; top: 7px; right: 7px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-full); background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--topbar-bg); }

.currency-switch { display: inline-flex; align-items: center; gap: 0; background: var(--surface-3);
  border-radius: var(--r-full); padding: 3px; }
.currency-switch button { height: 28px; padding: 0 12px; border-radius: var(--r-full); font-size: var(--fs-xs);
  font-weight: 700; font-family: var(--font-display); color: var(--text-muted);
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.currency-switch button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }

.menu-toggle { display: none; }

/* ---- Content ---- */
.content { padding: var(--sp-6) var(--sp-5); max-width: var(--content-max); width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4);
  flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head .ph-title h2 { font-size: var(--fs-2xl); }
.page-head .ph-title p { color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

/* Account cards (Accounts + Dashboard overview) */
.acct-card { position: relative; overflow: hidden; padding: var(--sp-5); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border); }
/* Two-tone: account stripe always uses the single accent (ignore per-account color). */
.acct-card .acct-stripe { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--primary); }
.acct-card .acct-type { font-size: var(--fs-xs); color: var(--text-muted); }
.acct-card .acct-name { font-family: var(--font-display); font-weight: 700; color: var(--text-strong); margin-top: var(--sp-2); }
.acct-card .acct-bal { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-xl);
  letter-spacing: var(--track-tight); margin-top: var(--sp-3); color: var(--text-strong); }

/* ---- Dropdown menu ---- */
.dropdown { position: absolute; min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px; z-index: var(--z-drawer);
  animation: pop var(--dur) var(--ease-spring) both; }
.dropdown .dd-item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 9px 10px;
  border-radius: var(--r-sm); font-size: var(--fs-base); color: var(--text); text-align: left;
  transition: background-color var(--dur-fast) var(--ease-out); }
.dropdown .dd-item:hover { background: var(--surface-2); }
.dropdown .dd-item.danger { color: var(--danger); }
.dropdown .dd-item svg { width: 17px; height: 17px; color: var(--text-muted); }
.dropdown .dd-item.danger svg { color: var(--danger); }
.dropdown hr { border: none; border-top: 1px solid var(--border-soft); margin: 6px 4px; }

/* ============ NOTIFICATIONS DRAWER ============ */
.drawer-backdrop { position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--overlay);
  animation: fade var(--dur) var(--ease-out) both; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-drawer); width: min(400px, 94vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slidein var(--dur-slow) var(--ease-out) both; }
.drawer-head { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between; }
.drawer-tools { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border-soft); }
.drawer-tools button { font-size: var(--fs-sm); font-weight: 600; color: var(--primary); }
.drawer-tools button:hover { text-decoration: underline; }
.notif-list { flex: 1; overflow-y: auto; padding: var(--sp-3); }
.notif { display: flex; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); position: relative;
  transition: background-color var(--dur-fast) var(--ease-out); }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--primary-soft); }
.notif .n-icon { width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.notif .n-icon svg { width: 17px; height: 17px; }
.notif.info .n-icon { color: var(--info); background: var(--info-bg); }
.notif.success .n-icon { color: var(--success); background: var(--success-bg); }
.notif.warning .n-icon { color: var(--warning); background: var(--warning-bg); }
.notif.danger .n-icon { color: var(--danger); background: var(--danger-bg); }
.notif.pending .n-icon { color: var(--pending); background: var(--pending-bg); }
.notif .n-title { font-weight: 700; font-family: var(--font-display); font-size: var(--fs-sm); color: var(--text-strong); }
.notif .n-desc { font-size: var(--fs-sm); color: var(--text-muted); }
.notif .n-time { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 3px; }

/* ============ CHAT ============ */
.chat { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - var(--topbar-h) - var(--sp-6) * 2);
  min-height: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.chat-list { border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; }
.chat-list .cl-search { padding: var(--sp-3); border-bottom: 1px solid var(--border-soft); }
.chat-list .cl-items { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); cursor: pointer; align-items: center;
  transition: background-color var(--dur-fast) var(--ease-out); }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--primary-soft); }
.conv .c-name { font-weight: 600; font-family: var(--font-display); color: var(--text-strong); font-size: var(--fs-base); }
.conv .c-last { font-size: var(--fs-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: var(--sp-3); }
.chat-msgs { flex: 1; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.msg { max-width: 72%; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); font-size: var(--fs-base); line-height: 1.5; }
.msg .m-who { font-size: var(--fs-xs); font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.msg .m-time { font-size: 10px; opacity: 0.7; margin-top: 3px; text-align: right; }
.msg.them { align-self: flex-start; background: var(--surface-3); color: var(--text); border-bottom-left-radius: var(--r-xs); }
.msg.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: var(--r-xs); }
.chat-input { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border-soft); display: flex; gap: var(--sp-3); }

/* ============ CLOCK widget ============ */
.clock-widget { text-align: center; padding: var(--sp-6); }
.clock-time { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.5rem, 7vw, 4.5rem);
  letter-spacing: var(--track-tight); color: var(--text-strong); font-variant-numeric: tabular-nums; line-height: 1; }
.clock-date { color: var(--text-muted); margin-top: var(--sp-2); font-size: var(--fs-lg); }
.clock-status { display: inline-flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-4);
  padding: 8px 16px; border-radius: var(--r-full); font-weight: 600; font-family: var(--font-display); }
.clock-status.in { color: var(--success); background: var(--success-bg); }
.clock-status.out { color: var(--text-muted); background: var(--surface-3); }

/* ============ RESPONSIVE SHELL ============ */
@media (max-width: 920px) {
  .app-shell, .app-shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease-out); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 39; background: var(--overlay); }
  .chat { grid-template-columns: 1fr; }
  .chat-list { display: none; }
  .chat.show-list .chat-list { display: flex; } .chat.show-list .chat-main { display: none; }
}
/* Collapse any in-content grid (incl. inline-styled asymmetric ones) on phones. */
@media (max-width: 760px) {
  .content .grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 560px) {
  .content { padding: var(--sp-4) var(--sp-4); }
  .currency-switch { display: none; }
  .topbar .page-sub { display: none; }
}
