:root {
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --brand-soft: #eff6ff;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --accent: #6366f1;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  z-index: 1001;
}

.sidebar-brand {
  padding: 0 24px 32px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s;
}

.sidebar-nav a i, 
.sidebar-nav a svg {
  width: 18px;
  height: 18px;
}

.sidebar-nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.sidebar-nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.sidebar-footer {
  padding: 24px;
  border-top: 1px solid var(--line);
}

.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  border: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
}


.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
}

.topnav-left,
.topnav-right,
.mainnav,
.subnav,
.toolbar,
.page-actions,
.footer-links,
.inline-actions,
.action-buttons,
.pagination,
.stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topnav-right {
  justify-content: flex-end;
}

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

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper i {
  position: absolute;
  left: 12px;
  width: 16px;
  color: var(--muted);
}

.search-input {
  width: 280px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 14px 0 38px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s;
}

.search-input:focus {
  background: #fff;
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.user-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--line);
  padding-left: 16px;
  margin-left: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  padding: 8px;
  z-index: 2000;
}

.user-dropdown.show {
  display: flex;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.user-dropdown a, 
.user-dropdown button {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  transition: all 0.2s;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
}

.user-dropdown a:hover, 
.user-dropdown button:hover {
  background: var(--bg-soft);
  color: var(--brand);
}

.user-dropdown .divider {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}


.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-new {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.brand-icon-new i {
  width: 20px;
  height: 20px;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-title span {
  font-weight: 400;
  color: var(--muted);
}

.brand-title small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
  margin-top: -2px;
}

.mainnav {
  display: flex;
  gap: 8px;
  margin-left: 12px;
}

.mainnav a {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s;
}

.mainnav a:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.mainnav a.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.subnav {
  margin-bottom: 18px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}

.subnav a {
  padding: 9px 14px;
  border-radius: 999px;
  color: #314155;
  white-space: nowrap;
}

.subnav a.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}

.search-input {
  width: 232px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(180deg, #cfd7e4, #9aa8bb);
}

.btn.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1e293b;
  transition: all 0.2s;
  cursor: pointer;
}

.btn.icon-btn i, 
.btn.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  margin: 0;
}

.icon-btn:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.page {
  padding: 24px 26px 32px;
}

.page--two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 324px;
  gap: 28px;
}

.page-inner {
  max-width: 1400px; /* Increased from 1200px for better split-view */
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 20px;
}

.breadcrumb {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.page-header h1,
.headline h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.page-header p,
.headline p,
.muted,
.screen-caption {
  margin: 8px 0 0;
  color: var(--muted);
}

.headline {
  margin-bottom: 20px;
}

.panel,
.metric-card,
.list-table,
.side-panel,
.upload-box,
.auth-card,
.note-box,
.flash {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
  margin-bottom: 22px;
}

.section-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.section-block h3,
.panel h2,
.panel h3,
.side-panel h3,
.side-panel h4 {
  margin: 0;
}

.panel-title,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.premium-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  margin-bottom: 18px;
  background: linear-gradient(180deg, #f8f5ee, #f4efe4);
  border: 1px solid var(--gold-line);
  border-radius: 14px;
}

.premium-strip strong {
  display: block;
}

.premium-strip span {
  color: var(--muted);
}

.metric-grid,
.cards-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 20px;
}

.cards-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.equal-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.two {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

.metric-card {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-icon i {
  width: 24px;
  height: 24px;
}

.metric-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-card .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-card .value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.metric-card .value small {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.metric-card .sub {
  font-size: 12px;
  color: var(--muted);
}

.chart,
.line-chart,
.mini-chart {
  border-radius: 12px;
  border: 1px solid #e5ebf3;
  position: relative;
  overflow: hidden;
}

.line-chart {
  height: 282px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 253, 0.96)),
    repeating-linear-gradient(180deg, transparent, transparent 50px, rgba(41, 74, 123, 0.08) 50px, rgba(41, 74, 123, 0.08) 51px);
}

.line-chart::before {
  content: "";
  position: absolute;
  left: 28px;
  right: 24px;
  top: 52px;
  bottom: 28px;
  background: linear-gradient(180deg, rgba(45, 111, 189, 0.12), rgba(45, 111, 189, 0.02));
  clip-path: polygon(0 86%, 8% 76%, 18% 65%, 30% 55%, 43% 54%, 56% 46%, 70% 32%, 82% 24%, 92% 20%, 100% 8%, 100% 100%, 0 100%);
}

.line-chart::after {
  content: "";
  position: absolute;
  left: 28px;
  right: 24px;
  top: 52px;
  bottom: 28px;
  border-top: 3px solid var(--brand);
  background: transparent;
  clip-path: polygon(0 86%, 8% 76%, 18% 65%, 30% 55%, 43% 54%, 56% 46%, 70% 32%, 82% 24%, 92% 20%, 100% 8%);
}

.chart-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 22px;
}

.mini-chart {
  height: 230px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 253, 0.96)),
    repeating-linear-gradient(180deg, transparent, transparent 42px, rgba(41, 74, 123, 0.06) 42px, rgba(41, 74, 123, 0.06) 43px);
}

.mini-chart.bars::before {
  content: "";
  position: absolute;
  inset: auto 18px 18px 18px;
  height: 140px;
  background:
    linear-gradient(180deg, rgba(46, 103, 177, 0.84), rgba(46, 103, 177, 0.84)) 0 100%/12% 52% no-repeat,
    linear-gradient(180deg, rgba(46, 103, 177, 0.84), rgba(46, 103, 177, 0.84)) 17% 100%/12% 66% no-repeat,
    linear-gradient(180deg, rgba(46, 103, 177, 0.84), rgba(46, 103, 177, 0.84)) 34% 100%/12% 74% no-repeat,
    linear-gradient(180deg, rgba(46, 103, 177, 0.84), rgba(46, 103, 177, 0.84)) 51% 100%/12% 58% no-repeat,
    linear-gradient(180deg, rgba(46, 103, 177, 0.84), rgba(46, 103, 177, 0.84)) 68% 100%/12% 83% no-repeat,
    linear-gradient(180deg, rgba(46, 103, 177, 0.84), rgba(46, 103, 177, 0.84)) 85% 100%/12% 64% no-repeat;
}

.mini-chart.donut::before {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  left: calc(50% - 75px);
  top: 36px;
  background: conic-gradient(#2e67b1 0 34%, #6ca0df 34% 58%, #d9bc72 58% 82%, #d8e3f3 82% 100%);
}

.mini-chart.donut::after {
  content: "";
  position: absolute;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  left: calc(50% - 41px);
  top: 70px;
  background: #fff;
  border: 1px solid var(--line);
}

.table,
.activity-table,
.kpi-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td,
.activity-table th,
.activity-table td,
.kpi-table th,
.kpi-table td,
.data-table th,
.data-table td {
  text-align: left;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.data-table thead th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.sortable-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
    user-select: none;
    cursor: pointer;
}

.sortable-link:hover {
    color: var(--brand);
}

.sortable-link i {
    width: 14px;
    height: 14px;
    opacity: 0.5;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.sortable-link:hover i {
    opacity: 1;
}

.sortable-link.active {
    color: var(--brand);
    font-weight: 700;
}

.sortable-link.active i {
    opacity: 1;
}

.activity-table td.time {
  color: var(--muted);
  width: 90px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 16px;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table, 
.table-wrap table {
  min-width: 900px;
}

.list-toolbar {
  display: grid;
  grid-template-columns: 180px 180px 180px 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
}

.select,
.text-input,
.cell-input,
.field input,
.field select,
.field textarea,
.search,
.search-input {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.select,
.text-input {
  height: 38px;
  padding: 0 12px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.field label {
  font-weight: 500;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.validation-summary-errors,
.field-validation-error {
  color: var(--danger);
  font-size: 13px;
}

.validation-summary-errors ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

.field .hint {
  color: var(--muted);
}

.filters,
.form-grid {
  display: grid;
  gap: 14px;
}

.role-nav-item {
  border: 1px solid transparent;
}

.role-nav-item:hover {
  background: rgba(37, 99, 235, 0.05) !important;
  color: var(--brand) !important;
}

.role-nav-item.active {
  background: var(--brand-soft) !important;
  border-color: var(--brand) !important;
}

.role-nav-item.active strong {
  color: var(--brand) !important;
}

.filters-bar {
  padding: 10px 16px;
  margin-bottom: 20px;
}

.filters-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 240px;
}

.filter-group i, 
.filter-group svg {
  position: absolute;
  left: 14px;
  pointer-events: none;
  color: var(--muted);
  width: 18px;
  height: 18px;
  z-index: 10;
}

.filter-group input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: all 0.2s;
}

.filter-group input:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.filter-select {
  height: 40px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  font-size: 14px;
  min-width: 160px;
  cursor: pointer;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.btn-icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

.btn-icon-only i {
  width: 18px;
  height: 18px;
}

.page-actions .btn {
  height: 38px;
  font-size: 14px;
  font-weight: 500;
}

.filters .search-input {
    flex: 1;
    min-width: 200px;
}

.filters .btn {
    min-width: auto;
    padding: 0 20px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-layout {
  display: grid !important;
  grid-template-columns: 1fr 280px !important; /* Fixed width for sidebar, flex for main */
  gap: 24px !important;
  align-items: flex-start !important;
  width: 100% !important;
}

.layout-main {
  min-width: 0 !important;
  overflow-x: auto !important; /* Tables can scroll here if they exceed their flex area */
  padding-bottom: 8px;
}

.side-stack {
  width: 100% !important; /* Fills its grid cell (280px) */
  position: sticky !important;
  top: 24px;
}

.side-panel {
  width: 100% !important;
  margin-bottom: 22px !important;
}

.layout-main {
  display: grid;
  gap: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.detail-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.detail-item label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-item strong {
  font-size: 16px;
}

.summary-box {
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--text);
  line-height: 1.6;
}

.mini-summary {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.mini-summary + .mini-summary {
  margin-top: 12px;
}

.mini-summary label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.action-stack {
  display: grid;
  gap: 10px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.step-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.step-card.active {
  border-color: #b8cce7;
  background: #f8fbff;
}

.step-index {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #edf2f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.step-card.active .step-index {
  background: var(--brand);
  color: #fff;
}

.alert-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 18px;
}

.alert-banner.success {
  background: #eefaf1;
  border: 1px solid #cae7d0;
}

.alert-banner.warning {
  background: #fff9ef;
  border: 1px solid #f3ddab;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table td,
.info-table th {
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.info-table th {
  color: var(--muted);
  font-weight: 600;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.side-panel {
  padding: 16px;
}

.side-panel.soft {
  background: linear-gradient(180deg, #f7f8fb 0%, #eef2f8 100%);
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.upload-box {
  border-style: dashed;
  padding: 18px;
  background: #fbfcfe;
}

.upload-files {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.file-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline {
  position: relative;
  display: grid;
  gap: 18px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #d5dfeb;
}

.timeline-item {
  position: relative;
  padding-left: 28px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #aac5e8;
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

.btn,
button.btn {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.btn.primary,
button.btn.primary {
  background: linear-gradient(180deg, #4d8cde, var(--brand));
  border-color: #4b82c9;
  color: #fff;
}

.btn.secondary,
button.btn.secondary {
  background: #f7f8fb;
}

.btn.ghost,
button.btn.ghost {
  background: #fff;
}

.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

.inline-form { display: inline; }

.note-box {
  padding: 16px;
}

.flash {
  margin-bottom: 16px;
  padding: 14px 16px;
}

.status {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.ok { background: var(--success-soft); color: #2e6d2e; }
.warn { background: var(--warn-soft); color: #8b5a06; }
.bad { background: var(--danger-soft); color: #973737; }
.neutral { background: #edf2f8; color: #314155; }

.status-new { background: #dceaf9; color: #325f94; }
.status-contacted { background: var(--success-soft); color: #2e6d2e; }
.status-qualified { background: var(--warn-soft); color: #8b5a06; }
.status-converted { background: var(--purple-soft); color: #68408d; }
.status-lost { background: var(--danger-soft); color: #973737; }

.pager,
.split-actions,
.pagination {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.disabled-link {
  opacity: 0.45;
  pointer-events: none;
}

.sticky-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  min-height: 100vh;
  padding: 34px;
}

.auth-card {
  padding: 34px;
}

.auth-side {
  border-radius: 32px;
  padding: 36px;
  background: linear-gradient(135deg, rgba(46, 103, 177, 0.92), rgba(35, 79, 134, 0.88));
  color: #fff7f2;
  box-shadow: var(--shadow);
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
}

.stat-box {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.inline-entry-row {
  background: #fafcff;
}

@media (max-width: 1200px) {
  .page--two-col,
  .metric-grid,
  .cards-4,
  .cards-3,
  .equal-2,
  .two,
  .chart-grid-2,
  .list-toolbar,
  .filters,
  .form-grid.two,
  .form-grid.three,
  .form-layout,
  .detail-grid,
  .stepper,
  .upload-files,
  .stats-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .topnav,
  .topnav-left,
  .topnav-right {
    flex-wrap: wrap;
  }

  .mainnav {
    order: 3;
    width: 100%;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .search-input {
    width: 100%;
  }
}

/* Quick Actions & Interactive Stepper */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
    margin-bottom: 24px;
}

.qa-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.qa-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 12px 24px rgba(46, 103, 177, 0.08);
}

.qa-card.highlight {
    background: linear-gradient(135deg, #2e67b1, #1a4a8d);
    color: #fff;
    border: none;
}

.qa-card.highlight span {
    color: rgba(255, 255, 255, 0.8);
}

.qa-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.qa-card strong {
    font-size: 16px;
}

.qa-card span {
    font-size: 13px;
    color: var(--muted);
}

.step-card {
    position: relative;
}

.step-tip {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    opacity: 0;
    transition: all 0.2s;
    white-space: nowrap;
    pointer-events: none;
}

.step-card:hover .step-tip {
    opacity: 1;
    bottom: 8px;
}

.step-card.active {
    border-color: var(--primary);
    background: rgba(46, 103, 177, 0.02);
}

/* Chronological Notes */
.notes-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Custom Scrollbar for Notes */
.notes-container::-webkit-scrollbar {
    width: 6px;
}

.notes-container::-webkit-scrollbar-track {
    background: transparent;
}

.notes-container::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.notes-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.2);
}

.note-item {
    background: #fdfdfd;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
    transition: all 0.2s;
}

.note-item:hover {
    box-shadow: var(--shadow);
    border-color: var(--brand);
}

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

.note-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary);
}

.note-badge {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
}

.note-date {
    color: var(--muted);
    font-size: 12px;
}

.note-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
}

.note-footer {
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    margin-top: 16px;
}

.note-input-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    transition: all 0.2s;
}

.note-textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 103, 177, 0.1);
}

/* Premium Grid Enhancements */
.summary-row {
    background: var(--bg-soft);
    font-weight: 700;
}

.summary-row td {
    border-top: 2px solid var(--line-strong) !important;
    color: var(--text);
    padding: 14px 12px !important;
}

.filters-bar {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.filters-bar:hover {
    box-shadow: var(--shadow);
}

.filters-inline {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-group {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 280px;
}

.filter-group i {
    position: absolute;
    left: 14px;
    color: var(--muted);
    font-size: 18px;
    pointer-events: none;
}

.filter-group input {
    width: 100%;
    height: 44px;
    padding-left: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
    font-size: 14px;
    transition: all 0.2s;
}

.filter-group input:focus {
    background: #fff;
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 4px var(--brand-soft);
}

.filter-select {
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
    font-size: 14px;
    min-width: 180px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:hover {
    border-color: var(--line-strong);
}

.filter-select:focus {
    background: #fff;
    border-color: var(--brand);
    outline: none;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

.btn-icon-only {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--radius-md);
}

/* Dashboard Filter Styles */
.dashboard-filters {
    background: rgba(255, 255, 255, 0.6);
    padding: 8px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.dashboard-filters-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-icon {
    width: 16px;
    color: var(--muted);
    flex-shrink: 0;
}

.filter-select-minimal {
    height: 34px;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    min-width: 120px;
}

.filter-select-minimal:focus {
    outline: none;
    color: var(--brand);
}

.v-divider {
    width: 1px;
    height: 20px;
    background: var(--line);
}

.custom-date-inputs {
    display: flex;
    gap: 8px;
}

.filter-input-date {
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-soft);
    padding: 0 8px;
    font-size: 13px;
}

@media (max-width: 1100px) {
    .form-layout {
        flex-direction: column !important;
        display: flex !important;
        width: 100% !important;
    }

    .side-stack {
        width: 100% !important;
        min-width: 100% !important;
        position: static !important;
    }
    
    .layout-main {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 768px) {
    /* Fixed Sidebar for Mobile */
    .sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        z-index: 9999 !important;
        background: var(--surface) !important;
        box-shadow: var(--shadow-xl);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        display: flex !important;
    }

    .app-shell.sidebar-open .sidebar {
        left: 0 !important;
    }

    /* Critical Mobile Fix for Page-level Horizontal Scroll */
    body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    .app-shell {
        display: block !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-top: 64px !important; /* Space for fixed topbar */
    }

    .hide-mobile {
        display: none !important;
    }

    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
        margin-bottom: 24px !important;
    }

    .page-header h1 {
        font-size: 24px !important;
    }

    /* Topbar Fix */
    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 64px;
        z-index: 1000;
        padding: 0 16px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: rgba(255,255,255,0.9);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--line);
    }

    .menu-toggle {
        display: flex !important;
    }

    .topbar-right .user-lockup div[style*="font-weight: 500"] {
        display: none; /* Hide name on very small screens if needed */
    }

    .search-input-wrapper {
        display: none !important;
    }

    /* Page Content */
    .page {
        padding: 16px !important;
    }

    .page-header h1 {
        font-size: 20px !important;
    }

    /* Metrics & Grids */
    .metric-grid, .cards-4, .cards-3, .equal-2, .two, .chart-grid-2, .detail-grid {
        grid-template-columns: 1fr !important;
        width: 100% !important;
        gap: 16px !important;
    }

    /* Tabs (Subnav) */
    .subnav {
        display: flex !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        margin: 0 -16px 20px -16px !important;
        padding: 0 16px 12px 16px !important;
        border-bottom: 1px solid var(--line);
    }

    .subnav a {
        flex: 0 0 auto;
    }

    /* Calendar Controls */
    #calendar-container div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        gap: 12px;
    }

    .premium-strip {
        flex-direction: column !important;
        align-items: stretch !important;
    }
}

@media (max-width: 480px) {
    .metric-card {
        padding: 16px !important;
    }
}
