/* ===== Tools Page ===== */
.tools-page {
    padding: 40px 0 80px;
    min-height: 60vh;
    background: #f7f8fa;
}

.tools-header {
    text-align: center;
    margin-bottom: 32px;
}

.tools-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 8px;
}

.tools-header p {
    font-size: 15px;
    color: #888;
    margin: 0;
}

/* ===== Breadcrumb ===== */
.tools-breadcrumb {
    margin-bottom: 24px;
    font-size: 14px;
    color: #999;
}

.tools-breadcrumb a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

.tools-breadcrumb a:hover {
    color: #DC0000;
}

.tools-breadcrumb .sep {
    margin: 0 8px;
    color: #ccc;
}

/* ===== Entry Grid (tools index) ===== */
.tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 800px;
    margin: 0 auto;
}

.tool-entry {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    border: 1.5px solid transparent;
    transition: all 0.25s;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.tool-entry:hover {
    border-color: #DC0000;
    box-shadow: 0 6px 24px rgba(220, 0, 0, 0.1);
    transform: translateY(-2px);
}

.tool-entry-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: #fef0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: #DC0000;
}

.tool-entry h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 8px;
}

.tool-entry p {
    font-size: 13px;
    color: #888;
    line-height: 1.6;
    margin: 0 0 16px;
    flex: 1;
}

.tool-entry-link {
    font-size: 14px;
    font-weight: 600;
    color: #DC0000;
}

@media (max-width: 600px) {
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .tool-entry {
        padding: 24px 20px;
    }
}

/* ===== Page Header (individual tool pages) ===== */
.tool-page-header {
    margin-bottom: 28px;
}

.tool-page-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px;
}

.tool-page-header p {
    font-size: 14px;
    color: #888;
    margin: 0;
}

/* ===== Two-Column Layout ===== */
.tool-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: stretch;
}

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

.tool-main > .tool-card {
    flex: 1;
}

.tool-side {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tool-side > .tool-card:first-child {
    flex: 1;
}

/* ===== Card ===== */
.tool-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.tool-card-header {
    padding: 24px 28px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.tool-card-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 4px;
}

.tool-card-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 4px;
}

.tool-card-header p {
    font-size: 13px;
    color: #999;
    margin: 0;
}

.tool-card-body {
    padding: 24px 28px 28px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    padding: 18px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.calc-form {
    padding: 20px 24px 24px;
}

/* ===== Results Stack (vertical layout for side column) ===== */
.results-stack {
    padding: 12px 24px 24px;
}

.results-stack .result-item {
    padding: 16px 0;
    border-bottom: 1px solid #f0f0f0;
    border-radius: 0;
    background: transparent;
    border-left: none;
    border-right: none;
    border-top: none;
}

.results-stack .result-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.results-stack .result-item.highlight {
    background: #fef0f0;
    border-radius: 10px;
    padding: 16px;
    margin: 4px -8px;
    border-bottom: none;
}

.results-stack .result-item.highlight + .result-item {
    border-top: none;
}

/* ===== Shared Field Styles ===== */
.field-group {
    margin-bottom: 16px;
}

.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.field-hint {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: block;
}

/* ===== Custom Select ===== */
.custom-select {
    position: relative;
}

.select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    background: #fafafa;
    font-size: 14px;
    transition: border-color 0.2s;
    user-select: none;
}

.select-trigger:hover {
    border-color: #DC0000;
}

.select-arrow {
    color: #999;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.custom-select.open .select-arrow {
    transform: rotate(180deg);
}

.select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: none;
}

.custom-select.open .select-dropdown {
    display: block;
}

.select-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.select-option:hover {
    background: #fef0f0;
}

.select-option.active {
    background: #fef0f0;
    color: #DC0000;
    font-weight: 600;
}

/* ===== Number Input ===== */
.number-input {
    display: flex;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
    transition: border-color 0.2s;
}

.number-input:focus-within {
    border-color: #DC0000;
}

.number-input input {
    flex: 1;
    border: none;
    padding: 10px 14px;
    font-size: 14px;
    background: transparent;
    outline: none;
    font-family: inherit;
    min-width: 0;
}

.number-btns {
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e8e8e8;
}

.number-btns button {
    flex: 1;
    width: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: background 0.15s;
    font-family: inherit;
}

.number-btns button:hover {
    background: #fef0f0;
    color: #DC0000;
}

.number-btns button:first-child {
    border-bottom: 1px solid #e8e8e8;
}

/* ===== Calc Layout ===== */
.calc-row {
    display: flex;
    gap: 16px;
}

.calc-row>.field-group {
    flex: 1;
    min-width: 0;
}

.calc-submit {
    width: 100%;
    padding: 13px;
    background: #DC0000;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 2px;
    transition: background 0.2s, transform 0.15s;
    margin-top: 8px;
    font-family: inherit;
}

.calc-submit:hover {
    background: #c00;
    transform: translateY(-1px);
}

.calc-submit:active {
    transform: translateY(0);
}

/* ===== Results ===== */
.calc-results {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #f0f0f0;
}

.results-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 16px;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.result-item {
    background: #fafafa;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #f0f0f0;
}

.result-item .result-label {
    font-size: 13px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.result-item .result-value {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}

.result-item .result-value .empty {
    color: #ccc;
}

.result-item .result-value small {
    font-size: 12px;
    font-weight: 500;
    color: #999;
    margin-left: 4px;
}

.result-item .result-value.profit-positive {
    color: var(--color-bullish, #20B531);
}

.result-item .result-value.profit-negative {
    color: var(--color-bearish, #F04945);
}

.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    font-size: 10px;
    font-weight: 700;
    cursor: help;
}

/* ===== Calc Form Extras ===== */
.calc-divider {
    position: relative;
    text-align: center;
    margin: 24px 0 16px;
    border-top: 1px solid #f0f0f0;
    padding-top: 20px;
}

.calc-divider-label {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    display: block;
    text-align: left;
    margin-bottom: 12px;
}

.calc-submit-alt {
    background: #fff;
    color: #1a1a2e;
    border: 1.5px solid #e0e0e0;
}

.calc-submit-alt:hover {
    background: #fef0f0;
    border-color: #DC0000;
    color: #DC0000;
}

/* ===== Tier Table ===== */
.tier-header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

.tier-header small {
    font-size: 12px;
    font-weight: 500;
    color: #999;
}

.tier-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 20px;
    font-size: 13px;
    transition: background 0.15s;
}

.tier-row + .tier-row {
    border-top: 1px solid #f5f5f5;
}

.tier-row.active {
    background: #fef0f0;
}

.tier-row.active .tier-range,
.tier-row.active .tier-rate {
    color: #DC0000;
    font-weight: 600;
}

.tier-range {
    color: #555;
}

.tier-rate {
    font-weight: 500;
    color: #1a1a2e;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", monospace;
}

.tier-rate small {
    font-weight: 400;
    color: #999;
}

/* ===== Disclaimer ===== */
.tool-disclaimer {
    font-size: 11px;
    color: #aaa;
    margin-top: 24px;
    line-height: 1.7;
    padding: 14px 16px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

/* ========================================
   Converter Specific
   ======================================== */
.converter-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 100px;
    background: #f7f8fa;
    border: 1px solid #e8e8e8;
    font-size: 12px;
    color: #888;
    flex-shrink: 0;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fbbf24;
    animation: pulse 2s infinite;
}

.badge-dot.live {
    background: var(--color-bullish, #20B531);
    box-shadow: 0 0 6px var(--color-bullish, #20B531);
}

.badge-dot.fallback {
    background: #fbbf24;
    box-shadow: 0 0 6px #fbbf24;
}

.badge-live {
    color: var(--color-bullish, #20B531);
}

.badge-fallback {
    color: #fbbf24;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Loading */
.converter-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    color: #999;
    font-size: 13px;
    gap: 12px;
}

.converter-loading.hidden {
    display: none;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e8e8e8;
    border-top-color: #DC0000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Amount Input */
.amount-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    padding: 4px 16px 4px 4px;
    gap: 8px;
    transition: border-color 0.2s;
}

.amount-input-wrap:focus-within {
    border-color: #DC0000;
}

.amount-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #1a1a2e;
    font-size: 24px;
    font-weight: 600;
    padding: 8px 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", monospace;
    min-width: 0;
}

.amount-suffix {
    color: #888;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

/* Quick Amounts */
.quick-amounts {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.quick-btn {
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 5px 14px;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    font-family: -apple-system, monospace;
    font-weight: 500;
    transition: all 0.15s;
}

.quick-btn:hover {
    border-color: #DC0000;
    color: #DC0000;
}

.quick-btn.active {
    background: #fef0f0;
    border-color: #DC0000;
    color: #DC0000;
}

/* Currency Row */
.currency-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.currency-col {
    flex: 1;
    min-width: 0;
    position: relative;
}

.currency-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: #fafafa;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    color: #1a1a2e;
    font-size: 14px;
    text-align: left;
    transition: all 0.2s;
    font-family: inherit;
}

.currency-btn:hover {
    border-color: #DC0000;
}

.currency-btn.open {
    border-color: #DC0000;
    box-shadow: 0 0 0 3px rgba(220, 0, 0, 0.08);
}

.c-flag {
    font-size: 20px;
}

/* Metal flag badges (Au / Ag) */
.metal-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.metal-flag.xau {
    background: linear-gradient(135deg, #C5960C, #F0D060);
}

.metal-flag.xag {
    background: linear-gradient(135deg, #7A7A7A, #B8B8B8);
}

.opt-flag .metal-flag,
.pair-flag .metal-flag {
    width: 20px;
    height: 20px;
    font-size: 9px;
}

.c-info {
    flex: 1;
    min-width: 0;
}

.c-code {
    font-weight: 600;
    font-size: 14px;
}

.c-name {
    font-size: 11px;
    color: #999;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.c-arrow {
    color: #999;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.currency-btn.open .c-arrow {
    transform: rotate(180deg);
}

/* Swap Button */
.swap-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #DC0000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(220, 0, 0, 0.25);
    transition: transform 0.2s;
}

.swap-btn:hover {
    transform: scale(1.08);
}

/* Currency Dropdown */
.currency-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    z-index: 100;
    max-height: 320px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    display: none;
}

.currency-dropdown.open {
    display: block;
}

.currency-search-wrap {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.currency-search {
    width: 100%;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 8px 12px;
    color: #333;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}

.currency-search:focus {
    border-color: #DC0000;
}

.currency-list {
    max-height: 260px;
    overflow-y: auto;
}

.currency-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    border: none;
    cursor: pointer;
    text-align: left;
    background: transparent;
    color: #333;
    font-size: 13px;
    transition: background 0.15s;
    font-family: inherit;
}

.currency-option:hover {
    background: #fef0f0;
}

.currency-option.active {
    background: #fef0f0;
    color: #DC0000;
    font-weight: 600;
}

.currency-option .opt-flag {
    font-size: 16px;
}

.currency-option .opt-code {
    font-weight: 600;
}

.currency-option .opt-name {
    color: #999;
    font-size: 12px;
}

/* Converter Result */
.converter-result {
    text-align: center;
    padding: 20px 0;
    margin: 4px 0;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

.cv-result-from {
    font-size: 13px;
    color: #999;
    margin-bottom: 6px;
}

.cv-result-value {
    font-size: 32px;
    font-weight: 700;
    color: #DC0000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", monospace;
    letter-spacing: -0.5px;
    line-height: 1.2;
    word-break: break-all;
}

.cv-result-to {
    font-size: 14px;
    color: #888;
    margin-top: 4px;
    font-weight: 500;
}

/* Rate Info */
.rate-info-box {
    margin-top: 16px;
    padding: 14px 16px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

.rate-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.rate-row+.rate-row {
    margin-top: 8px;
}

.rate-row .rate-label {
    color: #888;
}

.rate-row .rate-val {
    color: #1a1a2e;
    font-family: -apple-system, monospace;
    font-weight: 500;
}

/* Convert Table */
.convert-table-section {
    margin-top: 24px;
    border: 1px solid #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
}

.convert-table-header {
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.convert-table-title {
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

.convert-table-time {
    font-size: 11px;
    color: #999;
}

.convert-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 20px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
}

.convert-row:hover {
    background: #fef0f0;
}

.convert-row+.convert-row {
    border-top: 1px solid #f5f5f5;
}

.convert-from-text {
    font-family: -apple-system, monospace;
    color: #555;
}

.convert-to-text {
    font-family: -apple-system, monospace;
    color: #DC0000;
    font-weight: 500;
}

/* Pairs Section */
.pairs-section {
    margin-top: 24px;
}

.section-label {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 12px;
}

.pairs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pair-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fafafa;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    color: #333;
    font-size: 12px;
    text-align: left;
    transition: all 0.2s;
    font-family: inherit;
}

.pair-btn:hover {
    background: #fef0f0;
    border-color: #DC0000;
}

.pair-btn.active {
    background: #fef0f0;
    border-color: #DC0000;
}

.pair-flag {
    font-size: 16px;
}

.pair-info {
    flex: 1;
    min-width: 0;
}

.pair-code {
    font-weight: 600;
    font-size: 12px;
}

.pair-rate {
    color: #DC0000;
    font-family: -apple-system, monospace;
    font-size: 11px;
    font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .tool-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .tools-page {
        padding: 24px 0 60px;
    }

    .tools-header h1,
    .tool-page-header h1 {
        font-size: 22px;
    }

    .tool-card-header,
    .tool-card-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .card-title {
        padding-left: 16px;
        padding-right: 16px;
    }

    .calc-form {
        padding: 16px;
    }

    .results-stack {
        padding-left: 16px;
        padding-right: 16px;
    }

    .calc-row.calc-row-2,
    .calc-row.calc-row-3 {
        flex-direction: column;
        gap: 0;
    }

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

    .currency-row {
        flex-direction: column;
        align-items: stretch;
    }

    .swap-btn {
        align-self: center;
        transform: rotate(90deg);
        margin: 4px 0;
    }

    .swap-btn:hover {
        transform: rotate(90deg) scale(1.08);
    }

    .converter-header-row {
        flex-direction: column;
    }

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