:root {
	--bg-main: #edf2f7;
	--bg-card: #ffffff;
	--bg-subtle: #f5f7fb;
	--border-soft: #d0d7e4;
	--text-main: #1f2933;
	--text-soft: #6b7280;
	--accent: #1e3a8a;
	--accent-soft: #e0e7ff;
	--accent-strong: #102a6b;
	--success: #166534;
	--danger: #b91c1c;
	--shadow-soft: 0 8px 16px rgba(15, 23, 42, 0.08);
}

* {
	box-sizing:border-box;
}

body {
	margin:0;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	background: var(--bg-main);
	color: var(--text-main);
}

h1 {
	background: linear-gradient(90deg, #0f172a, #1e3a8a);
	color:#fff;
	margin:0;
	padding:16px 20px;
	font-size:20px;
	font-weight:600;
	letter-spacing:0.02em;
	display:flex;
	align-items:center;
	gap:8px;
	box-shadow:0 4px 10px rgba(15,23,42,0.3);
}

h1::before {
	content:"⚖️";
	font-size:18px;
}

nav {
	display:flex;
	background:#0b1220;
	padding:0 10px;
	box-shadow:0 4px 10px rgba(15,23,42,0.25);
	position:relative;
	z-index:2;
}



nav button {
	flex:0 0 auto;
	min-width:120px;
	padding:10px 14px;
	margin:6px 6px 8px 6px;
	background:transparent;
	color:#cbd5f5;
	border:none;
	border-radius:999px;
	cursor:pointer;
	font-size:13px;
	display:flex;
	align-items:center;
	justify-content:center;
	gap:6px;
	transition:background 0.15s, color 0.15s, transform 0.1s;
}

nav button span.icon {
	font-size:14px;
}

nav button.active {
	background:#e5edff;
	color:#0b1120;
	transform:translateY(-1px);
}

nav button:not(.active):hover {
	background:rgba(148,163,184,0.2);
}

.container {
	height:calc(100vh - 112px);
	display:flex;
	flex-direction:column;
	padding:14px 16px 16px 16px;
}

.tab { display:none; height:100%; }


/* Update this rule to ensure the tab takes the specific calculated height */
.tab.active {
    display: flex;
    flex-direction: column;
    /* FIX: Use !important to override any '100%' conflicts */
    height: calc(100vh - 112px) !important; 
}

.app-shell {
	display:flex;
	flex:1;
	min-height:0;
	gap:14px;
	overflow:hidden; /* ensure internal panels scroll independently */
}


.card {
	background:var(--bg-card);
	border-radius:12px;
	border:1px solid var(--border-soft);
	box-shadow:var(--shadow-soft);
	padding:14px 16px;
	display:flex;
	flex-direction:column;
	min-height:0;
}

.card-header {
	display:flex;
	align-items:center;
	justify-content:space-between;
	margin-bottom:8px;
	gap:8px;
}

.card-title {
	font-size:14px;
	font-weight:600;
	color:var(--accent-strong);
}

.card-subtitle {
	font-size:11px;
	color:var(--text-soft);
}


/* Ensure the card container fills the column height */
.left-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;       /* <--- Forces the card to fill the available vertical space */
    min-height: 0;
    overflow: hidden;
}

/* Make the internal panel scrollable */
#leftPanel {
    flex: 1;            /* Grow to fill remaining space inside the card */
    overflow-y: auto;   /* Scroll only this element */
    min-height: 0;      /* Allow shrinking if needed */
    padding-right: 6px; /* Space for scrollbar */
    /* Remove 'height: 0' if you added it previously! */
}

/* Optional: Keep the styled scrollbar */
#leftPanel::-webkit-scrollbar {
    width: 6px;
}
#leftPanel::-webkit-scrollbar-track {
    background: transparent;
}
#leftPanel::-webkit-scrollbar-thumb {
    background-color: var(--border-soft);
    border-radius: 10px;
}
#leftPanel::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-soft);
}

/* Right side in Builder */
.right {
	flex:1;
	display:flex;
	gap:14px;
	min-width:0;
}

/* Add semantic classes for columns */
.col {
	flex:1;
	min-width:0;
	overflow-y:auto;
}

.col.enquiries { flex:1; }
.col.responses { flex:1; }

/* When responses are collapsed */
.builder-responses-collapsed .col.responses {
	display:none;
}

.builder-responses-collapsed .col.enquiries {
	flex:1 1 100%;
}

/* Attribute groups and labels */
details {
	margin-bottom:10px;
	border-radius:10px;
	border:1px solid var(--border-soft);
	background:var(--bg-subtle);
	padding:6px 8px;
}

summary {
	cursor:pointer;
	font-weight:600;
	color:var(--accent-strong);
	font-size:13px;
}

summary::-webkit-details-marker {
	display:none;
}

summary::before {
	content:"▸";
	display:inline-block;
	margin-right:5px;
	font-size:10px;
	transform:translateY(-1px);
}

details[open] summary::before {
	content:"▾";
}

.attribute-label {
	display:flex;
	align-items:center;
	margin:3px 0;
	padding:4px 6px;
	border-radius:6px;
	gap:6px;
	font-size:12px;
	color:var(--text-main);
	background:transparent;
	transition:background 0.12s, color 0.12s, transform 0.08s, box-shadow 0.12s;
}

.attribute-label input {
	margin:0;
}

.attribute-label:hover {
	background:var(--accent-soft);
	color:var(--accent-strong);
	transform:translateX(2px);
	box-shadow:0 2px 4px rgba(15,23,42,0.12);
}

.helper-text {
	font-size:11px;
	color:var(--text-soft);
	margin-top:4px;
}

/* Enquiries / Responses */
#enqCol, #advCol {
	margin-top:4px;
	font-size:13px;
}

#enqCol ol, #advCol ol {
	padding-left:18px;
	margin:4px 0 0 0;
}

#advCol ol li {
	margin-bottom:10px;
	padding-bottom:6px;
}
.advice-block {
	padding:8px 9px;
	margin:4px 0;
	border-radius:8px;
	background:#eef2ff;
	border-left:4px solid var(--accent);
	font-size:12px;
}

.advice-good {
	background:#ecfdf3;
	border-left-color:var(--success);
}

.advice-bad {
	background:#fef2f2;
	border-left-color:var(--danger);
}

/* Buttons */
button.action {
	background:var(--accent);
	color:#f9fafb;
	border:none;
	padding:7px 14px;
	cursor:pointer;
	margin-bottom:8px;
	border-radius:999px;
	font-size:12px;
	font-weight:500;
	display:inline-flex;
	align-items:center;
	gap:6px;
	box-shadow:0 4px 10px rgba(15,23,42,0.25);
	transition:background 0.15s, transform 0.08s, box-shadow 0.15s;
}

button.action::before {
	content:"📋";
	font-size:13px;
}

button.action:hover {
	background:#1d4ed8;
	transform:translateY(-1px);
	box-shadow:0 6px 14px rgba(15,23,42,0.3);
}

button.action:active {
	transform:translateY(0);
	box-shadow:0 3px 8px rgba(15,23,42,0.25);
}

/* Small secondary button (for hide) */
button.text-button {
	background:none;
	border:none;
	color:var(--text-soft);
	font-size:11px;
	cursor:pointer;
	display:inline-flex;
	align-items:center;
	gap:4px;
	padding:3px 6px;
	border-radius:999px;
	transition:background 0.12s, color 0.12s;
}

button.text-button:hover {
	background:#e5edff;
	color:var(--accent-strong);
}

button.text-button span.icon {
	font-size:13px;
}

/* Responses vertical ribbon (collapsed state) */
#responsesRibbon {
	position:fixed;
	top:50%;
	right:0;
	transform:translateY(-50%);
	background:var(--accent);
	color:#e5edff;
	padding:10px 4px;
	border-radius:12px 0 0 12px;
	box-shadow:0 6px 16px rgba(15,23,42,0.45);
	cursor:pointer;
	font-size:11px;
	font-weight:600;
	letter-spacing:0.12em;
	text-transform:uppercase;
	display:none;
	align-items:center;
	justify-content:center;
	writing-mode:vertical-rl;
	text-orientation:mixed;
	z-index:5;
}

#responsesRibbon span.icon {
	font-size:14px;
	margin-bottom:4px;
}

.builder-responses-collapsed #responsesRibbon {
	display:flex;
}

/* Only show ribbon on Builder tab */
#tabMatcher.active ~ #responsesRibbon,
#tabData.active ~ #responsesRibbon {
	display:none;
}
/* Ensure matcher columns align vertically */
#tabMatcher .app-shell {
	align-items: stretch;
}

#tabMatcher .card {
	display: flex;
	flex-direction: column;
}

#tabMatcher textarea,
#tabMatcher .match-output {
	flex: 1;
}
#tabMatcher .card-header {
	align-items: center;
}
/* BSA output sections */
.bsa-section {
	margin-bottom: 24px;
}

.bsa-section h3,
.bsa-section h4 {
	margin-bottom: 8px;
	font-weight: 600;
}
#bsaRegime {
	background: #ffffff;
	border: 1px solid #dcdfe6;
	border-radius: 6px;
	padding: 16px;
}

#bsaRegime ul {
	margin: 0;
	padding-left: 18px;
}

#bsaRegime li {
	margin-bottom: 10px;
	font-weight: 500;
}
#bsaRegime small,
#bsaDocs small,
#bsaAdvice small {
	display: block;
	margin-top: 4px;
	color: #666;
	font-size: 0.8rem;
}
#bsaDocs {
	background: #f9fafc;
	border: 1px dashed #cfd6e4;
	border-radius: 6px;
	padding: 14px 16px;
}

#bsaDocs li {
	margin-bottom: 8px;
}
#bsaDocs {
	background: #f9fafc;
	border: 1px dashed #cfd6e4;
	border-radius: 6px;
	padding: 14px 16px;
}

#bsaDocs li {
	margin-bottom: 8px;
}
#bsaDocs li::marker {
	content: "📄 ";
}
#bsaAdvice {
	background: #eef6ff;
	border-left: 4px solid #3b82f6;
	padding: 16px;
	border-radius: 6px;
}

#bsaAdvice li {
	font-weight: 500;
	margin-bottom: 8px;
}

/* Matcher */
#pasteBox {
	width:100%;
	height:350px;
	padding:10px 12px;
	box-sizing:border-box;
	border-radius:10px;
	border:1px solid var(--border-soft);
	font-size:13px;
	resize:vertical;
	background:#f9fafb;
}

#pasteBox:focus {
	outline:none;
	border-color:var(--accent);
	box-shadow:0 0 0 2px rgba(59,130,246,0.25);
	background:#ffffff;
}

.match-output {
	font-size:13px;
	line-height:1.45;
	border-radius:10px;
	border:1px solid var(--border-soft);
	padding:10px 10px;
	background:var(--bg-subtle);
	min-height:350px;
	overflow-y:auto;
}

.match-item {
	margin-bottom:14px;
	padding:8px 8px 10px 8px;
	border-radius:8px;
	background:#ffffff;
	border:1px solid #e2e8f0;
	box-shadow:0 2px 6px rgba(15,23,42,0.1);
}

.match-item-header {
	font-size:12px;
	color:var(--text-soft);
	margin-bottom:4px;
	display:flex;
	align-items:center;
	justify-content:space-between;
	gap:6px;
}

.match-status {
	font-weight:600;
	font-size:11px;
	padding:2px 6px;
	border-radius:999px;
	white-space:nowrap;
}

.match-status.ok {
	color:var(--success);
	background:#dcfce7;
	border:1px solid #bbf7d0;
}

.match-status.bad {
	color:var(--danger);
	background:#fee2e2;
	border:1px solid #fecaca;
}

.match-item h4 {
	margin:5px 0 4px 0;
	color:var(--accent-strong);
	font-size:13px;
}

.match-pos, .match-neg {
	border-left:3px solid;
	padding:6px 8px;
	margin:4px 0;
	border-radius:6px;
	font-size:12px;
}

.match-pos {
	border-left-color:var(--success);
	background:#ecfdf3;
}

.match-neg {
	border-left-color:var(--danger);
	background:#fef2f2;
}

/* Data tab */
#dataTabInner {
	flex:1;
	display:flex;
	flex-direction:column;
	min-height:0;
}

#dataControls {
	margin-bottom:8px;
	display:flex;
	align-items:center;
	gap:8px;
}

#dataControls input {
	padding:5px 8px;
	border-radius:999px;
	border:1px solid var(--border-soft);
	font-size:12px;
	min-width:220px;
	background:#f9fafb;
}
#dataControls input:focus {
	outline:none;
	border-color:var(--accent);
	box-shadow:0 0 0 2px rgba(59,130,246,0.25);
	background:#ffffff;
}

#dataTableWrapper {
	flex:1;
	overflow:auto;
	border-radius:10px;
	border:1px solid var(--border-soft);
	background:#ffffff;
	box-shadow:var(--shadow-soft);
}

table {
	border-collapse:collapse;
	width:100%;
	font-size:12px;
}

th, td {
	border-bottom:1px solid #e5e7eb;
	padding:6px 8px;
	vertical-align:top;
}

th {
	background:#f1f5f9;
	position:sticky;
	top:0;
	z-index:2;
	cursor:pointer;
	font-weight:600;
	color:#111827;
}

th.sort-asc::after { content:" ▲"; font-size:10px; }
th.sort-desc::after { content:" ▼"; font-size:10px; }

.data-filter-row th {
	background:#e5e7eb;
	position:sticky;
	top:24px;
	z-index:1;
}

.data-filter-row input {
	width:100%;
	box-sizing:border-box;
	font-size:11px;
	padding:3px 4px;
	border-radius:6px;
	border:1px solid #d1d5db;
	background:#f9fafb;
}

tbody tr:nth-child(even) {
	background:#f9fafb;
}
tbody tr:hover {
	background:#e5edff;
}

.helper-pill {
	display:inline-flex;
	align-items:center;
	gap:3px;
	padding:2px 6px;
	border-radius:999px;
	background:#e0f2fe;
	color:#075985;
	font-size:10px;
}

.helper-pill span {
	font-size:11px;
}
/* Client updater alignment */
#tabUpdater label {
	display: grid;
	grid-template-columns: 260px 1fr;
	align-items: center;
	gap: 12px;
	margin-bottom: 8px;
}
