/* ===================================================
   Sellabrew BrandFinder — Design System v2
   60:30:10 Rule  |  White · Sky Blue · Coral
   =================================================== */

/* ========== DESIGN TOKENS ========== */

/* --- Light Mode (Default) --- */
:root,
:root[data-theme="light"] {
    /* Neutral Foundation (95%) */
    --white: #FFFFFF;
    --snow: #F7F9FC;
    --mist: #EEF2F7;

    /* Gray Scale (Stripe/Vercel式) */
    --gray-50:  #F7F9FC;
    --gray-100: #EEF2F7;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E0;
    --gray-400: #A0AEC0;
    --gray-500: #718096;
    --gray-600: #4A5568;
    --gray-700: #2D3748;
    --gray-800: #1A202C;
    --gray-900: #0A1628;

    /* 30% — Sky Blue */
    --sky: #00B4D8;
    --sky-dark: #0090B0;
    --sky-light: rgba(0, 180, 216, 0.06);
    --sky-glow: rgba(0, 180, 216, 0.12);

    /* 10% — Coral Red */
    --coral: #E8636F;
    --coral-dark: #D04E5A;
    --coral-light: rgba(232, 99, 111, 0.06);
    --coral-glow: rgba(232, 99, 111, 0.12);

    /* Neutrals */
    --ink: #1A202C;
    --slate: #4A5568;
    --ash: #A0AEC0;
    --sage: #38A169;
    --sage-light: rgba(56, 161, 105, 0.08);
    --amber: #D69E2E;
    --amber-light: rgba(214, 158, 46, 0.08);

    /* Semantic mapping */
    --bg-primary: var(--snow);
    --bg-secondary: var(--mist);
    --bg-card: var(--white);
    --bg-card-hover: var(--snow);
    --bg-glass: rgba(0, 180, 216, 0.02);
    --bg-input: var(--mist);
    --border: #E2E8F0;
    --border-focus: rgba(0, 180, 216, 0.4);
    --text-primary: var(--ink);
    --text-secondary: var(--slate);
    --text-muted: var(--ash);
    --accent: var(--sky);
    --accent-hover: var(--sky-dark);
    --accent-glow: var(--sky-light);
    --accent-light: var(--sky-light);
    --success: var(--sage);
    --success-bg: var(--sage-light);
    --danger: var(--coral);
    --danger-bg: var(--coral-light);
    --warning: var(--amber);
    --warning-bg: var(--amber-light);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);

    /* Radius */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-8: 48px;
    --space-10: 64px;
    --space-16: 96px;

    /* Typography */
    --font-heading: 'Outfit', 'Noto Sans JP', -apple-system, sans-serif;
    --font-body: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

/* --- Dark Mode --- */
:root[data-theme="dark"] {
    --white: #1A202C;
    --snow: #2D3748;
    --mist: #374151;
    --sky: #4DD0E1;
    --sky-dark: #80DEEA;
    --sky-light: rgba(77, 208, 225, 0.08);
    --sky-glow: rgba(77, 208, 225, 0.15);
    --coral: #FC8181;
    --coral-dark: #FEB2B2;
    --coral-light: rgba(252, 129, 129, 0.08);
    --ink: #F7FAFC;
    --slate: #CBD5E0;
    --ash: #718096;
    --sage: #68D391;
    --sage-light: rgba(104, 211, 145, 0.1);
    --amber: #F6E05E;
    --amber-light: rgba(246, 224, 94, 0.1);
    --bg-primary: var(--white);
    --bg-secondary: var(--snow);
    --bg-card: var(--snow);
    --bg-card-hover: var(--mist);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(77, 208, 225, 0.4);
    --text-primary: var(--ink);
    --text-secondary: var(--slate);
    --text-muted: var(--ash);
    --accent: var(--sky);
    --accent-hover: var(--sky-dark);
    --accent-glow: var(--sky-light);
    --accent-light: var(--sky-light);
    --success: var(--sage);
    --success-bg: var(--sage-light);
    --danger: var(--coral);
    --danger-bg: var(--coral-light);
    --warning: var(--amber);
    --warning-bg: var(--amber-light);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.3);
}


/* ========== RESET & BASE ========== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}


/* ========== NAVIGATION ========== */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: var(--space-5) var(--space-4);
    z-index: 100;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.nav.hidden { display: none; }

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 var(--space-2) var(--space-5);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-4);
    flex-shrink: 0;
}

.nav-logo { width: 26px; height: 26px; flex-shrink: 0; }
.nav-logo img { width: 100%; height: 100%; object-fit: contain; }

/* Sellabrew Teardrop Logo */
.sbf-logo { display: inline-block; vertical-align: middle; }
.sbf-logo svg { display: block; }

.nav-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.nav-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover {
    background: var(--accent-glow);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}

.nav-icon { font-size: 18px; }

.nav-logout {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.nav-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}


/* ========== MAIN CONTENT ========== */

#page-content {
    margin-left: 0;
    padding: var(--space-6);
    min-height: 100vh;
    transition: margin-left 0.3s;
}

body.authenticated #page-content {
    margin-left: 240px;
}


/* ========== PAGE HEADER ========== */

.page-header {
    margin-bottom: var(--space-6);
}

.page-header h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}



.page-header p {
    color: var(--text-secondary);
    font-size: 15px;
}


/* ========== CARDS ========== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    box-shadow: var(--shadow);
    border-color: var(--sky-glow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
}

.card-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}


/* ========== STAT CARDS ========== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}



.stat-card:hover { box-shadow: var(--shadow); }

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.stat-value.success { color: var(--success); }
.stat-value.danger { color: var(--danger); }
.stat-value.accent { color: var(--accent); }


/* ========== BUTTONS ========== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--sky);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 180, 216, 0.2);
}

.btn-primary:hover {
    background: var(--sky-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 180, 216, 0.25);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid transparent;
}

.btn-danger:hover { border-color: var(--danger); }

.btn-success {
    background: var(--success);
    color: white;
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: var(--radius); }


/* ========== FORMS ========== */

.form-group { margin-bottom: var(--space-5); }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-card);
}

.form-input::placeholder { color: var(--text-muted); }


/* ========== SEARCH BOX ========== */

.search-container {
    position: relative;
    max-width: 600px;
}

.search-input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--text-muted);
    pointer-events: none;
}


/* ========== TABLES ========== */

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

table { width: 100%; border-collapse: collapse; }

th, td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-light); }


/* ========== BADGES ========== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-neutral { background: var(--bg-input); color: var(--text-secondary); }


/* ========== PROGRESS BAR ========== */

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--sky);
    transition: width 0.5s ease;
}


/* ========== RATIO BAR ========== */

.ratio-bar { display: flex; align-items: center; gap: var(--space-2); }

.ratio-bar-track {
    flex: 1;
    height: 8px;
    background: var(--danger-bg);
    border-radius: 4px;
    overflow: hidden;
}

.ratio-bar-fill {
    height: 100%;
    background: var(--success);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.ratio-value {
    font-size: 13px;
    font-weight: 700;
    min-width: 45px;
    text-align: right;
}


/* ========== EMPTY STATE ========== */

.empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-5);
    color: var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: var(--space-4); opacity: 0.4; }

.empty-state h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
}

.empty-state p { font-size: 14px; margin-bottom: var(--space-5); }


/* ========== SPINNER ========== */

.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

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

.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10);
    gap: var(--space-4);
    color: var(--text-muted);
}


/* ========== LOGIN PAGE ========== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-5);
    background: var(--bg-primary);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-6);
}

.login-header .logo { font-size: 48px; margin-bottom: var(--space-4); }

.login-header h1 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
}

.login-header p { color: var(--text-secondary); font-size: 14px; }

.login-footer {
    text-align: center;
    margin-top: var(--space-5);
    font-size: 13px;
    color: var(--text-muted);
}

.login-footer a { color: var(--accent); font-weight: 600; }

.form-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: var(--space-4);
    display: none;
}

.form-error.visible { display: block; }


/* ========== CONNECT CARDS (Settings) ========== */

.connect-card {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    padding: var(--space-5);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.connect-icon { font-size: 40px; }
.connect-info { flex: 1; }

.connect-info h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: var(--space-1);
}

.connect-info p { color: var(--text-secondary); font-size: 13px; }

.connect-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.connect-status.connected { color: var(--success); }
.connect-status.disconnected { color: var(--text-muted); }


/* ========== FILTER BAR ========== */

.filter-bar {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.filter-btn:hover { border-color: var(--accent); color: var(--accent); }

.filter-btn.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}


/* ========== PAGINATION ========== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-5);
}

.pagination button {
    padding: var(--space-2) var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text-muted); }


/* ========== TOASTS ========== */

.toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--accent); color: white; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}


/* ========== MOBILE MENU BUTTON ========== */

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 200;
    width: 40px; height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.mobile-menu-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}

.nav-overlay.active {
    display: block;
    opacity: 1;
}


/* ========== COMPONENT CLASSES ========== */
/* インラインスタイルの代替クラス群 */

/* --- Brand Card (dashboard / auto-search) --- */
.brand-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 8px; margin: 2px 0; border-radius: 6px; font-size: 13px;
    text-decoration: none; color: inherit; transition: background 0.15s;
}
.brand-card:hover { filter: brightness(1.05); }
.brand-card--warning { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2); }
.brand-card--success { background: rgba(34,197,94,0.06); border: 1px solid rgba(34,197,94,0.15); }
.brand-card--danger  { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.15); }
.brand-card__name  { font-weight: 500; }
.brand-card__meta  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.brand-card__stats { text-align: right; white-space: nowrap; }
.brand-card__ratio { font-weight: 600; font-size: 12px; }
.brand-card__time  { font-size: 9px; color: var(--text-muted); }

/* --- Text Utilities --- */
.text-xs         { font-size: 9px; }
.text-sm         { font-size: 11px; }
.text-base       { font-size: 13px; }
.text-lg         { font-size: 14px; }
.text-xl         { font-size: 16px; }
.text-muted      { color: var(--text-muted); }
.text-muted-sm   { font-size: 10px; color: var(--text-muted); }
.text-muted-xs   { font-size: 9px; color: var(--text-muted); }
.text-secondary  { color: var(--text-secondary); }
.text-secondary-sm { font-size: 13px; color: var(--text-secondary); }
.text-accent     { color: var(--accent); }
.text-success    { color: var(--success); }
.text-danger     { color: var(--danger); }
.text-warning    { color: var(--warning); }
.fw-medium       { font-weight: 500; }
.fw-semi         { font-weight: 600; }
.fw-bold         { font-weight: 700; }
.fw-bold-sm      { font-size: 13px; font-weight: 600; }

/* --- Settings Info Row --- */
.info-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 13px; color: var(--text-secondary); }
.info-value { font-size: 14px; font-weight: 600; }

/* --- Section Title --- */
.section-title {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    display: block; margin-bottom: 6px;
}

/* --- Pill Tag (category, status) --- */
.pill-tag {
    display: inline-block; padding: 2px 8px; border-radius: 8px;
    font-size: 10px; white-space: nowrap;
}
.pill-tag--accent  { background: rgba(139,92,246,0.1); color: rgba(139,92,246,0.8); }
.pill-tag--success { background: var(--success-bg); color: var(--success); }
.pill-tag--warning { background: var(--warning-bg); color: var(--warning); }
.pill-tag--muted   { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* --- Mode Toggle Button (Fast/Deep, Keyword/Brand) --- */
.toggle-group {
    display: flex; border-radius: 8px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
}
.toggle-btn {
    padding: 6px 14px; border: none; border-left: 1px solid var(--border);
    font-size: 12px; font-weight: 600; cursor: pointer;
    background: var(--bg-input); color: var(--text-muted);
    transition: all 0.15s; font-family: inherit;
}
.toggle-btn:first-child { border-left: none; }
.toggle-btn--active {
    background: var(--accent-glow); color: var(--accent);
}

/* --- Scroll List --- */
.scroll-list    { max-height: 400px; overflow-y: auto; padding: 8px; }
.scroll-list-sm { max-height: 300px; overflow-y: auto; padding: 8px; }

/* --- Empty Message --- */
.empty-msg {
    padding: 16px; color: var(--text-muted); font-size: 13px; text-align: center;
}

/* --- Icon sizes --- */
.icon-md { font-size: 16px; }
.icon-lg { font-size: 20px; }
.icon-xl { font-size: 24px; }

/* --- Plan Badge --- */
.plan-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; border-radius: 8px;
    font-size: 11px; font-weight: 600;
}
.plan-badge--pro   { background: rgba(0,180,216,0.1); color: var(--accent); }
.plan-badge--ultra  { background: rgba(245,158,11,0.1); color: #f59e0b; }
.plan-badge--free   { background: var(--bg-input); color: var(--text-muted); }

/* --- Mini Progress Bar --- */
.mini-progress {
    width: 80px; height: 4px; background: rgba(255,255,255,0.08);
    border-radius: 2px; overflow: hidden;
}
.mini-progress__fill {
    height: 100%; border-radius: 2px; transition: width 0.3s;
}

/* --- Flex Utilities --- */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-col     { display: flex; flex-direction: column; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }

/* --- Spacing Utilities --- */
.mt-xs { margin-top: 4px; }   .mb-xs { margin-bottom: 4px; }
.mt-sm { margin-top: 8px; }   .mb-sm { margin-bottom: 8px; }
.mt-md { margin-top: 12px; }  .mb-md { margin-bottom: 12px; }
.mt-lg { margin-top: 20px; }  .mb-lg { margin-bottom: 20px; }
.mt-xl { margin-top: 24px; }  .mb-xl { margin-bottom: 24px; }
.p-sm  { padding: 8px; }
.p-md  { padding: 12px; }
.p-lg  { padding: 16px; }

/* --- Lock / Disabled overlay --- */
.lock-overlay {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: 10px;
    background: rgba(100,116,139,0.05); border: 1px solid var(--border);
    opacity: 0.7;
}

/* --- Hint Tooltip --- */
.hint-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; border-radius: 50%;
    background: rgba(0,0,0,0.06); font-size: 9px; font-weight: 700;
    color: var(--text-muted); cursor: help; margin-left: 2px;
}


/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
    /* Show hamburger */
    .mobile-menu-btn { display: flex; }

    /* Nav sidebar */
    .nav {
        transform: translateX(-100%);
        width: 280px;
        max-width: 85vw;
        box-shadow: var(--shadow-lg);
    }
    .nav.open { transform: translateX(0); }

    /* Main content */
    body.authenticated #page-content { margin-left: 0; padding-top: 56px; }
    #page-content { padding: var(--space-3); }

    /* Page header */
    .page-header { margin-bottom: var(--space-3); }
    .page-header h1 { font-size: 18px; }
    .page-header p { font-size: 13px; }

    /* --- Stats Grid --- */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
    .stat-card { padding: var(--space-3); }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 9px; }

    /* --- Cards --- */
    .card { padding: var(--space-3); border-radius: var(--radius-sm); }
    .card-header { margin-bottom: var(--space-3); flex-wrap: wrap; gap: 8px; }
    .card-title { font-size: 13px; }

    /* --- Filter pills: horizontal scroll --- */
    #filter-pills {
        display: flex !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        flex-wrap: nowrap !important;
        gap: 0;
        max-width: 100%;
    }
    #filter-pills::-webkit-scrollbar { display: none; }
    #filter-pills .filter-pill {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 11px !important;
        padding: 5px 10px !important;
    }

    /* --- Brand list table → card layout --- */
    .table-container { border: none; box-shadow: none; overflow: visible; }
    .table-container table { min-width: 0; }
    .table-container thead { display: none; }
    .table-container tbody { display: flex; flex-direction: column; gap: 8px; }
    .table-container tbody tr {
        display: flex;
        flex-wrap: wrap;
        padding: 12px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        gap: 6px 12px;
        align-items: center;
    }
    .table-container tbody tr:hover td { background: transparent; }
    .table-container tbody td {
        padding: 0;
        border-bottom: none;
        font-size: 13px;
    }
    /* Brand name: full width */
    .table-container tbody td:first-child {
        flex: 1 1 100%;
        font-size: 14px;
    }
    /* Category */
    .table-container tbody td:nth-child(2) {
        flex: 1 1 100%;
        order: 5;
    }
    /* Status badge */
    .table-container tbody td:nth-child(3) {
        order: 2;
    }
    /* Ratio bar */
    .table-container tbody td:nth-child(4) {
        flex: 1 1 40%;
        order: 3;
    }
    /* Check count */
    .table-container tbody td:nth-child(5) {
        font-size: 12px;
        color: var(--text-muted);
        order: 4;
    }
    /* Last checked */
    .table-container tbody td:nth-child(6) {
        font-size: 11px;
        color: var(--text-muted);
        order: 6;
        margin-left: auto;
    }

    /* --- Sort/search row --- */
    #sort-select { font-size: 11px !important; padding: 6px 8px !important; }
    #brand-search-input { max-width: none !important; font-size: 14px !important; }

    /* --- Download modal --- */
    #download-modal > div {
        width: 95vw !important;
        max-width: none !important;
        padding: 16px !important;
    }

    /* --- Buttons --- */
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-lg { padding: 12px 20px; font-size: 14px; }

    /* --- Forms --- */
    .form-input, .form-select, textarea { font-size: 16px !important; /* prevent iOS zoom */ }

    /* --- Search page: mode/scope toggles --- */
    #search-mode-toggle, #search-scope-toggle {
        flex-shrink: 0;
    }
    #search-mode-toggle .mode-btn,
    #search-scope-toggle .scope-btn {
        font-size: 11px !important;
        padding: 6px 10px !important;
    }

    /* --- ASIN detail panel table → card on mobile --- */
    #asin-detail-panel .table-container tbody td:first-child {
        flex: 0 0 auto;
    }
    #asin-detail-panel .table-container tbody td:nth-child(2) {
        flex: 1 1 60%;
        order: 1;
    }

    /* --- Settings page --- */
    /* Account info grid */
    #account-info > div {
        grid-template-columns: 1fr !important;
    }
    /* Plan table scroll */
    #plan-section .table-container,
    #plan-section table {
        min-width: 0;
    }
    #plan-section table {
        font-size: 12px;
    }
    #plan-section th,
    #plan-section td {
        padding: 6px 4px;
    }
    /* Keep plan table as table (not card) but allow scroll */
    #plan-section .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
    }
    #plan-section .table-container thead { display: table-header-group; }
    #plan-section .table-container tbody { display: table-row-group; }
    #plan-section .table-container tbody tr {
        display: table-row;
        padding: 0;
        background: none;
        border: none;
        border-radius: 0;
        gap: 0;
    }
    #plan-section .table-container tbody td {
        padding: 6px 4px;
        border-bottom: 1px solid var(--border);
        display: table-cell;
    }
    /* Billing section */
    #billing-section span {
        font-size: 12px !important;
    }
    /* Password section */
    #password-section > div { max-width: 100% !important; }

    /* --- Dashboard: chart containers --- */
    #time-chart-container, #brands-chart-container {
        max-height: 200px;
    }

    /* --- Two-column grids → single column --- */
    .mobile-stack { grid-template-columns: 1fr !important; }

    /* --- Footer --- */
    #site-footer div { flex-direction: column; gap: 8px !important; }

    /* --- Toast --- */
    .toast-container { left: 12px; right: 12px; top: 12px; }
    .toast { max-width: none; }

    /* --- Search Status Widget --- */
    .search-status-widget { max-height: 120px; }

    /* --- Global bulk apply section --- */
    #global-bulk-apply-section > div {
        flex-direction: column;
        gap: 8px !important;
        align-items: stretch !important;
    }

    /* --- Announcement banner --- */
    #announcement-banner {
        max-width: calc(100vw - 24px) !important;
        right: 12px !important;
        left: 12px !important;
    }
}


/* ========== CLICKABLE ROW ========== */

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-glow); }


/* ========== SEARCH STATUS WIDGET ========== */

.search-status-widget {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    margin-top: auto; /* 左サイドバーの下端に寄せる */
}

.ssw-container {
    border-top: 1px solid var(--border);
    padding-top: var(--space-3);
    margin-top: var(--space-3);
}
.ssw-container.ssw-setup {
    margin-top: 0;
    padding-top: var(--space-2);
}

/* ── 固定3行レイアウト ── */
.ssw-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
}
.ssw-row:last-child { border-bottom: none; }

.ssw-row-icon {
    flex-shrink: 0;
    width: 16px;
    font-size: 13px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ssw-row-label {
    flex-shrink: 0;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 11px;
}

.ssw-row-state {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ssw-state-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ssw-state-icon { font-size: 12px; flex-shrink: 0; }

.ssw-state-running { background: var(--accent-glow); border-radius: 4px; }
.ssw-state-running .ssw-row-state { color: var(--accent); font-weight: 600; }

.ssw-state-done .ssw-row-state { color: var(--text-secondary); }
.ssw-state-failed .ssw-row-state { color: var(--danger); font-weight: 600; }

.ssw-cancel {
    color: var(--danger);
    text-decoration: none;
    flex-shrink: 0;
    font-size: 12px;
}
.ssw-cancel:hover { text-decoration: underline; }

/* セットアップ進捗のプログレスバー */
.ssw-bar {
    height: 4px;
    background: var(--accent-glow);
    border-radius: 2px;
    margin: 0 4px 6px 22px;
    overflow: hidden;
}
.ssw-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.5s;
}

.ssw-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 var(--space-1) var(--space-2);
}

.ssw-empty {
    font-size: 12px;
    color: var(--text-muted);
    padding: var(--space-2) var(--space-1);
}

.ssw-job {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    margin-bottom: 6px;
    font-size: 12px;
    transition: border-color 0.3s;
}

.ssw-job:last-child { margin-bottom: 0; }

.ssw-job-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--space-1);
}

.ssw-type {
    font-weight: 600;
    font-size: 11px;
    color: var(--text-primary);
}

.ssw-query {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ssw-running {
    border-color: var(--sky-glow);
    animation: ssw-pulse 2s ease-in-out infinite;
}

@keyframes ssw-pulse {
    0%, 100% { border-color: rgba(0, 180, 216, 0.1); }
    50% { border-color: rgba(0, 180, 216, 0.3); }
}

.ssw-progress {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-weight: 600;
    font-size: 11px;
}

.ssw-spinner {
    display: inline-block;
    width: 12px; height: 12px;
    border: 2px solid var(--sky-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.ssw-completed { border-color: var(--sage-light); }
.ssw-failed { border-color: var(--coral-light); }

.ssw-result {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 11px;
    color: var(--text-secondary);
}

.ssw-check { font-size: 12px; }
.ssw-ago { margin-left: auto; color: var(--text-muted); font-size: 10px; }

.ssw-details {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    padding-left: 2px;
}


/* ========== THEME TOGGLE ========== */

.nav-theme-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: var(--space-2);
    flex-shrink: 0;
}

.nav-theme-toggle:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--accent-glow);
}

:root[data-theme="light"] .mode-btn {
    border: none !important;
}