@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Fira+Code:wght@400;500;700&display=swap');

:root {
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-base: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, monospace;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-panel: #0f172a;
  --bg-darker: #020617;
  --ir-crimson: #881337;
  --ir-crimson-light: #fff1f2;
  --ir-crimson-border: #fecdd3;
  --ir-gold: #d97706;
  --ir-gold-hover: #b45309;
  --ir-gold-light: #fef3c7;
  --ir-gold-border: #fde68a;
  --text-title: #0f172a;
  --text-main: #334155;
  --text-muted: #64748b;
  --text-light: #cbd5e1;
  --border-light: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --radius-sm: 6px;
  --radius-md: 12px;
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-base);
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.34);
  border-radius: 4px;
}

header {
  background-color: var(--bg-panel);
  background-image:
    linear-gradient(135deg, rgba(136, 19, 55, 0.35) 0%, transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(217, 119, 6, 0.15) 0%, transparent 40%);
  color: #ffffff;
  border-bottom: 4px solid var(--ir-gold);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 820px) {
  .header-container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

.ir-emblem {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  border: 2px solid var(--ir-gold);
  background: radial-gradient(circle, var(--ir-crimson) 0%, #4c0519 100%);
  color: var(--ir-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.4);
}

.ir-emblem svg {
  width: 28px;
  height: 28px;
}

.gyaanvaapi-mark {
  background: #ffffff;
  color: var(--ir-crimson);
  overflow: hidden;
  padding: 7px;
}

.gyaanvaapi-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-info {
  min-width: 0;
}

.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fcd34d;
  background: rgba(217, 119, 6, 0.2);
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: 4px;
  padding: 2px 8px;
}

.meta-time {
  color: var(--text-light);
  font-family: var(--font-mono);
  font-size: 10px;
}

.brand-info h1 {
  margin-top: 2px;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-info p {
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1rem;
  min-width: 0;
}

.meta-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 30px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dot,
.status-green-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  max-width: 100%;
  background: var(--bg-darker);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.tab-btn {
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-light);
  padding: 0 1rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  transition: var(--transition);
}

.tab-btn:hover {
  color: #ffffff;
}

.tab-btn.active {
  background: var(--ir-gold);
  color: #000000;
}

main {
  width: 100%;
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

.summaryGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.statCard {
  min-height: 95px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
}

.statCard span {
  display: block;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.statCard strong {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-title);
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1080px) {
  .dashboard-grid {
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  }
}

.sidebar-wrapper {
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 620px;
  height: calc(100vh - 205px);
  position: sticky;
  top: 112px;
}

.search-box {
  margin-bottom: 1rem;
}

.search-control {
  position: relative;
  display: block;
}

.search-control svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-control input {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  outline: none;
  color: var(--text-title);
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  font-size: 0.88rem;
  transition: var(--transition);
}

.search-control input:focus {
  border-color: var(--ir-crimson);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--ir-crimson-light);
}

.filter-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  overflow: visible;
  max-width: 100%;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.filter-select select,
.modeButtons button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: #f1f5f9;
  color: var(--text-main);
  padding: 0 0.9rem;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.modeButtons {
  display: flex;
  gap: 0.5rem;
}

.modeButtons button.active {
  background: var(--ir-crimson);
  color: #ffffff;
}

.sidebar-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.record-list-scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.record-item {
  width: 100%;
  border: 1px solid #f1f5f9;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  text-align: left;
  transition: var(--transition);
}

.record-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.record-item.active {
  background: var(--ir-crimson-light);
  border-color: var(--ir-crimson-border);
}

.record-item span {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.record-item b {
  color: var(--text-title);
  font-family: var(--font-display);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-item small {
  color: var(--text-muted);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-item em {
  flex: 0 0 auto;
  border: 1px solid var(--ir-gold-border);
  border-radius: 4px;
  background: var(--ir-gold-light);
  color: var(--ir-gold-hover);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.emptyList,
.emptyState {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.workspace-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.profile-card,
.table-card {
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.profile-card-header,
.table-card-head {
  border-bottom: 1px solid var(--border-light);
  background-image: linear-gradient(180deg, #f8fafc, #ffffff);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

.profile-main-title {
  min-width: 0;
}

.profile-code-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

#activeRecordTitle {
  min-width: 0;
  color: var(--text-title);
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.profile-desc {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.p-tag {
  border-radius: 20px;
  padding: 0.28rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.p-tag-accent {
  background: var(--ir-crimson-light);
  color: var(--ir-crimson);
  border: 1px solid var(--ir-crimson-border);
}

.refreshButton {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--ir-gold);
  color: #000000;
  padding: 0 1rem;
  font-weight: 900;
}

.profile-body {
  padding: 1.5rem;
}

.metrics-row-large {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 720px) {
  .metrics-row-large {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.metric-card-large {
  position: relative;
  overflow: hidden;
  border: 1px solid #f1f5f9;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  padding: 1rem;
}

.metric-lbl {
  display: block;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric-val {
  margin-top: 0.25rem;
  color: var(--text-title);
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.metric-unit {
  color: var(--text-muted);
  font-family: var(--font-base);
  font-size: 0.72rem;
  font-weight: 800;
  margin-left: 0.2rem;
  text-transform: uppercase;
}

.metric-decor-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--ir-gold);
}

.metric-card-large:nth-child(2) .metric-decor-bar { background: #10b981; }
.metric-card-large:nth-child(3) .metric-decor-bar { background: var(--ir-crimson); }
.metric-card-large:nth-child(4) .metric-decor-bar { background: #3b82f6; }

.remarks-view-sheet {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  padding: 1rem;
}

.remarks-view-sheet h4 {
  color: var(--text-title);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.remarks-view-sheet p {
  color: var(--text-main);
  font-size: 0.84rem;
}

.table-card-head h2 {
  color: var(--text-title);
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.table-card-head p {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.tableShell {
  width: 100%;
  max-width: 100%;
  max-height: 520px;
  overflow: auto;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 0.9rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.8rem;
  max-width: 320px;
  overflow-wrap: anywhere;
  word-break: normal;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr:hover {
  background: #fff7ed;
}

.phoneLink {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid var(--ir-gold-border);
  border-radius: 20px;
  background: var(--ir-gold-light);
  color: var(--ir-gold-hover);
  margin: 0 4px 4px 0;
  padding: 2px 8px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

footer {
  width: 100%;
  max-width: 1400px;
  margin: 2rem auto 1.5rem;
  padding: 0 1.5rem;
}

.footer-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

@media (max-width: 900px) {
  main,
  footer {
    padding: 0 1rem;
  }

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

  .sidebar-wrapper {
    position: static;
    height: auto;
    min-height: 420px;
  }

  .tableShell {
    max-height: none;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    border-collapse: collapse;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8fafc;
  }

  tbody tr {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  tbody tr:nth-child(even),
  tbody tr:hover {
    background: #ffffff;
  }

  td {
    display: grid;
    grid-template-columns: minmax(96px, 30%) minmax(0, 1fr);
    gap: 0.75rem;
    max-width: none;
    border-bottom: 1px solid #eef2f7;
    padding: 0.7rem 0.8rem;
    font-size: 0.78rem;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}

@media (max-width: 620px) {
  .header-container {
    padding: 0.9rem 1rem;
  }

  .brand-section,
  .header-actions,
  .profile-card-header,
  .footer-container {
    align-items: flex-start;
  }

  .brand-section,
  .header-actions,
  .profile-card-header,
  .footer-container,
  .table-card-head {
    width: 100%;
    min-width: 0;
  }

  .header-actions,
  .profile-card-header,
  .footer-container,
  .table-card-head {
    flex-direction: column;
  }

  .brand-section {
    gap: 0.75rem;
  }

  .ir-emblem {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .brand-info h1,
  #activeRecordTitle {
    font-size: 1.35rem;
  }

  .summaryGrid,
  .metrics-row-large {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    width: 100%;
  }

  .tab-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 0 0.5rem;
  }

  main {
    margin-top: 1rem;
    padding: 0 0.75rem;
  }

  .profile-card-header,
  .profile-body,
  .table-card-head,
  .sidebar-wrapper {
    padding: 1rem;
  }

  td {
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
  }
}
