/**
 * AgentExit - Base CSS
 * Design: OpenAI-inspired monochrome dark/light theme
 * Fonts: LINE Seed JP / Plus Jakarta Sans / JetBrains Mono
 * Icons: Lucide Icons
 */

/* ============================================================
   1. CSS Variables
   ============================================================ */

:root {
    /* Background */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-surface: #ececf1;
    --bg-dark: #0d0d0d;
    --bg-tertiary: #d9d9e3;

    /* Text */
    --text-primary: #0d0d0d;
    --text-secondary: #6e6e80;
    --text-muted: #8e8ea0;
    --text-tertiary: #8e8ea0;
    --text-white: #ffffff;

    /* Accent → black-based (OpenAI style) */
    --accent-blue: #0d0d0d;
    --accent-blue-dark: #000000;
    --accent-blue-light: #f7f7f8;
    --accent-light: #f7f7f8;

    /* Link color */
    --link-color: #2563eb;
    --link-hover: #1d4ed8;

    /* Status colors */
    --accent-red: #dc2626;
    --accent-red-light: #fef2f2;
    --accent-red-dark: #b91c1c;
    --accent-green: #16a34a;
    --accent-green-light: #f0fdf4;
    --accent-green-dark: #15803d;
    --accent-orange: #ea580c;
    --accent-orange-light: #fff7ed;
    --accent-yellow: #d97706;
    --accent-yellow-light: #fffbeb;

    /* AgentExit theme key: ae- */
    --ae-accent: #0d0d0d;
    --ae-accent-hover: #000000;
    --ae-accent-light: #f7f7f8;
    --ae-accent-muted: rgba(13, 13, 13, 0.08);

    /* Border */
    --border: #e5e5e5;
    --border-light: #f0f0f0;
    --border-strong: #c5c5d2;
    --border-color: #e5e5e5;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans: 'LINE Seed JP', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-display: 'Plus Jakarta Sans', -apple-system, sans-serif;

    /* Layout */
    --container: 1140px;
    --header-h: 64px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Z-index */
    --z-dropdown: 1000;
    --z-header: 1100;
    --z-modal: 2000;
    --z-toast: 2100;
    --z-mobile-menu: 1200;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-surface: #2a2a2a;
    --bg-dark: #000000;
    --bg-tertiary: #2a2a2a;

    --text-primary: #ececec;
    --text-secondary: #a0a0a0;
    --text-muted: #6b6b6b;
    --text-tertiary: #6b6b6b;

    --accent-blue: #ffffff;
    --accent-blue-dark: #e0e0e0;
    --accent-blue-light: rgba(255, 255, 255, 0.08);
    --accent-light: rgba(255, 255, 255, 0.08);

    --link-color: #60a5fa;
    --link-hover: #93bbfd;

    --ae-accent: #ffffff;
    --ae-accent-hover: #e0e0e0;
    --ae-accent-light: rgba(255, 255, 255, 0.08);
    --ae-accent-muted: rgba(255, 255, 255, 0.06);

    --border: #2e2e2e;
    --border-light: #1e1e1e;
    --border-strong: #404040;
    --border-color: #2e2e2e;

    --accent-red-light: rgba(220, 38, 38, 0.15);
    --accent-green-light: rgba(22, 163, 74, 0.15);
    --accent-orange-light: rgba(234, 88, 12, 0.15);
    --accent-yellow-light: rgba(217, 119, 6, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   2. Reset & Base
   ============================================================ */

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

[hidden] { display: none !important; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 32px);
    font-size: 16px;
    background: var(--bg-dark);
}

main [id] { scroll-margin-top: calc(var(--header-h) + 32px); }

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body.menu-open { overflow: hidden; }

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color var(--transition-base);
}
a:hover { color: var(--link-hover); }

img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button { font-family: var(--font-sans); cursor: pointer; }
input, textarea, select { font-family: var(--font-sans); }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    line-height: 1.35;
    color: var(--text-primary);
}

.lucide-icon { width: 16px; height: 16px; flex-shrink: 0; }

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
}
.container--narrow { max-width: 800px; }
.container--wide   { max-width: 1320px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================================
   3. Header
   ============================================================ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    z-index: var(--z-header);
    transition: background var(--transition-base), border-color var(--transition-base);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 16px;
}

/* Logo */
.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    text-decoration: none;
    flex-shrink: 0;
    transition: opacity var(--transition-base);
    letter-spacing: -0.01em;
}
.header-logo:hover { opacity: 0.7; color: var(--text-primary); }
.header-logo svg { flex-shrink: 0; width: 26px; height: 26px; }

.logo-text {
    display: inline-flex;
    align-items: baseline;
    letter-spacing: 0.01rem;
    font-weight: 800;
}

.logo-accent {
    font-weight: 800;
    color: var(--link-color);
}

[data-theme="dark"] .logo-accent { color: #60a5fa; }

/* Header nav */
.header-nav {
    display: flex;
    align-items: center;
    gap: 24px;
    flex: 1;
    justify-content: center;
}

.header-nav-link {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    padding: 4px 0;
    transition: color var(--transition-base);
    white-space: nowrap;
}
.header-nav-link:hover { color: var(--text-primary); }
.header-nav-link.active { color: var(--text-primary); font-weight: 600; }

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Header user dropdown */
.header-user {
    position: relative;
}

.header-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-base), border-color var(--transition-base);
}
.header-user-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-strong);
}

.header-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ae-accent);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.header-dropdown,
.header-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.header-dropdown.open,
.header-dropdown.is-open,
.header-user-dropdown.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.header-dropdown-section {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
}
.header-dropdown-section:last-child { border-bottom: none; }

.header-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast);
    white-space: nowrap;
}
.header-dropdown-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.header-dropdown-item.danger { color: var(--accent-red); }
.header-dropdown-item.danger:hover { background: var(--accent-red-light); }

.header-dropdown-label {
    padding: 6px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Hamburger */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 8px;
    transition: background var(--transition-base);
}
.hamburger-btn:hover { background: var(--bg-secondary); }

.hamburger-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform var(--transition-base), opacity var(--transition-base);
}

.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   4. Mobile Menu
   ============================================================ */

.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-mobile-menu) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}
.mobile-menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    background: var(--bg-primary);
    z-index: var(--z-mobile-menu);
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.mobile-menu.open { transform: translateX(0); }

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
}

.mobile-menu-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    transition: background var(--transition-base);
}
.mobile-menu-close:hover { background: var(--bg-secondary); }

.mobile-menu-nav {
    padding: 12px 0;
    flex: 1;
}

.mobile-menu-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition-fast);
}
.mobile-menu-nav a:hover { background: var(--bg-secondary); color: var(--text-primary); }
.mobile-menu-nav a.active {
    background: var(--ae-accent-light);
    font-weight: 600;
}

.mobile-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.mobile-menu-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================================
   5. Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background var(--transition-base),
        color var(--transition-base),
        border-color var(--transition-base),
        box-shadow var(--transition-base),
        opacity var(--transition-base);
    -webkit-user-select: none;
    user-select: none;
    vertical-align: middle;
}
.btn:focus-visible {
    outline: 2px solid var(--ae-accent);
    outline-offset: 2px;
}
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary */
.btn-primary {
    background: var(--ae-accent);
    color: var(--bg-primary);
    border-color: var(--ae-accent);
}
.btn-primary:hover {
    background: var(--ae-accent-hover);
    border-color: var(--ae-accent-hover);
    color: var(--bg-primary);
}

[data-theme="dark"] .btn-primary {
    background: #ffffff;
    color: #0d0d0d;
    border-color: #ffffff;
}
[data-theme="dark"] .btn-primary:hover {
    background: #e0e0e0;
    border-color: #e0e0e0;
    color: #0d0d0d;
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-outline:hover {
    background: var(--bg-secondary);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* Secondary */
.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--bg-surface);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* Danger */
.btn-danger {
    background: var(--accent-red);
    color: #ffffff;
    border-color: var(--accent-red);
}
.btn-danger:hover {
    background: var(--accent-red-dark);
    border-color: var(--accent-red-dark);
    color: #ffffff;
}

/* Sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    gap: 6px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
    border-radius: var(--radius-md);
}

/* Block */
.btn-block {
    width: 100%;
    justify-content: center;
}

/* Icon only */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-sm);
}
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-icon.btn-lg { width: 44px; height: 44px; }

/* ============================================================
   6. Forms
   ============================================================ */

.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.4;
}

.form-required {
    color: var(--accent-red);
    margin-left: 2px;
}

.form-input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    line-height: 1.5;
    transition:
        border-color var(--transition-base),
        box-shadow var(--transition-base),
        background var(--transition-base);
    -webkit-appearance: none;
    appearance: none;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
    outline: none;
    border-color: var(--ae-accent);
    box-shadow: 0 0 0 3px var(--ae-accent-muted);
}
.form-input:disabled {
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: not-allowed;
}
.form-input.error { border-color: var(--accent-red); }
.form-input.error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12); }

/* Select */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    cursor: pointer;
}

/* Textarea */
.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* Hint */
.form-hint {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.5;
}

/* Error message */
.form-error {
    display: block;
    font-size: 13px;
    color: var(--accent-red);
    margin-top: 5px;
    line-height: 1.5;
}

/* Checkbox / Radio */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.form-checkbox,
.form-radio {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    border: 2px solid var(--border-strong);
    background: var(--bg-primary);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background var(--transition-base), border-color var(--transition-base);
}
.form-checkbox { border-radius: 4px; }
.form-radio    { border-radius: 50%; }

.form-checkbox:checked {
    background: var(--ae-accent);
    border-color: var(--ae-accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}
.form-radio:checked {
    border-color: var(--ae-accent);
    background: var(--bg-primary);
    box-shadow: inset 0 0 0 4px var(--ae-accent);
}

.form-check-label {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    cursor: pointer;
}

/* Password wrapper */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 4px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-base);
    border-radius: var(--radius-sm);
}
.password-toggle:hover { color: var(--text-primary); }

/* Input with icon */
.input-icon-wrapper {
    position: relative;
}
.input-icon-wrapper .form-input { padding-left: 40px; }
.input-icon-wrapper .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* ============================================================
   7. Cards
   ============================================================ */

.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow var(--transition-base), border-color var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-body { padding: 24px; }

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* Elevated card */
.card--elevated {
    box-shadow: var(--shadow-md);
    border-color: transparent;
}
.card--elevated:hover { box-shadow: var(--shadow-lg); }

/* Flat card */
.card--flat { box-shadow: none; }
.card--flat:hover { box-shadow: var(--shadow-sm); }

/* ============================================================
   8. Alerts & Toast
   ============================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.alert-icon { flex-shrink: 0; margin-top: 1px; }

.alert-success {
    background: var(--accent-green-light);
    color: var(--accent-green-dark);
}
.alert-error {
    background: var(--accent-red-light);
    color: var(--accent-red-dark);
}
.alert-warning {
    background: var(--accent-yellow-light);
    color: var(--accent-yellow);
}
.alert-info {
    background: #eff6ff;
    color: #1e40af;
}

[data-theme="dark"] .alert-info {
    background: rgba(37, 99, 235, 0.15);
    color: #93bbfd;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-dark);
    color: #ffffff;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastSlideIn var(--transition-slow) ease both;
}

.toast.toast-success { background: var(--accent-green); }
.toast.toast-error   { background: var(--accent-red); }
.toast.toast-warning { background: var(--accent-orange); }

.toast.hiding { animation: toastSlideOut var(--transition-slow) ease both; }

@keyframes toastSlideIn {
    from { transform: translateX(calc(100% + 24px)); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(calc(100% + 24px)); opacity: 0; }
}

/* ============================================================
   9. Badges
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: var(--radius-full);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge-primary {
    background: var(--ae-accent-light);
    color: var(--ae-accent);
    border: 1px solid var(--border);
}
.badge-success {
    background: var(--accent-green-light);
    color: var(--accent-green-dark);
}
.badge-warning {
    background: var(--accent-yellow-light);
    color: var(--accent-yellow);
}
.badge-danger {
    background: var(--accent-red-light);
    color: var(--accent-red-dark);
}
.badge-info {
    background: #eff6ff;
    color: #1e40af;
}
.badge-orange {
    background: var(--accent-orange-light);
    color: var(--accent-orange);
}
.badge-muted {
    background: var(--bg-surface);
    color: var(--text-muted);
}

/* M&A category badges */
.badge-saas      { background: #eff6ff; color: #1e40af; }
.badge-ecommerce { background: #fdf4ff; color: #7e22ce; }
.badge-media     { background: #fff7ed; color: #9a3412; }
.badge-agency    { background: #f0fdf4; color: #15803d; }
.badge-app       { background: #fef9c3; color: #a16207; }
.badge-other     { background: var(--bg-surface); color: var(--text-secondary); }

[data-theme="dark"] .badge-saas      { background: rgba(37, 99, 235, 0.15); color: #93bbfd; }
[data-theme="dark"] .badge-ecommerce { background: rgba(126, 34, 206, 0.15); color: #c4b5fd; }
[data-theme="dark"] .badge-media     { background: rgba(154, 52, 18, 0.15); color: #fdba74; }
[data-theme="dark"] .badge-agency    { background: rgba(21, 128, 61, 0.15); color: #86efac; }
[data-theme="dark"] .badge-app       { background: rgba(161, 98, 7, 0.15); color: #fde68a; }
[data-theme="dark"] .badge-info      { background: rgba(37, 99, 235, 0.15); color: #93bbfd; }

/* ============================================================
   10. Footer
   ============================================================ */

.site-footer {
    background: var(--bg-dark);
    color: #a0a0a0;
    margin-top: auto;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    gap: 48px;
    padding: 56px 0 48px;
}

.footer-brand { max-width: 280px; flex-shrink: 0; }

.footer-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 20px;
    text-decoration: none;
    margin-bottom: 14px;
    transition: opacity var(--transition-base);
}
.footer-logo:hover { opacity: 0.7; color: #ffffff; }
.footer-logo-accent { color: #60a5fa; }

.footer-brand-desc {
    font-size: 14px;
    color: #6b6b6b;
    line-height: 1.7;
}

.footer-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
    flex: 1;
}

.footer-col-title {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 14px;
}

.footer-col-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-col-links a {
    font-size: 14px;
    color: #6b6b6b;
    text-decoration: none;
    transition: color var(--transition-base);
}
.footer-col-links a:hover { color: #ffffff; }

.footer-bottom {
    border-top: 1px solid #1e1e1e;
    padding: 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.footer-copyright {
    font-size: 13px;
    color: #4a4a4a;
}

.footer-legal-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.footer-legal-links a {
    font-size: 13px;
    color: #4a4a4a;
    text-decoration: none;
    transition: color var(--transition-base);
}
.footer-legal-links a:hover { color: #a0a0a0; }

/* ============================================================
   11. Utilities
   ============================================================ */

/* Text alignment */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

/* Text color */
.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-success   { color: var(--accent-green) !important; }
.text-danger    { color: var(--accent-red) !important; }
.text-warning   { color: var(--accent-yellow) !important; }
.text-white     { color: #ffffff !important; }
.text-link      { color: var(--link-color) !important; }

/* Text size */
.text-xs  { font-size: 12px; }
.text-sm  { font-size: 13px; }
.text-base{ font-size: 15px; }
.text-lg  { font-size: 18px; }
.text-xl  { font-size: 22px; }
.text-2xl { font-size: 28px; }

/* Text weight */
.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }

/* Display */
.d-flex   { display: flex; }
.d-grid   { display: grid; }
.d-block  { display: block; }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }
.d-none   { display: none !important; }

/* Flex utilities */
.align-center    { align-items: center; }
.align-start     { align-items: flex-start; }
.align-end       { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-wrap       { flex-wrap: wrap; }
.flex-col        { flex-direction: column; }
.flex-1          { flex: 1; }
.flex-shrink-0   { flex-shrink: 0; }

/* Gap */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.gap-5 { gap: 32px; }

/* Margin top */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mt-5 { margin-top: 32px; }
.mt-6 { margin-top: 48px; }

/* Margin bottom */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mb-5 { margin-bottom: 32px; }
.mb-6 { margin-bottom: 48px; }

/* Padding */
.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }

/* Width */
.w-full  { width: 100%; }
.w-auto  { width: auto; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }

/* Responsive visibility */
.sp-only { display: none; }
.pc-only { display: block; }

/* Divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

/* ============================================================
   12. Theme Toggle
   ============================================================ */

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition:
        background var(--transition-base),
        color var(--transition-base),
        border-color var(--transition-base);
    flex-shrink: 0;
}
.theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* Sun icon: show in dark mode; hide in light mode */
.icon-sun  { display: none; }
.icon-moon { display: block; }

[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ============================================================
   13. Page Sections
   ============================================================ */

.page-section {
    padding: calc(var(--header-h) + 40px) 0 80px;
}

.page-section--sm {
    padding: calc(var(--header-h) + 24px) 0 48px;
}

.page-section--center {
    text-align: center;
}

.page-section--dark {
    background: var(--bg-dark);
    color: #ffffff;
}

.page-section--secondary {
    background: var(--bg-secondary);
}

.section-title {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.section-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 560px;
}
.page-section--center .section-subtitle { margin-left: auto; margin-right: auto; }

.page-hero {
    padding: calc(var(--header-h) + 64px) 0 80px;
}

/* 404 page */
.page-404 {
    padding: calc(var(--header-h) + 80px) 0 80px;
    text-align: center;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-404-code {
    font-family: var(--font-display);
    font-size: 120px;
    font-weight: 900;
    color: var(--border-strong);
    line-height: 1;
    letter-spacing: -0.06em;
    margin-bottom: 16px;
    display: block;
}

.page-404-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.page-404-desc {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: calc(var(--header-h) + 12px) 0 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-base);
}
.breadcrumb a:hover { color: var(--text-primary); }

.breadcrumb-sep { color: var(--border-strong); }

.breadcrumb-current {
    color: var(--text-secondary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

/* ============================================================
   14. Pagination
   ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 32px 0;
    flex-wrap: wrap;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition:
        background var(--transition-base),
        color var(--transition-base),
        border-color var(--transition-base);
    cursor: pointer;
}
.pagination-link:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.pagination-link.active {
    background: var(--ae-accent);
    color: var(--bg-primary);
    border-color: var(--ae-accent);
    font-weight: 700;
    pointer-events: none;
}

[data-theme="dark"] .pagination-link.active {
    background: #ffffff;
    color: #0d0d0d;
    border-color: #ffffff;
}

.pagination-link.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    font-size: 14px;
    color: var(--text-muted);
}

/* ============================================================
   15. Empty State
   ============================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 64px 24px;
    gap: 12px;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.empty-state-desc {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 360px;
    line-height: 1.6;
}

.empty-state-action { margin-top: 8px; }

/* ============================================================
   16. Loading / Spinner
   ============================================================ */

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

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.spinner-white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

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

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
}
[data-theme="dark"] .loading-overlay { background: rgba(13, 13, 13, 0.8); }

/* Skeleton loader */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-surface) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ============================================================
   17. Modal
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
    backdrop-filter: blur(2px);
}
.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-slow);
}
.modal.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    transform: translateY(12px) scale(0.98);
    transition: transform var(--transition-slow);
}
.modal.open .modal-dialog { transform: translateY(0) scale(1); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}
.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-base), color var(--transition-base);
}
.modal-close:hover { background: var(--bg-secondary); color: var(--text-primary); }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   18. Table
   ============================================================ */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    white-space: nowrap;
    font-size: 13px;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-secondary); }

/* ============================================================
   19. Tabs
   ============================================================ */

.tabs {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition:
        color var(--transition-base),
        border-color var(--transition-base);
    white-space: nowrap;
    cursor: pointer;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-sans);
}
.tab-link:hover { color: var(--text-primary); }
.tab-link.active {
    color: var(--text-primary);
    border-bottom-color: var(--ae-accent);
    font-weight: 600;
}

/* ============================================================
   20. Responsive
   ============================================================ */

@media (max-width: 768px) {

    /* Container */
    .container { padding: 0 16px; }

    /* Visibility */
    .sp-only { display: block; }
    .pc-only { display: none; }

    .d-flex.sp-only   { display: flex; }
    .d-inline.sp-only { display: inline; }

    /* Header */
    .header-nav    { display: none; }
    .hamburger-btn { display: flex; }

    .header-actions .btn-outline,
    .header-actions .btn-ghost {
        display: none;
    }

    /* Sections */
    .page-section    { padding: calc(var(--header-h) + 24px) 0 56px; }
    .page-section--sm{ padding: calc(var(--header-h) + 16px) 0 36px; }
    .page-hero       { padding: calc(var(--header-h) + 48px) 0 56px; }

    /* Section typography */
    .section-title { font-size: 26px; }
    .section-subtitle { font-size: 15px; }

    /* Footer */
    .footer-top {
        flex-direction: column;
        gap: 32px;
        padding: 40px 0 32px;
    }
    .footer-brand { max-width: 100%; }
    .footer-nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .footer-legal-links { flex-wrap: wrap; gap: 12px; }

    /* Cards */
    .card-body  { padding: 16px; }
    .card-header{ padding: 12px 16px; }
    .card-footer{ padding: 12px 16px; }

    /* Modal */
    .modal { padding: 16px; align-items: flex-end; }
    .modal-dialog {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 85vh;
    }

    /* Toast */
    .toast-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }
    .toast { min-width: unset; max-width: 100%; }

    /* Table */
    .table th, .table td { padding: 10px 12px; font-size: 13px; }

    /* Mobile menu adjustments */
    .mobile-menu { width: 100%; max-width: 320px; }

    /* 404 */
    .page-404-code { font-size: 80px; }
    .page-404-title { font-size: 22px; }

    /* Pagination */
    .pagination { gap: 4px; }
    .pagination-link { min-width: 34px; height: 34px; font-size: 13px; }

    /* Forms */
    .form-label { font-size: 13px; }
    .form-input { font-size: 16px; } /* Prevent iOS zoom on focus */

    /* Buttons */
    .btn-lg { padding: 11px 20px; font-size: 15px; }

    /* Tabs */
    .tab-link { padding: 10px 14px; font-size: 13px; }

    /* Utilities: flex overrides */
    .flex-col-mobile { flex-direction: column; }
    .w-full-mobile   { width: 100%; }
}

@media (max-width: 480px) {
    .footer-nav { grid-template-columns: 1fr 1fr; }
    .section-title { font-size: 22px; }
}
