:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --accent: #008949;
    --accent-hover: #006b38;
    --accent-light: #d4f5e6;
    --accent-subtle: #e6f7ef;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.06), 0 4px 10px rgba(0,0,0,.04);
    --transition: 0.15s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a{text-decoration: none}
/* ── Header ── */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,.88);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 24px;
}
.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}
.logo-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), #00a85a);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 16px;
}
.logo-text {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    letter-spacing: -0.3px;
}
.header-nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.header-nav::-webkit-scrollbar { display: none; }
.header-nav a {
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition);
}
.header-nav a:hover, .header-nav a.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

/* ── Search Bar (sticky, always visible on sub-pages) ── */
.search-bar {
    background: var(--bg);
    padding: 12px 0;
    position: sticky;
    top: 56px;
    z-index: 99;
    border-bottom: 1px solid var(--border);
}
.search-bar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}
.search-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 4px;
    border: 1px solid var(--border);
}
.search-card.home-search {
    box-shadow: var(--shadow-lg);
    padding: 6px;
    max-width: 680px;
    margin: 0 auto;
    border: none;
}
.search-row {
    display: flex;
    gap: 0;
    align-items: stretch;
}
.search-type {
    position: relative;
    flex-shrink: 0;
}
.search-type select {
    appearance: none;
    height: 100%;
    padding: 0 36px 0 16px;
    border: none;
    border-right: 1px solid var(--border);
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    outline: none;
}
.search-type select:focus { background: var(--accent-subtle); }
.search-type::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-secondary);
    pointer-events: none;
}
.search-input-wrap {
    flex: 1;
    position: relative;
}
.search-input-wrap input {
    width: 100%;
    height: 100%;
    padding: 12px 16px;
    border: none;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    background: transparent;
}
.search-input-wrap input::placeholder { color: var(--text-muted); }
.search-btn {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-btn:hover { background: var(--accent-hover); }
.search-btn svg { width: 16px; height: 16px; }

/* ── Main ── */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 60px;
}

/* ── Hero (homepage only) ── */
.hero {
    text-align: center;
    padding: 40px 0 28px;
}
.hero h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.8px;
    margin-bottom: 8px;
    line-height: 1.2;
}
.hero h1 span { color: var(--accent); }
.hero p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 24px;
}

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 28px;
    flex-wrap: wrap;
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}
.stat-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--accent-subtle); color: var(--accent); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-value { font-weight: 700; color: var(--text); font-size: 15px; }
.stat-label { font-size: 12px; }

/* ── Browse Section ── */
.browse-section {
    margin-top: 48px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.browse-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}
.browse-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.browse-card .icon-circle {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}
.browse-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}
.browse-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Province Grid ── */
.province-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}
.province-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 10px;
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    text-decoration: none;
    transition: all var(--transition);
    cursor: pointer;
}
.province-chip:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.pc-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.province-chip:hover .pc-name { color: var(--accent); }
.pc-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ── New Companies List ── */
.new-companies-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.new-company-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.new-company-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.nc-left { flex: 1; min-width: 0; }
.nc-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
    line-height: 1.3;
}
.nc-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-secondary);
}
.nc-tax {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 500;
}

/* ── Date Search Card ── */
.date-search-card {
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
}
.date-search-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}
.date-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.date-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.date-field input[type="date"] {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    outline: none;
    transition: border-color var(--transition);
}
.date-field input[type="date"]:focus {
    border-color: var(--accent);
}
.date-field select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    outline: none;
    cursor: pointer;
    min-width: 160px;
    transition: border-color var(--transition);
}
.date-field select:focus {
    border-color: var(--accent);
}

/* ── Sub-page top ── */
.subpage-top {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.subpage-top h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ── Results List ── */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.results-count {
    font-size: 14px;
    color: var(--text-secondary);
}
.results-count strong { color: var(--text); }
.result-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 8px;
}
.result-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.result-item .ri-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.result-item .ri-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
    line-height: 1.3;
}
.result-item .ri-tax {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.result-item .ri-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.result-item .ri-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--danger); }
.status-dot.suspended { background: var(--warning); }

/* ── Back button ── */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--card);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}
.back-btn:hover { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }

/* ── Detail Card ── */
.detail-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.detail-header {
    padding: 28px 32px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--accent-subtle), transparent);
}
.detail-header .dh-name {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
    line-height: 1.3;
    margin-bottom: 8px;
}
.detail-header .dh-sub {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}
.detail-header .dh-sub .intl {
    font-style: italic;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.status-badge.inactive { background: var(--danger-light); color: var(--danger); }
.status-badge.active { background: var(--success-light); color: var(--success); }
.status-badge.suspended { background: var(--warning-light); color: var(--warning); }

.detail-body {
    padding: 24px 32px;
}
.detail-body + .detail-body { border-top: 1px solid var(--border); }
.detail-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.action-btns {
    display: flex;
    gap: 6px;
}
.copy-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-transform: none;
    letter-spacing: 0;
    transition: all var(--transition);
    white-space: nowrap;
}
.copy-all-btn:hover {
    background: var(--accent);
    color: #fff;
}
.copy-all-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.copy-all-btn svg { width: 13px; height: 13px; }
.copy-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-transform: none;
    letter-spacing: 0;
    transition: all var(--transition);
    white-space: nowrap;
}
.copy-link-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}
.copy-link-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.copy-link-btn svg { width: 13px; height: 13px; }
.info-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}
.info-col-left, .info-col-right {
    display: flex;
    flex-direction: column;
}
.info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.info-item:last-child { border-bottom: none; }
.info-label {
    width: 120px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    padding-top: 1px;
}
.info-value {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    word-break: break-word;
    line-height: 1.4;
}
.info-value.empty {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--card);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
    flex-shrink: 0;
    margin-left: 6px;
    white-space: nowrap;
}
.copy-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}
.copy-btn.copied {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}
.copy-btn svg { width: 12px; height: 12px; }

/* ── Business Fields Table ── */
.fields-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.fields-table th {
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.fields-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}
.fields-table tr:last-child td { border-bottom: none; }
.fields-table .code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    width: 70px;
}
.fields-table .main-row { background: var(--accent-subtle); }
.fields-table .main-row td { font-weight: 600; }
.main-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--accent);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    z-index: 200;
}
.toast.show { opacity: 1; }

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .hero h1 { font-size: 24px; }
    .search-row { flex-wrap: wrap; }
    .search-type { width: 100%; }
    .search-type select {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        border-radius: var(--radius-sm) var(--radius-sm) 0 0;
        padding: 12px 16px;
    }
    .search-input-wrap input { padding: 12px 16px; }
    .search-btn { width: 100%; justify-content: center; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
    .info-columns { grid-template-columns: 1fr; gap: 0; }
    .detail-header, .detail-body { padding: 20px; }
    .stats-bar { gap: 20px; }
    .browse-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .province-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .new-company-item { flex-direction: column; align-items: flex-start; }
    .nc-meta { flex-direction: column; gap: 2px; }
    .date-search-row { flex-direction: column; }
    .date-field { width: 100%; }
    .date-field select { min-width: auto; width: 100%; }
    .header-nav { display: none; }
    .search-bar { top: 56px; }
}