/* ============================================================================
   Invoice Process Tracking — Premium Design System
   Waaree Energies
   Brand gradient: linear-gradient(to right, #3db6bd, #3cb878, #61b441, #3a6429)
   ========================================================================== */

:root {
  /* Brand */
  --grad: linear-gradient(120deg, #3db6bd, #3cb878 45%, #61b441 75%, #3a6429);
  --grad-soft: linear-gradient(120deg, rgba(61,182,189,.14), rgba(60,184,120,.12), rgba(97,180,65,.12));
  --teal: #3db6bd;
  --green: #3cb878;
  --lime: #61b441;
  --forest: #3a6429;
  --forest-deep: #2c4f20;

  /* Neutrals */
  --bg: #eef2f5;
  --bg-2: #e7edf1;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --ink: #14201a;
  --ink-2: #3f4d47;
  --muted: #6b7a73;
  --muted-2: #97a39c;
  --line: #e4eae7;
  --line-2: #eef2f0;

  /* Sidebar (dark, premium) */
  --side-bg: #10211a;
  --side-bg-2: #0c1813;
  --side-ink: #c9d8d0;
  --side-muted: #7d978b;
  --side-active: rgba(97,180,65,.16);

  /* Status palette (BRD 9.2) */
  --st-pending: #8a97a0;
  --st-progress: #3db6bd;
  --st-approved: #3cb878;
  --st-rejected: #e2574c;
  --st-rework: #e6932f;
  --st-complete: #3a6429;

  /* Effects */
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(16,33,26,.05), 0 1px 3px rgba(16,33,26,.06);
  --shadow: 0 6px 22px rgba(16,33,26,.07), 0 2px 6px rgba(16,33,26,.05);
  --shadow-lg: 0 24px 60px rgba(16,33,26,.16);
  --shadow-glow: 0 10px 30px rgba(60,184,120,.30);
  --ring: 0 0 0 4px rgba(60,184,120,.16);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --t-fast: .16s cubic-bezier(.4,0,.2,1);
  --t: .26s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--forest); text-decoration: none; }
a:hover { color: var(--green); }
h1,h2,h3,h4,h5 { margin: 0 0 .4em; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
::selection { background: rgba(60,184,120,.22); }

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #c4d0cb; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #a7b6b0; background-clip: content-box; }

/* Utility */
.text-grad {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.fw-700 { font-weight: 700; }
.gradient-bar { height: 4px; background: var(--grad); border-radius: 4px; }

/* ============================================================================
   AUTH PAGES  (premium animated left panel)
   ========================================================================== */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--bg); }

.auth-side {
  position: relative; overflow: hidden; isolation: isolate; color: #fff;
  background: radial-gradient(130% 120% at 0% 0%, #103024 0%, #0a1a12 55%, #06100b 100%);
  display: flex; flex-direction: column; padding: 46px 52px; min-height: 100vh;
}
/* layer 0 — drifting aurora blobs */
.auth-aurora { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.auth-aurora i {
  position: absolute; display: block; width: 48vmax; height: 48vmax; border-radius: 50%;
  filter: blur(64px); opacity: .5; mix-blend-mode: screen; will-change: transform;
}
.auth-aurora i:nth-child(1) { background: radial-gradient(circle at 35% 35%, #3db6bd, transparent 60%); top: -16%; left: -14%; animation: aurFloat1 18s ease-in-out infinite; }
.auth-aurora i:nth-child(2) { background: radial-gradient(circle at 35% 35%, #3cb878, transparent 60%); bottom: -22%; right: -12%; animation: aurFloat2 22s ease-in-out infinite; }
.auth-aurora i:nth-child(3) { background: radial-gradient(circle at 35% 35%, #61b441, transparent 62%); top: 34%; left: 34%; opacity: .35; animation: aurFloat3 26s ease-in-out infinite; }
@keyframes aurFloat1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(9%,11%) scale(1.18); } }
@keyframes aurFloat2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-11%,-9%) scale(1.22); } }
@keyframes aurFloat3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-7%,9%) scale(1.12); } }
/* layer 1 — drifting grid + particle canvas */
.auth-side::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: .4;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 25%, transparent 78%);
  mask-image: radial-gradient(circle at 50% 42%, #000 25%, transparent 78%);
  animation: gridDrift 24s linear infinite;
}
@keyframes gridDrift { to { background-position: 46px 46px, 46px 46px; } }
.auth-particles { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }
/* layer 2 — content */
.auth-side-inner { position: relative; z-index: 2; display: flex; flex-direction: column; justify-content: space-between; gap: 22px; flex: 1; }

.auth-brand { display: flex; align-items: center; gap: 13px; }
.auth-brand img { height: 34px; background: #fff; padding: 7px 11px; border-radius: 11px; box-shadow: 0 10px 26px rgba(0,0,0,.3); }
.auth-brand .bn { font-weight: 800; font-size: 15.5px; line-height: 1.2; }
.auth-brand .bn small { display: block; margin-top: 3px; font-weight: 600; font-size: 13.5px; color: #9fe9bd; letter-spacing: .02em; }

.auth-center { display: flex; flex-direction: column; gap: 26px; }
.auth-hero h1 { font-size: clamp(28px, 3.1vw, 41px); line-height: 1.08; letter-spacing: -.025em; margin: 0 0 14px; color: #fff; }
.auth-hero h1 .hl { background: linear-gradient(90deg, #8fe6b0, #c7ec8c 45%, #7fe0e6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-rotator { height: 24px; overflow: hidden; position: relative; }
.auth-rotator span { position: absolute; inset: 0; font-size: 15px; color: rgba(255,255,255,.82); opacity: 0; transform: translateY(100%); transition: opacity .6s, transform .6s; }
.auth-rotator span.on { opacity: 1; transform: translateY(0); }
.auth-rotator span.off { opacity: 0; transform: translateY(-110%); }

/* animated workflow tracker (the product, demonstrated) */
.auth-flow { position: relative; }
.auth-flow .rail { position: absolute; left: 21px; top: 22px; bottom: 22px; width: 2px; background: rgba(255,255,255,.13); border-radius: 2px; overflow: hidden; }
.auth-flow .rail .fill { position: absolute; left: 0; right: 0; top: 0; height: 0; background: linear-gradient(180deg, #3db6bd, #3cb878 55%, #61b441); box-shadow: 0 0 12px rgba(97,180,65,.75); transition: height .9s cubic-bezier(.4,0,.2,1); }
.auth-stage { display: flex; align-items: center; gap: 14px; padding: 7px 0; }
.auth-stage .pin { position: relative; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; background: rgba(255,255,255,.05); border: 2px solid rgba(255,255,255,.16); color: rgba(255,255,255,.55); transition: all .5s; }
.auth-stage .tx b { font-size: 13.8px; font-weight: 700; color: rgba(255,255,255,.85); }
.auth-stage .tx small { display: block; font-size: 11.5px; color: rgba(255,255,255,.5); }
.auth-stage.done .pin { background: linear-gradient(135deg, #3cb878, #3a6429); border-color: transparent; color: #fff; }
.auth-stage.done .tx b, .auth-stage.active .tx b { color: #fff; }
.auth-stage.active .pin { background: var(--grad); border-color: transparent; color: #fff; animation: pinPulse 1.15s ease-in-out infinite; }
@keyframes pinPulse { 0%,100% { box-shadow: 0 0 0 5px rgba(60,184,120,.18), 0 10px 24px rgba(60,184,120,.4); } 50% { box-shadow: 0 0 0 13px rgba(60,184,120,0), 0 10px 24px rgba(60,184,120,.55); } }

.auth-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12px; color: rgba(255,255,255,.55); }
.auth-foot .pill { display: inline-flex; align-items: center; gap: 6px; }
.auth-foot .pill .bi { color: #8fe6b0; }

/* right / form side */
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 412px; }
.auth-card .logo-sm { display: none; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 28px; font-size: 14.5px; }

/* responsive — stack with a compact animated banner on top */
@media (max-width: 991px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { min-height: auto; padding: 30px 26px 28px; }
  .auth-side-inner { gap: 16px; }
  .auth-center { gap: 14px; }
  .auth-hero h1 { font-size: clamp(24px, 6.5vw, 32px); margin-bottom: 8px; }
  .auth-flow, .auth-foot { display: none; }   /* keep the banner short when stacked */
}
@media (max-width: 480px) {
  .auth-side { padding: 24px 20px 22px; }
  .auth-rotator { display: none; }
  .auth-main { padding: 26px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-aurora i, .auth-side::before, .auth-stage.active .pin { animation: none; }
}

/* ============================================================================
   FORMS
   ========================================================================== */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.input, .form-control, .form-select, textarea.input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14.5px; font-family: var(--font); color: var(--ink); background: #fff;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .form-control:focus, .form-select:focus, textarea.input:focus {
  outline: none; border-color: var(--green); box-shadow: var(--ring);
}
.input::placeholder { color: var(--muted-2); }
.input-group { position: relative; }
.input-group .bi-eye, .input-group .bi-eye-slash { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); cursor: pointer; }
.input-icon { padding-left: 42px; }
.input-group > .bi:first-child { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field.invalid .input { border-color: var(--st-rejected); }
.field .err { color: var(--st-rejected); font-size: 12px; margin-top: 6px; display: none; }
.field.invalid .err { display: block; }

/* OTP boxes */
.otp-row { display: flex; gap: 10px; justify-content: space-between; }
.otp-row input {
  width: 100%; aspect-ratio: 1; text-align: center; font-size: 24px; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: 12px; color: var(--forest);
}
.otp-row input:focus { outline: none; border-color: var(--green); box-shadow: var(--ring); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; font-family: var(--font);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), filter var(--t-fast);
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn-grad { background: var(--grad); color: #fff; box-shadow: var(--shadow-glow); background-size: 160% 100%; }
.btn-grad:hover { filter: brightness(1.05); color: #fff; background-position: 30% 0; }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--forest-deep); color: #fff; }
.btn-light { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-light:hover { background: var(--surface-2); border-color: #d6ded9; }
.btn-soft { background: var(--grad-soft); color: var(--forest); }
.btn-soft:hover { filter: brightness(.98); }
.btn-danger { background: #fdecea; color: #c23a30; }
.btn-danger:hover { background: #fbdcd8; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn:disabled, .btn.loading { opacity: .65; pointer-events: none; }
.btn.loading::after {
  content: ""; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   APP SHELL
   ========================================================================== */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; transition: grid-template-columns var(--t); }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--side-bg), var(--side-bg-2));
  color: var(--side-ink); display: flex; flex-direction: column; z-index: 40;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; }
.sidebar .brand img { height: 30px; background: #fff; padding: 5px 8px; border-radius: 8px; }
.sidebar .brand .t { font-size: 14.5px; font-weight: 800; color: #fff; line-height: 1.1; }
.sidebar .brand .t small { display: block; font-size: 10.5px; font-weight: 500; color: var(--side-muted); letter-spacing: .04em; }
.nav-section { padding: 6px 14px; }
.nav-section .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--side-muted); padding: 14px 12px 7px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10.5px 12px; margin: 2px 0; border-radius: 11px;
  color: var(--side-ink); font-size: 14px; font-weight: 500; cursor: pointer; position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-link .bi { font-size: 17px; opacity: .9; width: 20px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--side-active); color: #fff; }
.nav-link.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--grad);
}
.nav-link .badge-count {
  margin-left: auto; background: var(--grad); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 21px; height: 21px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.sidebar .side-foot { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.07); }
.role-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--side-muted); }
.role-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grad); }

/* Topbar */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.85); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); padding: 13px 26px; display: flex; align-items: center; gap: 16px;
}
.topbar .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; font-size: 20px; color: var(--ink-2); background: #fff; border: 1.5px solid var(--line); cursor: pointer; transition: var(--t-fast); flex-shrink: 0; }
.topbar .menu-toggle:hover { background: var(--surface-2); border-color: #d6ded9; color: var(--forest); }
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .page-title small { display:block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.topbar .spacer { flex: 1; }
.topbar .search {
  position: relative; width: 280px; max-width: 32vw;
}
.topbar .search input { width: 100%; padding: 9px 12px 9px 38px; border-radius: 24px; border: 1.5px solid var(--line); background: var(--surface-2); font-size: 13.5px; }
.topbar .search input:focus { outline: none; border-color: var(--green); box-shadow: var(--ring); background: #fff; }
.topbar .search .bi { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; transition: var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); border-color: #d6ded9; }
.icon-btn .dot-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--st-rejected); color: #fff; font-size: 10.5px; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center; border: 2px solid #fff;
}
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px; border-radius: 30px; }
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.user-chip .meta { line-height: 1.15; }
.user-chip .meta .nm { font-size: 13.5px; font-weight: 700; }
.user-chip .meta .rl { font-size: 11.5px; color: var(--muted); }

.content { padding: 26px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .ph-title h1 { font-size: 23px; margin-bottom: 4px; }
.page-head .ph-title p { color: var(--muted); font-size: 14px; margin: 0; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* Mobile shell */
.scrim { display: none; position: fixed; inset: 0; background: rgba(8,18,13,.5); z-index: 39; }
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform var(--t); box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .scrim { display: block; }
  .topbar .menu-toggle { display: inline-flex; }
  .content { padding: 18px; }
  .topbar .search { display: none; }
}

/* Desktop: collapsed icon-rail sidebar (toggled from the navbar) */
@media (min-width: 1025px) {
  .app.collapsed { grid-template-columns: 76px 1fr; }
  .app.collapsed .sidebar { overflow-x: hidden; }
  .app.collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .app.collapsed .brand .t { display: none; }
  .app.collapsed .nav-section { padding-left: 10px; padding-right: 10px; }
  .app.collapsed .nav-section .lbl { display: none; }
  .app.collapsed .nav-link { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
  .app.collapsed .nav-link > span:not(.badge-count) { display: none; }
  .app.collapsed .nav-link .bi { width: auto; font-size: 18px; }
  .app.collapsed .nav-link.active::before { left: -10px; }
  .app.collapsed .nav-link .badge-count { position: absolute; top: 5px; right: 11px; min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; }
  .app.collapsed .side-foot { padding-left: 0; padding-right: 0; }
  .app.collapsed .side-foot .role-pill { justify-content: center; font-size: 0; }
}

/* ============================================================================
   CARDS / PANELS
   ========================================================================== */
.card2 { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card2 .c-head { padding: 18px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.card2 .c-head h3 { font-size: 15.5px; margin: 0; }
.card2 .c-head .sub { font-size: 12.5px; color: var(--muted); margin: 0; }
.card2 .c-head .c-actions { margin-left: auto; display: flex; gap: 8px; }
.card2 .c-body { padding: 20px; }
.card2.flush .c-body { padding: 0; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); overflow: hidden; transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--grad-soft); }
.stat .ic { width: 44px; height: 44px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; font-size: 21px; color: #fff; background: var(--grad); position: relative; z-index: 1; }
.stat .ic.alt { background: linear-gradient(135deg, var(--teal), var(--green)); }
.stat .v { font-size: 30px; font-weight: 800; margin-top: 12px; letter-spacing: -.02em; position: relative; z-index: 1; }
.stat .k { font-size: 13px; color: var(--muted); position: relative; z-index: 1; }
.stat .trend { font-size: 12px; font-weight: 600; margin-top: 6px; position: relative; z-index: 1; }
.stat .trend.up { color: var(--green); } .stat .trend.down { color: var(--st-rejected); }

.grid { display: grid; gap: 16px; }
/* Allow grid cells to shrink below their content width so a wide canvas/table
   never forces the column wider (which would cause page horizontal scroll). */
.grid > *, .stat-grid > * { min-width: 0; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-12 { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 980px) { .grid-2, .grid-3, .grid-12 { grid-template-columns: 1fr; } }
/* Charts must never exceed their container (belt-and-suspenders with the
   resize dispatch on sidebar toggle). */
.card2 canvas { max-width: 100% !important; }

/* ============================================================================
   BADGES / CHIPS
   ========================================================================== */
.badge2 { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 20px; line-height: 1.4; white-space: nowrap; }
.badge2 .bdot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-pending { background: #eef1f3; color: #5d6b73; }
.b-progress { background: rgba(61,182,189,.14); color: #1f8e94; }
.b-approved, .b-active { background: rgba(60,184,120,.15); color: #2a8e5a; }
.b-rejected { background: rgba(226,87,76,.14); color: #c23a30; }
.b-rework { background: rgba(230,147,47,.15); color: #b9741c; }
.b-complete { background: rgba(58,100,41,.13); color: #3a6429; }
.b-role { background: var(--grad-soft); color: var(--forest); }
.chip { display:inline-flex; align-items:center; gap:6px; padding: 5px 11px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }

/* ============================================================================
   TABLES
   ========================================================================== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl thead th {
  text-align: left; padding: 13px 16px; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--ink-2); }
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .entry-no { font-weight: 700; color: var(--forest); }
.row-click { cursor: pointer; }
table.tbl thead th.sortable { cursor: pointer; user-select: none; white-space: nowrap; transition: color var(--t-fast); }
table.tbl thead th.sortable:hover { color: var(--forest); }
table.tbl thead th.sortable .sx { font-size: 11px; margin-left: 4px; opacity: .4; }
table.tbl thead th.sortable.asc .sx, table.tbl thead th.sortable.desc .sx { opacity: 1; color: var(--green); }

.table-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.table-toolbar .search-mini { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.table-toolbar .search-mini input { width: 100%; padding: 9px 12px 9px 36px; border-radius: 10px; border: 1.5px solid var(--line); font-size: 13.5px; }
.table-toolbar .search-mini .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.pagination { display: flex; align-items: center; gap: 6px; padding: 14px 20px; flex-wrap: wrap; }
.pagination .pg { min-width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--line); background: #fff; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 13px; font-weight: 600; }
.pagination .pg:hover { background: var(--surface-2); }
.pagination .pg.active { background: var(--grad); color: #fff; border-color: transparent; }
.pagination .pg:disabled { opacity: .45; pointer-events: none; }
.pg-info { color: var(--muted); font-size: 12.5px; margin-left: auto; }

/* Empty / loading */
.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .bi { font-size: 46px; color: var(--line); display: block; margin-bottom: 12px; }
.skeleton { background: linear-gradient(90deg, #eef2f0 25%, #e2e9e5 37%, #eef2f0 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.spinner-c { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner-c::after { content: ""; width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }

/* ============================================================================
   TOASTS / MODALS
   ========================================================================== */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast2 {
  display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow-lg); animation: toastIn .3s cubic-bezier(.2,.9,.3,1);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }
.toast2.out { animation: toastOut .25s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
.toast2 .bi { font-size: 19px; margin-top: 1px; }
.toast2.ok { border-left-color: var(--green); } .toast2.ok .bi { color: var(--green); }
.toast2.err { border-left-color: var(--st-rejected); } .toast2.err .bi { color: var(--st-rejected); }
.toast2.info { border-left-color: var(--teal); } .toast2.info .bi { color: var(--teal); }
.toast2.warn { border-left-color: var(--st-rework); } .toast2.warn .bi { color: var(--st-rework); }
.toast2 .tx .ti { font-weight: 700; font-size: 13.5px; }
.toast2 .tx .ms { font-size: 13px; color: var(--muted); }

.modal-back { position: fixed; inset: 0; background: rgba(8,18,13,.46); backdrop-filter: blur(2px); z-index: 9990; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-back.open { display: flex; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.modal2 { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 540px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; animation: modalin .3s cubic-bezier(.2,.9,.3,1); }
@keyframes modalin { from { opacity: 0; transform: translateY(20px) scale(.98); } }
.modal2.lg { max-width: 760px; }
/* The optional <form> between .modal2 and .m-body/.m-foot must join the flex
   column so the body scrolls and the footer (action buttons) stays visible. */
.modal2 > form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; overflow: hidden; }
.modal2 .m-head { flex: 0 0 auto; padding: 20px 24px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.modal2 .m-head h3 { margin: 0; font-size: 17px; }
.modal2 .m-head .x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: none; }
.modal2 .m-body { flex: 1 1 auto; min-height: 0; padding: 22px 24px; overflow-y: auto; }
.modal2 .m-foot { flex: 0 0 auto; padding: 16px 24px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); }

/* Alerts inline */
.alert2 { display: flex; gap: 11px; padding: 13px 16px; border-radius: 12px; font-size: 13.5px; margin-bottom: 16px; align-items: flex-start; }
.alert2 .bi { font-size: 18px; margin-top: 1px; }
.alert2.err { background: #fdecea; color: #b5352b; }
.alert2.ok { background: rgba(60,184,120,.12); color: #2a8e5a; }
.alert2.info { background: rgba(61,182,189,.12); color: #1f8e94; }
.alert2.warn { background: rgba(230,147,47,.13); color: #b9741c; }

/* Definition list (entry detail) */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 0; }
.dl dt { padding: 10px 0; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line-2); }
.dl dd { padding: 10px 0; margin: 0; font-weight: 600; color: var(--ink); font-size: 13.5px; border-bottom: 1px solid var(--line-2); }
@media (max-width: 620px){ .dl { grid-template-columns: 1fr; } .dl dt { border-bottom: none; padding-bottom: 0; } }

/* ============================================================================
   DROPDOWNS / NOTIFICATIONS
   ========================================================================== */
/* Custom dropdown — namespaced (ui-) to avoid colliding with Bootstrap's
   .dropdown-menu { display:none } which otherwise hides our menu. */
.ui-dropdown { position: relative; }
.ui-menu {
  position: absolute; right: 0; top: calc(100% + 12px); min-width: 248px; background: #fff;
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 8px;
  display: block; opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98);
  transform-origin: top right; transition: var(--t-fast); z-index: 70; pointer-events: none;
}
.ui-menu.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); pointer-events: auto; }
/* little arrow */
.ui-menu::before {
  content: ""; position: absolute; top: -6px; right: 22px; width: 12px; height: 12px; background: #fff;
  border-left: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg); border-radius: 3px 0 0 0;
}
.ui-menu .dd-head { padding: 12px 12px 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 5px; display: flex; gap: 11px; align-items: center; }
.ui-menu .dd-head .av { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ui-menu .dd-head .nm { font-weight: 700; font-size: 14px; line-height: 1.2; }
.ui-menu .dd-head .em { font-size: 12px; color: var(--muted); }
.ui-menu .dd-head .rl { display: inline-block; margin-top: 4px; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--grad-soft); color: var(--forest); }
.ui-menu-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-size: 13.8px; cursor: pointer; text-decoration: none; transition: var(--t-fast); border: none; background: none; width: 100%; text-align: left; font-family: var(--font); }
.ui-menu-item:hover { background: var(--surface-2); color: var(--ink); }
.ui-menu-item .bi { font-size: 16px; width: 20px; text-align: center; color: var(--muted); }
.ui-menu-item:hover .bi { color: var(--forest); }
.ui-menu-item.danger { color: #c23a30; }
.ui-menu-item.danger:hover { background: #fdecea; }
.ui-menu-item.danger .bi { color: #d8584d; }
.ui-menu-divider { height: 1px; background: var(--line-2); margin: 6px 4px; }

.notif-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 360px; max-width: 92vw; background: #fff;
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: var(--t-fast); z-index: 60; overflow: hidden;
}
.notif-panel.open { opacity: 1; visibility: visible; transform: translateY(0); }
.notif-panel .np-head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); font-weight: 700; font-size: 14px; display: flex; align-items: center; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: rgba(60,184,120,.05); }
.notif-item .ni-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--grad-soft); color: var(--forest); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-item .ni-tx { display: flex; flex-direction: column; min-width: 0; }
.notif-item .ni-t { font-weight: 600; font-size: 13.3px; color: var(--ink); }
.notif-item .ni-b { font-size: 12.5px; color: var(--muted); }
.notif-item .ni-time { font-size: 11px; color: var(--muted-2); margin-top: 3px; }

/* ============================================================================
   UPLOAD / DROPZONE
   ========================================================================== */
.dropzone {
  border: 2.5px dashed #cfdad4; border-radius: var(--radius); padding: 40px 24px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: var(--t-fast);
}
.dropzone:hover, .dropzone.drag { border-color: var(--green); background: rgba(60,184,120,.06); }
.dropzone .dz-ic { font-size: 46px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dropzone h4 { margin: 12px 0 4px; font-size: 16px; }
.dropzone p { color: var(--muted); font-size: 13px; margin: 0; }
.file-pill { display: inline-flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 11px; background: #fff; border: 1.5px solid var(--line); margin-top: 14px; }
.file-pill .bi { color: var(--green); font-size: 20px; }
.file-pill .x { cursor: pointer; color: var(--muted); margin-left: 6px; }

.upload-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.upload-summary .us { padding: 14px; border-radius: 12px; text-align: center; }
.upload-summary .us .n { font-size: 24px; font-weight: 800; }
.upload-summary .us .l { font-size: 12px; color: var(--muted); }
.upload-summary .us.ok { background: rgba(60,184,120,.1); } .upload-summary .us.ok .n { color: var(--green); }
.upload-summary .us.skip { background: rgba(230,147,47,.1); } .upload-summary .us.skip .n { color: var(--st-rework); }
.upload-summary .us.tot { background: var(--surface-2); } .upload-summary .us.tot .n { color: var(--ink); }

/* ============================================================================
   SMART INSIGHTS
   ========================================================================== */
.insight-card .insight-spark { width: 38px; height: 38px; border-radius: 11px; background: var(--grad); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 19px; box-shadow: var(--shadow-glow); }
.insight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.insight { display: flex; gap: 12px; padding: 13px 15px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); }
.insight .ins-ic { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.insight .ins-t { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.insight .ins-x { font-size: 12.7px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.insight.ins-bottleneck .ins-ic, .insight.ins-info .ins-ic { background: rgba(61,182,189,.16); color: #1f8e94; }
.insight.ins-risk .ins-ic { background: rgba(226,87,76,.15); color: #c23a30; }
.insight.ins-watch .ins-ic { background: rgba(230,147,47,.16); color: #b9741c; }
.insight.ins-good .ins-ic { background: rgba(60,184,120,.16); color: #2a8e5a; }
.insight.ins-risk { border-color: rgba(226,87,76,.25); }

/* ============================================================================
   KANBAN BOARD (Live Tracker)
   ========================================================================== */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.board-col { flex: 0 0 270px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.board-col .bc-head { padding: 13px 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 9px; position: sticky; top: 0; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; z-index: 1; }
.board-col .bc-head .ic { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.board-col .bc-head .t { font-weight: 700; font-size: 13.5px; }
.board-col .bc-head .cnt { margin-left: auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; min-width: 26px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; color: var(--ink-2); padding: 0 8px; }
.board-col .bc-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.kcard { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 11px; padding: 11px 12px; cursor: pointer; transition: var(--t-fast); }
.kcard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kcard.warn { border-left-color: var(--st-rework); } .kcard.crit { border-left-color: var(--st-rejected); }
.kcard .kc-no { font-weight: 700; font-size: 12.5px; color: var(--forest); }
.kcard .kc-cust { font-size: 13px; color: var(--ink); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .kc-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.board-col.done .bc-head .ic { background: var(--forest); }
.board-empty { text-align: center; color: var(--muted-2); font-size: 12.5px; padding: 18px 8px; }

.divider { height: 1px; background: var(--line-2); margin: 18px 0; }
.flex { display: flex; } .between { justify-content: space-between; } .items-center { align-items: center; } .gap { gap: 12px; } .wrap { flex-wrap: wrap; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.hide { display: none !important; }

/* ============================================================================
   PRINT / EXPORT-PDF  (clean, branded report output)
   ========================================================================== */
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  .sidebar, .topbar, .scrim, #toasts, .no-print, .ui-dropdown, .menu-toggle { display: none !important; }
  .app { display: block !important; }
  .main { display: block !important; }
  .content { padding: 0 !important; }
  body, .app { background: #fff !important; }
  .print-only { display: block !important; }
  .card2 { box-shadow: none !important; border: 1px solid #d9e1dd !important; break-inside: avoid; page-break-inside: avoid; }
  .stat { box-shadow: none !important; border: 1px solid #d9e1dd !important; break-inside: avoid; }
  .grid-12, .grid-2, .grid-3 { grid-template-columns: 1fr 1fr !important; }
  .stat-grid { grid-template-columns: repeat(4, 1fr) !important; }
  a[href]:after { content: ""; }
  .print-head { border-bottom: 3px solid #3a6429; padding-bottom: 12px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; }
  .print-head .pt-title { font-size: 20px; font-weight: 800; color: #14201a; }
  .print-head .pt-sub { font-size: 12px; color: #6b7a73; }
}
