:root {
  --bg-page: #f3f6fc;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sidebar: #0b0f19;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
  --bg-sidebar-active: linear-gradient(90deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.06));

  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;

  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --emerald-border: #a7f3d0;

  --amber: #d97706;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;

  --rose: #e11d48;
  --rose-soft: #fff1f2;
  --rose-border: #fecdd3;

  --violet: #7c3aed;
  --violet-soft: #f5f3ff;

  --border: #e2e8f0;
  --border-subtle: #edf2f7;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-hover: 0 12px 28px -4px rgba(15, 23, 42, 0.09), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 25px 70px -10px rgba(15, 23, 42, 0.32), 0 0 1px rgba(15, 23, 42, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-page);
  background-image:
    radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.05) 0px, transparent 45%),
    radial-gradient(at 100% 0%, rgba(124, 58, 237, 0.04) 0px, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  font: 14px/1.6 "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

button, a, select {
  cursor: pointer;
}

/* ==================== Buttons ==================== */
button {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

button:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-main);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

button:active {
  transform: translateY(0);
}

button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

button.primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

button.primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

button.danger {
  color: var(--rose);
  border-color: var(--rose-border);
  background: var(--rose-soft);
}

button.danger:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

button.success {
  color: var(--emerald);
  border-color: var(--emerald-border);
  background: var(--emerald-soft);
}

button.success:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

button.sm {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.link {
  border: 0;
  padding: 4px 8px;
  background: transparent;
  color: var(--primary);
  font-weight: 500;
  font-size: 13px;
  box-shadow: none;
  border-radius: 6px;
}

.link:hover {
  background: var(--primary-soft);
  color: var(--primary-hover);
  transform: none;
  box-shadow: none;
}

.link.danger-link {
  color: var(--rose);
}

.link.danger-link:hover {
  background: var(--rose-soft);
  color: #be123c;
}

/* ==================== Layout Shell ==================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ==================== Dark Executive Sidebar ==================== */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  background-image: radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.18), transparent 55%);
  color: #e2e8f0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  z-index: 20;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

.brand {
  display: flex;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
  align-items: center;
  padding: 4px 10px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.brand-logo svg {
  width: 20px;
  height: 20px;
}

.brand-text strong {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #f8fafc;
}

.brand-text small {
  display: block;
  font-size: 9.5px;
  color: #64748b;
  letter-spacing: 1.4px;
  font-weight: 600;
  margin-top: 1px;
}

.workspace-card {
  margin: 22px 4px 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.ws-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ws-info {
  flex: 1;
  min-width: 0;
}

.ws-title {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
}

.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  flex-shrink: 0;
}

.nav-group-label {
  font-size: 11px;
  color: #64748b;
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.sidenav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidenav a {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: #94a3b8;
  padding: 10px 13px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.sidenav a:hover {
  background: var(--bg-sidebar-hover);
  color: #f8fafc;
}

.sidenav a.active {
  background: var(--bg-sidebar-active);
  color: #ffffff;
  font-weight: 600;
  border-left-color: #3b82f6;
}

.sidenav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidenav a.active svg {
  color: #60a5fa;
  opacity: 1;
}

.sidenav .nav-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 99px;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.db-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  flex-shrink: 0;
}

.db-title {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.db-sub {
  font-size: 10.5px;
  color: #64748b;
}

/* ==================== Login Mode (Clean Fullscreen) ==================== */
html.is-login-mode .sidebar,
html.is-login-mode .topbar,
html.is-login-mode .page-footer,
body.is-login-mode .sidebar,
body.is-login-mode .topbar,
body.is-login-mode .page-footer {
  display: none !important;
}

html.is-login-mode .main-area,
body.is-login-mode .main-area {
  margin-left: 0 !important;
  width: 100% !important;
  min-height: 100vh !important;
  background: #f8fafc !important;
}

html.is-login-mode .page-content,
body.is-login-mode .page-content {
  padding: 0 !important;
  min-height: 100vh !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* ==================== Main Area & Topbar ==================== */
.main-area {
  margin-left: 260px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 66px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 15;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.breadcrumb strong {
  color: var(--text-main);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-Indicator {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.role-Indicator::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.role-Indicator.emp-mode {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.user-switcher {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.switcher-label {
  color: var(--text-muted);
  font-size: 12px;
}

.user-switcher select {
  border: 0;
  background: transparent;
  color: var(--text-main);
  font-weight: 600;
  padding: 2px 4px;
  margin: 0;
  width: auto;
  outline: none;
  font-size: 12.5px;
}

.user-avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  font-weight: 700;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.25);
}

/* ==================== Page Content & Headings ==================== */
.page-content {
  padding: 30px 36px;
  flex: 1;
  max-width: 1640px;
  width: 100%;
  margin: 0 auto;
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
}

.heading h1 {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.3px;
  margin: 0 0 5px;
  color: var(--text-main);
}

.heading p {
  color: var(--text-muted);
  margin: 0;
  font-size: 13.5px;
}

h2 {
  font-size: 15.5px;
  font-weight: 650;
  margin: 0;
  color: var(--text-main);
}

h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text-secondary);
}

p {
  color: var(--text-muted);
  margin: 3px 0;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ==================== Banner Notices ==================== */
.notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--primary);
  color: #1e3a8a;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 13.5px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.notice.warn-box {
  background: linear-gradient(90deg, #fffbeb 0%, #fefce8 100%);
  border-color: #fde68a;
  border-left-color: var(--amber);
  color: #92400e;
}

/* ==================== Bento KPI Stats Cards ==================== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.stat label {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.violet { background: #f5f3ff; color: #7c3aed; }
.stat-icon.emerald { background: #ecfdf5; color: #059669; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }

.stat strong {
  display: block;
  font-size: 29px;
  font-weight: 750;
  line-height: 1.3;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.stat-foot {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-light);
}

/* ==================== Cards & Grids ==================== */
.grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: 22px;
  overflow: hidden;
}

.cardhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 17px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: #ffffff;
}

.cardbody {
  padding: 22px;
}

.muted {
  color: var(--text-light);
  font-size: 12px;
}

/* ==================== Modern Charts & Organization Progress ==================== */
.chart-wrap {
  padding: 22px 24px 18px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 195px;
  padding: 24px 12px 10px;
  border-bottom: 1px dashed var(--border);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, rgba(241, 245, 249, 0.5) 100%);
  border-radius: 8px;
}

.barcol {
  flex: 1;
  text-align: center;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.bar-val {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 650;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.bar {
  width: 52%;
  max-width: 42px;
  background: linear-gradient(180deg, #93c5fd 0%, #60a5fa 100%);
  border-radius: 7px 7px 2px 2px;
  min-height: 5px;
  transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s ease;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.18);
}

.barcol:hover .bar {
  transform: scaleX(1.08);
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

.barcol:last-child .bar {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.barcol small {
  padding-top: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.company {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.org-metric-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
}

.companyline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}

.track div {
  background: linear-gradient(90deg, #3b82f6 0%, #6366f1 100%);
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s ease;
}

/* ==================== Filters & Segmented Tabs ==================== */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  background: #ffffff;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.filters input, .filters select {
  width: auto;
  min-width: 140px;
  margin-top: 0;
  padding: 7.5px 11px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.filters input.search-input {
  min-width: 240px;
  flex: 1;
  background: #ffffff;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 18px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: none;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  transform: none;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

/* ==================== Data Tables & Person Cells ==================== */
.tablewrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  text-align: left;
  font-size: 13px;
}

th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text-secondary);
}

tbody tr {
  transition: background-color 0.12s ease;
}

tbody tr:hover td {
  background: #f8faff;
}

td small {
  display: block;
  color: var(--text-light);
  font-size: 11.5px;
  margin-top: 2px;
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e0e7ff, #dbeafe);
  color: #1d4ed8;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #bfdbfe;
}

/* ==================== Status Pills & Chips ==================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3.5px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill.待确认, .pill.待核对 {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
}

.pill.已确认, .pill.上游已确认, .pill.正常, .pill.在岗, .pill.进行中 {
  background: var(--emerald-soft);
  color: var(--emerald);
  border-color: var(--emerald-border);
}

.pill.草稿, .pill.已归档 {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

.pill.已退回, .pill.已作废, .pill.停用, .pill.离岗 {
  background: var(--rose-soft);
  color: var(--rose);
  border-color: var(--rose-border);
}

.tag {
  display: inline-block;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
}

.hash-badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 2px 7px;
}

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-light);
}

/* ==================== Cards Grid (Bills & Team) ==================== */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.personcard {
  padding: 22px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.personcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.personcard h2 {
  margin: 12px 0 8px;
  font-size: 16.5px;
}

/* ==================== Modern Modal Dialog ==================== */
.modern-modal {
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-lg);
  width: 960px;
  max-width: 95vw;
  max-height: 90vh;
  padding: 0;
  box-shadow: var(--shadow-modal);
  color: var(--text-main);
  background: #ffffff;
}

.modern-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.modalbody {
  padding: 24px 26px;
  max-height: calc(90vh - 135px);
  overflow-y: auto;
}

.modalfoot {
  border-top: 1px solid var(--border);
  padding: 15px 26px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==================== Forms & Interactive Sheet ==================== */
.formgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.formgrid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

label.field {
  display: block;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

input, select, textarea {
  display: block;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8.5px 12px;
  background: #ffffff;
  color: var(--text-main);
  margin-top: 5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

input:disabled, select:disabled {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.sheet {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.sheet th {
  padding: 10px 12px;
  font-size: 12px;
}

.sheet td {
  padding: 7px 9px;
}

.sheet input, .sheet select {
  min-width: 78px;
  padding: 6.5px 9px;
  margin-top: 0;
}

.sheet .wide {
  min-width: 230px;
}

/* ==================== Signature Canvas ==================== */
.sign {
  border: 1.5px dashed #94a3b8;
  background-color: #f8fafc;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 16px 16px;
  border-radius: 10px;
  width: 100%;
  height: 135px;
  touch-action: none;
  margin-top: 6px;
  cursor: crosshair;
}

.sigimg {
  height: 78px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 6px 10px;
  box-shadow: var(--shadow-sm);
}

/* ==================== Printable Statement Paper ==================== */
.paper {
  max-width: 940px;
  background: #ffffff;
  margin: 18px auto;
  padding: 48px 56px;
  border: 1px solid #cbd5e1;
  border-top: 5px solid #1e3a8a;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  position: relative;
}

.paper h1 {
  text-align: center;
  font-size: 24px;
  font-weight: 750;
  margin-bottom: 14px;
  color: #0f172a;
}

.paper .meta {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #1e293b;
  padding: 14px 0;
  font-size: 13px;
  color: #334155;
}

.paper [contenteditable="true"] {
  min-height: 76px;
  outline: none;
  border: 1.5px dashed #93c5fd;
  background: #f8faff;
  padding: 14px 16px;
  margin: 14px 0;
  border-radius: 8px;
  color: var(--text-main);
}

.paper [contenteditable="false"] {
  min-height: 60px;
  border: 1px solid var(--border);
  background: #f8fafc;
  padding: 14px 16px;
  margin: 14px 0;
  border-radius: 8px;
}

.paper table {
  white-space: normal;
  border: 1px solid #cbd5e1;
  margin-top: 12px;
}

.paper th, .paper td {
  border: 1px solid #cbd5e1;
  padding: 10px 14px;
}

.sign-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px dashed #cbd5e1;
}

.sign-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

/* ==================== Activity Timeline & Footer ==================== */
.activity {
  border-left: 2px solid #bfdbfe;
  margin: 16px 8px;
  padding-left: 18px;
}

.activity p {
  font-size: 12.5px;
  margin: 10px 0;
  color: #475569;
  position: relative;
}

.activity p::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  position: absolute;
  left: -23px;
  top: 6px;
  border: 2px solid #ffffff;
}

.page-footer {
  padding: 16px 36px;
  font-size: 12px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-meta {
  display: flex;
  gap: 8px;
}

.modern-toast {
  position: fixed;
  bottom: 32px;
  left: 55%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 99px;
  display: none;
  z-index: 100;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.3);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.check {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.warn {
  font-size: 12.5px;
  color: var(--amber);
  margin: 10px 0;
}

/* ==================== Online Document Workspace (#docs & Rich Editor) ==================== */
.doc-workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

.doc-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.doc-list {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-list-item {
  padding: 12px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-subtle);
}

.doc-list-item:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.doc-list-item.active {
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.doc-item-title {
  font-weight: 650;
  color: var(--text-main);
  font-size: 13.5px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.doc-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.doc-editor-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.doc-title-input {
  font-size: 21px !important;
  font-weight: 750 !important;
  border: 0 !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  border-radius: 0 !important;
  padding: 18px 24px !important;
  margin: 0 !important;
  background: #ffffff !important;
  color: var(--text-main) !important;
}

.doc-title-input:focus {
  box-shadow: none !important;
  background: #f8faff !important;
}

.doc-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 12.5px;
}

.doc-meta-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 500;
}

.doc-meta-bar input, .doc-meta-bar select {
  width: auto;
  margin-top: 0;
  padding: 5px 9px;
  font-size: 12.5px;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 9px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.tool-btn {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #dbe2ec;
  color: var(--text-secondary);
  font-weight: 600;
  box-shadow: none;
}

.tool-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  transform: none;
}

.tool-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
}

.rich-editor {
  min-height: 360px;
  padding: 24px 28px;
  outline: none;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text-main);
  background: #ffffff;
}

.rich-editor.compact {
  min-height: 170px;
  max-height: 280px;
  overflow-y: auto;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.rich-toolbar.compact-bar {
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  margin-top: 5px;
}

.rich-editor h2 {
  font-size: 17px;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
  margin: 18px 0 10px;
}

.rich-editor h3 {
  font-size: 15px;
  color: #1e293b;
  margin: 14px 0 8px;
}

.rich-editor ul, .rich-editor ol {
  padding-left: 22px;
  margin: 8px 0;
}

.rich-editor li {
  margin: 4px 0;
}

.rich-editor code {
  background: #f1f5f9;
  color: #be123c;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
}

.rich-editor table {
  border: 1px solid #cbd5e1;
  margin: 12px 0;
  white-space: normal;
}

.rich-editor th, .rich-editor td {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
}

/* ==================== Modal Embedded OnlyOffice Editor & Fullscreen ==================== */
.modal-oo-wrap {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.modal-oo-target-box {
  height: 360px;
  width: 100%;
  background: #ffffff;
  position: relative;
}

.modal-oo-wrap.fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
  border: 0 !important;
  margin: 0 !important;
}

.modal-oo-wrap.fullscreen .modal-oo-target-box {
  flex: 1;
  height: 100vh !important;
}

/* ==================== 2FA Two-Factor Authentication Styles ==================== */
.otp-digit-grid {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
}

.otp-digit-input {
  width: 48px !important;
  height: 54px !important;
  text-align: center;
  font-size: 22px !important;
  font-weight: 800;
  font-family: ui-monospace, Consolas, monospace;
  border: 2px solid #cbd5e1 !important;
  border-radius: 10px !important;
  background: #f8fafc !important;
  color: #0f172a !important;
  padding: 0 !important;
  transition: all 0.15s ease;
}

.otp-digit-input:focus {
  border-color: #2563eb !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15) !important;
  transform: translateY(-1px);
}

.twofa-qr-card {
  display: flex;
  gap: 20px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 18px;
}

.twofa-gate-card {
  max-width: 520px;
  margin: 40px auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.twofa-demo-banner {
  background: #eff6ff;
  border: 1px dashed #60a5fa;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #1e3a8a;
}

/* ==================== System Settings Tree Navigation Layout ==================== */
.settings-tree-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.settings-tree-sidebar {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: sticky;
  top: 78px;
}

.settings-tree-head {
  padding: 14px 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-tree-head strong {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.settings-tree-head span {
  font-size: 11px;
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.28);
  padding: 2px 7px;
  border-radius: 99px;
}

.settings-tree-body {
  padding: 10px;
}

.tree-group {
  margin-bottom: 6px;
}

.tree-group:last-child {
  margin-bottom: 0;
}

.tree-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: none;
  background: #f8fafc;
  border-radius: 8px;
  color: #1e293b;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.tree-group-header:hover {
  background: #f1f5f9;
  border-color: transparent;
}

.tree-group-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tree-arrow {
  font-size: 10px;
  color: #64748b;
  transition: transform 0.18s ease;
  display: inline-block;
}

.tree-group.open .tree-arrow {
  transform: rotate(90deg);
}

.tree-children {
  margin-left: 15px;
  padding-left: 11px;
  border-left: 1.5px dashed #cbd5e1;
  margin-top: 4px;
  display: none;
  flex-direction: column;
  gap: 3px;
}

.tree-group.open .tree-children {
  display: flex;
}

.tree-node-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7.5px 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  color: #475569;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: all 0.15s ease;
}

.tree-node-btn::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 50%;
  width: 9px;
  height: 1.5px;
  background: #cbd5e1;
}

.tree-node-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: transparent;
}

.tree-node-btn.active {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  font-weight: 700;
}

.tree-node-btn.active::before {
  background: #2563eb;
}

.tree-node-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  background: #e2e8f0;
  color: #334155;
  flex-shrink: 0;
}

.tree-node-btn.active .tree-count-badge {
  background: #2563eb;
  color: #ffffff;
}

.tree-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.settings-tree-main {
  min-width: 0;
}

.settings-panel-bar {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.settings-panel-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}

.settings-panel-crumb strong {
  color: #0f172a;
  font-size: 15px;
}

/* ==================== Responsive & Print ==================== */
@media (max-width: 1100px) {
  .sidebar { width: 215px; }
  .main-area { margin-left: 215px; }
  .page-content { padding: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid, .grid-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 14px;
  }
  .workspace-card, .nav-group-label, .sidebar-footer { display: none; }
  .sidenav { flex-direction: row; overflow-x: auto; gap: 6px; margin-top: 10px; }
  .sidenav a { white-space: nowrap; padding: 8px 12px; font-size: 12.5px; border-left: 0; }
  .main-area { margin-left: 0; }
  .topbar { padding: 10px 16px; height: auto; flex-wrap: wrap; gap: 8px; }
  .role-Indicator { display: none; }
  .page-content { padding: 16px; }
  .heading { flex-direction: column; align-items: flex-start; }
  .stats, .cards, .formgrid, .formgrid-2, .sign-boxes { grid-template-columns: 1fr; }
  .paper { padding: 22px; }
  .page-footer { flex-direction: column; gap: 6px; text-align: center; }
}

@media print {
  .sidebar, .topbar, .page-footer, .heading, .filters, .notice, .noprint, button {
    display: none !important;
  }
  .main-area { margin: 0; }
  .page-content { padding: 0; }
  .paper {
    border: 0;
    box-shadow: none;
    margin: 0;
    padding: 10px;
    max-width: none;
  }
  body { background: #ffffff; }
}
