:root {
    --primary: #059669;
    --primary-hover: #047857;
    --secondary: #10b981;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --bg: #ecfdf5;
    --surface: #ffffff;
    --text: #064e3b;
    --text-muted: #047857;
    --border: #a7f3d0;
    --border-strong: #6ee7b7;
    --row-hover: #f0fdf4;
    --header-bg: #d1fae5;
    --shadow: 0 4px 24px rgba(6, 78, 59, 0.08);
    --radius: 12px;
    --font: 'Plus Jakarta Sans', system-ui, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.brand {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0 0.5rem;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
}

.brand h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.brand p {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    background: var(--bg);
    color: var(--primary);
    font-weight: 600;
}

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow: auto;
}

.page-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.75rem;
    font-weight: 700;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.feature-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: 0 8px 32px rgba(6, 78, 59, 0.12);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.feature-card p {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.card-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.tool-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.25rem;
    margin-top: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .tool-layout {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

.panel-title {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
}

.import-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab {
    padding: 0.45rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    border-color: var(--border-strong);
}

.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.paste-area,
.keywords-area {
    width: 100%;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.82rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    background: #fafafa;
    color: var(--text);
}

.paste-area:focus,
.keywords-area:focus {
    outline: 2px solid var(--secondary);
    outline-offset: 1px;
    border-color: var(--secondary);
}

.file-drop {
    border: 2px dashed var(--border-strong);
    border-radius: 10px;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1rem;
    transition: border-color 0.2s, background 0.2s;
}

.file-drop.dragover {
    border-color: var(--primary);
    background: var(--bg);
}

.file-drop svg {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.15rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-ghost {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--border-strong);
}

.keyword-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.preset-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    background: #fff;
    cursor: pointer;
}

.panel-table {
    margin-top: 1.25rem;
}

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.table-toolbar .panel-title {
    margin: 0;
}

.stats {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stats strong {
    color: var(--primary);
}

.excel-wrap {
    overflow: auto;
    max-height: 480px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
}

.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    background: #fff;
}

.excel-table th,
.excel-table td {
    border: 1px solid #c6e9d8;
    padding: 0.35rem 0.6rem;
    text-align: left;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.excel-table th {
    position: sticky;
    top: 0;
    background: var(--header-bg);
    font-weight: 600;
    z-index: 1;
    color: var(--text);
}

.excel-table tbody tr:nth-child(even) {
    background: #f7fef9;
}

.excel-table tbody tr:hover {
    background: var(--row-hover);
}

.excel-table .col-index {
    width: 48px;
    text-align: center;
    background: #e8f8ef;
    font-weight: 600;
    color: var(--text-muted);
}

.excel-table .col-link a {
    color: #0369a1;
    text-decoration: none;
}

.excel-table .col-link a:hover {
    text-decoration: underline;
}

.excel-table .col-title {
    white-space: normal;
    min-width: 200px;
}

.panel-removed {
    margin-top: 1rem;
}

.removed-list {
    max-height: 200px;
    overflow: auto;
    font-size: 0.82rem;
}

.removed-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 0.5rem;
    align-items: start;
}

.removed-item .kw {
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--text);
    color: #ecfdf5;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 100;
    max-width: 360px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: #b91c1c;
}

.progress-wrap {
    margin: 1rem 0;
    padding: 0 0.25rem;
}

.progress-track {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 999px;
    transition: width 0.25s ease;
}

.progress-label {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.keywords-file-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
