/* ================================================================
   菜刀客在线工具页 · 公共样式（common.css）
   ================================================================
   三页共用：mortgage-calculator.html / json-formatter.html / qrcode-generator.html
   用法：每个工具页先引入本文件再引入页面私有样式（如有）。
   <link rel="stylesheet" href="/css/common.css">
   页面私有覆盖请放在单独的 <link> 或内联 <style> 中（在公共文件之后加载）。
   ================================================================ */

/* ================= 重置与基础 ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    min-height: 100vh;
}

/* ================= 页头 ================= */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header p {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 5px;
}

/* ================= 容器与主体布局 ================= */
.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

.container .ad-container {
    width: 100%;
    margin: 10px auto;
}

.main {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 15px;
}

@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }
}

/* ================= 面板 ================= */
.panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.panel-header:first-child {
    border-top: none;
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

/* ================= 按钮 ================= */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd6;
}

.btn-secondary {
    background: #ffffff;
    color: #374151;
    border-color: #d1d5db;
}

.btn-secondary:hover {
    background: #f9fafb;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.panel-actions .btn {
    padding: 5px 10px;
    font-size: 12px;
}

/* ================= 表单 ================= */
.form-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.form-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-wrap {
    position: relative;
    flex: 1;
}

.input-wrap .suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #9ca3af;
    pointer-events: none;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

.form-control[readonly] {
    background: #f9fafb;
    color: #6b7280;
    cursor: default;
}

select.form-control {
    cursor: pointer;
}

.rate-tip {
    font-size: 12px;
    color: #9ca3af;
}

.radio-group {
    display: flex;
    gap: 10px;
}

.radio-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: #374151;
}

.radio-card:hover {
    border-color: #667eea;
}

.radio-card.active {
    border-color: #667eea;
    background: #eef2ff;
    color: #4338ca;
}

.radio-card input {
    accent-color: #667eea;
}

.calc-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
    justify-content: center;
}

/* ================= 标签页 ================= */
.tab-bar {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
}

.tab {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    background: #f9fafb;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* ================= 结果展示 ================= */
.result-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hero-result {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-result .label {
    font-size: 13px;
    opacity: 0.9;
}

.hero-result .amount {
    font-size: 30px;
    font-weight: 700;
}

.hero-result .method {
    font-size: 12px;
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 20px;
}

.summary-list {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.summary-title {
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    font-size: 13px;
}

.summary-row + .summary-row {
    border-top: 1px solid #f0f1f3;
}

.summary-row .item-name {
    color: #6b7280;
}

.summary-row .item-value {
    color: #ef4444;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.summary-row .item-value.total {
    color: #4338ca;
}

.table-wrap {
    max-height: 420px;
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

table.schedule {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 560px;
}

table.schedule th {
    background: #f9fafb;
    color: #374151;
    font-weight: 600;
    padding: 10px 12px;
    text-align: right;
    position: sticky;
    top: 0;
    border-bottom: 1px solid #e5e7eb;
    z-index: 1;
}

table.schedule th:first-child,
table.schedule td:first-child {
    text-align: center;
}

table.schedule td {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    text-align: right;
    color: #4b5563;
    font-variant-numeric: tabular-nums;
}

table.schedule tr:hover td {
    background: #fafbff;
}

table.schedule tr:last-child td {
    border-bottom: none;
}

table.schedule tr.total-row td {
    background: #eef2ff;
    color: #4338ca;
    font-weight: 600;
    border-top: 2px solid #c7d2fe;
}

.view-more {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 10px;
    cursor: pointer;
    color: #667eea;
    font-size: 13px;
    border-top: 1px solid #e5e7eb;
    user-select: none;
}

.view-more:hover {
    background: #f9fafb;
}

/* ================= 状态栏 / 空态 / 提示 ================= */
.status-bar {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    font-size: 13px;
    color: #6b7280;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
}

.status-error {
    background: #fef2f2;
    color: #dc2626;
    border-top: 1px solid #fecaca;
}

.status-success {
    color: #16a34a;
    border-top: 1px solid #bbf7d0;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #9ca3af;
    gap: 10px;
}

.empty-state .icon {
    font-size: 42px;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: #374151;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ================= 导航 ================= */
.navbar {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-brand {
    font-size: 15px;
    font-weight: 600;
    color: #667eea;
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-brand:hover {
    color: #5a6fd6;
}

.nav-list {
    display: flex;
    gap: 4px;
    list-style: none;
    flex: 1;
}

.nav-list a {
    display: block;
    padding: 6px 12px;
    font-size: 14px;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-list a:hover {
    color: #667eea;
    background: #eef2ff;
}

.nav-list a.active {
    color: #667eea;
    font-weight: 600;
    background: #eef2ff;
}

.nav-list li.has-drop {
    position: relative;
}

.nav-list li.has-drop > a {
    display: flex;
    align-items: center;
    gap: 3px;
}

.nav-list .caret {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.2s;
}

.nav-list li.has-drop:hover > a .caret,
.nav-list li.has-drop.open > a .caret {
    transform: rotate(180deg);
}

.nav-list .submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 150px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    list-style: none;
    padding: 6px;
    z-index: 200;
}

.nav-list li.has-drop:hover > .submenu,
.nav-list li.has-drop.open > .submenu {
    display: block;
}

.nav-list .submenu a {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
}

.nav-search {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 3px 4px 3px 10px;
    margin-left: auto;
    transition: border-color 0.2s;
}

.nav-search:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

.nav-search input {
    border: none;
    outline: none;
    background: transparent;
    width: 130px;
    font-size: 13px;
    color: #374151;
}

.nav-search .search-btn {
    border: none;
    background: #667eea;
    color: #ffffff;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.nav-search .search-btn:hover {
    background: #5a6fd6;
}

@media (max-width: 560px) {
    .nav-inner {
        gap: 8px;
        padding: 0 12px;
    }

    .nav-search input {
        width: 80px;
    }
}

.nav-toggle {
    display: none;
    padding: 5px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    font-size: 16px;
    line-height: 1;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-toggle:hover {
    background: #f9fafb;
}

.navbar.collapsed .nav-list {
    display: none;
}

.navbar.collapsed .nav-toggle {
    display: inline-flex;
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.navbar.collapsed.open .nav-dropdown {
    display: block;
}

.nav-dropdown a {
    display: block;
    padding: 10px 20px;
    font-size: 14px;
    color: #374151;
    text-decoration: none;
    border-radius: 0;
}

.nav-dropdown a + a {
    border-top: 1px solid #f3f4f6;
}

.nav-dropdown a:hover {
    color: #667eea;
    background: #f9fafb;
}

.nav-dropdown a.active {
    color: #667eea;
    font-weight: 600;
}

.nav-dropdown a.drop-group {
    color: #6b7280;
    font-size: 13px;
    background: #f9fafb;
    font-weight: 600;
}

.nav-dropdown a.drop-sub {
    padding-left: 36px;
    font-size: 13px;
    color: #4b5563;
}

/* ================= 页脚 ================= */
.footer {
    max-width: 1400px;
    margin: 50px auto 0;
    text-align: center;
    font: 14px 'Microsoft Yahei',Verdana,Arial,Tahoma;
}

.footer a {
    color: #333;
    text-decoration: none;
    background-color: transparent;
}