:root {
    --brand-color: #00aa7c;
    --brand-bg: #f0fdf4;
    --text-black: #000000;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
}

.country-page-wrapper {
    position: relative;
    min-height: 100vh;
    background-color: white;
    color: var(--text-black);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow-x: hidden;
    padding-top: 4rem;
    padding-bottom: 8rem;
}

.country-page-wrapper h1,
.country-page-wrapper h2,
.country-page-wrapper h3 {
    margin: 0;
}

/* Background Decorations */
.bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.bg-grid {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(var(--gray-100) 1px, transparent 1px),
        linear-gradient(90deg, var(--gray-100) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.4;
}

.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.08;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: var(--brand-color);
    top: -100px;
    right: -100px;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: var(--brand-color);
    bottom: -50px;
    left: -50px;
}

/* Main Content Container */
.country-content-container {
    position: relative;
    z-index: 10;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem;
}

.back-nav {
    margin-bottom: 2rem;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-600);
    text-decoration: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

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

/* Header Cards Grid */
.country-header-grid {
    display: grid;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (min-width: 1024px) {
    .country-header-grid {
        grid-template-columns: 1fr 300px;
    }
}

.header-card {
    background: white;
    border: 2px solid var(--gray-200);
    position: relative;
    overflow: hidden;
}

.header-info-card {
    padding: 2rem;
}

.header-card-decoration {
    position: absolute;
    bottom: -3rem;
    right: -3rem;
    opacity: 0.04;
    pointer-events: none;
}

.decoration-globe {
    width: 16rem;
    height: 16rem;
    color: var(--brand-color);
}

.header-card-content {
    position: relative;
    z-index: 1;
}

.label-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.accent-line {
    height: 1px;
    width: 3rem;
    background: var(--brand-color);
}

.section-label {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    color: var(--brand-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.title-icon {
    height: 2rem;
    width: 2rem;
    color: var(--brand-color);
}

.header-info-card h1 {
    font-size: 2.25rem;
    font-weight: 900;
    margin: 0;
}

.header-info-card .description {
    font-size: 1.125rem;
    color: var(--gray-600);
    margin-bottom: 2rem;
    max-width: 600px;
}

.search-input-group {
    position: relative;
    max-width: 400px;
}

.search-input {
    width: 100%;
    border: none;
    border-bottom: 3px solid var(--text-black);
    padding: 0.75rem 0;
    font-size: 1.25rem;
    font-weight: 800;
    background: transparent;
    border-radius: 0;
    text-transform: uppercase;
    outline: none;
}

.search-input::placeholder {
    color: var(--gray-300);
}

.search-icon {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1.5rem;
    height: 1.5rem;
    color: var(--text-black);
}

.header-stats-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.stats-card-inner {
    text-align: center;
}

.stats-card-inner .stat-number {
    font-size: 4rem;
    font-weight: 900;
    color: var(--brand-color);
    margin: 0;
    line-height: 1;
}

.stats-card-inner .stat-label {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--gray-600);
    margin-top: 0.25rem;
}

/* Split Stats Card (Country View) */
.header-stats-card-split {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--gray-200);
}

.header-stats-card-split .stats-box {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem 2rem;
}

.header-stats-card-split .stat-number {
    font-size: 2.25rem;
    font-weight: 900;
    color: var(--brand-color);
    margin: 0;
    line-height: 1;
}

.header-stats-card-split .bottom-box .stat-number {
    color: var(--text-black);
}

.header-stats-card-split .stat-label {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-600);
    margin-top: 0.5rem;
    letter-spacing: 0.05em;
}

/* Toolbar */
.country-toolbar {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toolbar-results-info {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--gray-600);
    letter-spacing: 0.025em;
}

.view-toggle-group {
    display: flex;
    gap: 1px;
    background: var(--gray-200);
    border: 2px solid var(--gray-200);
}

.view-btn {
    padding: 0.5rem;
    background: white;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    transition: all 0.2s;
}

.view-btn.active {
    background: var(--brand-color);
    color: white;
}

/* Grid Layout */
.country-grid {
    display: grid;
    gap: 1px;
    background: var(--gray-200);
    border: 2px solid var(--gray-200);
}

@media (min-width: 768px) {
    .country-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .country-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Country Card Item */
.country-card-item {
    background: white;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
    height: 194px;
    /* Matches user feedback for country cards */
}

/* More specific selector to ensure override */
.country-card-item.company-card-item {
    height: 218px;
    /* Matches user feedback for company cards */
}

.country-card-item:hover {
    background-color: rgba(240, 253, 244, 0.5);
}

.country-card-inner {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.top-rank-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--brand-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    text-transform: uppercase;
    padding: 0.25rem 0.5rem;
    letter-spacing: 0.025em;
    line-height: 1rem;
}

.card-title-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    margin-bottom: 1rem;
    line-height: 1.75rem;
}

.country-name {
    font-size: 1.125rem;
    /* Matches text-lg */
    font-weight: 900;
    margin: 0 !important;
    color: var(--text-black);
    transition: color 0.2s;
}

.country-card-item:hover .country-name {
    color: var(--brand-color);
}

.rank-number {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.card-stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    /* Increased to fill space in company cards */
}

.card-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 900;
    margin: 0;
}

.stat-value.primary {
    color: var(--brand-color);
}

.stat-value.secondary {
    color: var(--text-black);
}

.stat-key {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-600);
    line-height: 1rem;
    margin: 0;
}

.card-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 2px solid var(--gray-200);
}

.view-details-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.view-details-group span {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.25rem;
}

.company-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    /* Matches text-sm */
    color: var(--gray-600);
    margin-bottom: 1rem;
    /* Increased as per mb-4 */
    margin-top: 0;
    /* Matches mt-1 */
    line-height: 1.25rem;
}

.company-card-item .card-stat .stat-value {
    font-size: 1.5rem;
    /* Matches text-2xl */
    font-weight: 900;
    color: var(--brand-color);
    margin: 0;
    line-height: normal;
}

.company-card-item .card-stat .stat-key {
    font-size: 0.75rem;
    /* Matches text-xs */
    text-transform: uppercase;
    color: var(--gray-600);
    margin-top: 0;
}

.icon-arrow {
    width: 1rem;
    height: 1rem;
    color: var(--gray-400);
    transition: all 0.2s;
}

.country-card-item:hover .icon-arrow {
    color: var(--brand-color);
    transform: translateX(0.25rem);
}

/* List View Style */
.country-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--gray-200);
    border: 2px solid var(--gray-200);
}

.country-list-item {
    background: white;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.country-list-item:hover {
    background-color: var(--brand-bg);
}

.list-rank {
    width: 3rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    color: var(--gray-400);
}

.list-name {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 800;
}

.list-stats {
    display: flex;
    gap: 2rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-right: 2rem;
}

.list-stats span {
    width: 120px;
}