/* ========================================
   リセット・基本設定
======================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        "Noto Sans JP",
        "Yu Gothic",
        "Meiryo",
        sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

a {
    color: inherit;
}


/* ========================================
   共通ヘッダー
======================================== */

.app-header {
    width: 100%;
    min-height: 72px;

    background-color: #0f172a;
    color: #ffffff;

    border-bottom: 1px solid #1e293b;
}

.app-header__inner {
    width: min(1200px, 94%);
    min-height: 72px;
    margin: 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}


/* ========================================
   ブランド
======================================== */

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.brand-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-text {
    min-width: 0;
}

.brand-name {
    display: flex;
    align-items: baseline;
    gap: 8px;

    color: #ffffff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.brand-name span {
    color: #f59e0b;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.brand-subtitle {
    margin: 4px 0 0;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.4;
    white-space: nowrap;
}


/* ========================================
   ヘッダー右側
======================================== */

.header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-shrink: 0;
}

.header-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.header-user__name {
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.header-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 9px;

    border: 1px solid #475569;
    border-radius: 5px;
    background-color: transparent;

    color: #cbd5e1;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;

    transition:
        background-color 0.2s,
        border-color 0.2s,
        color 0.2s;
}

.header-logout:hover {
    background-color: #1e293b;
    border-color: #64748b;
    color: #ffffff;
    text-decoration: none;
}

.header-badge {
    padding: 6px 12px;
    flex-shrink: 0;

    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 999px;
    background-color: rgba(245, 158, 11, 0.12);

    color: #fbbf24;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}


/* ========================================
   共通：ヘッダー下 横ナビ
======================================== */

.top-nav {
    width: 100%;
    overflow-x: hidden;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.top-nav__inner {
    width: min(1200px, 94%);
    margin: 0 auto;

    display: flex;
    align-items: center;
    gap: 4px;
}

.top-nav__link {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 0;
    min-height: 52px;
    padding: 0 20px;

    color: #64748b;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;

    transition:
        color 0.2s,
        background-color 0.2s;
}

.top-nav__link:hover {
    color: #0f172a;
    background-color: #f8fafc;
}

.top-nav__link.active {
    color: #ea580c;
}

.top-nav__link.active::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background-color: #ea580c;
}


/* ========================================
   スマートフォン：共通ヘッダー・横ナビ
======================================== */

@media (max-width: 768px) {

    .app-header__inner {
        width: calc(100% - 32px);
        min-height: 64px;
        gap: 12px;
    }

    .brand {
        gap: 10px;
    }

    .brand-icon {
        width: 38px;
        height: 38px;
    }

    .brand-text {
        max-width: 190px;
    }

    .brand-name {
        gap: 6px;
        font-size: 18px;
    }

    .brand-name span {
        font-size: 9px;
    }

    .brand-subtitle,
    .header-badge {
        display: none;
    }

    .header-actions {
        gap: 10px;
    }

    .header-user__name {
        font-size: 12px;
    }

    .header-logout {
        font-size: 11px;
    }

    .top-nav__inner {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0;
        overflow-x: visible;
    }

    .top-nav__link {
        width: 100%;
        min-width: 0;
        min-height: 52px;
        padding: 0 4px;
        flex-shrink: 1;
        font-size: 12px;
        white-space: nowrap;
    }

    .top-nav__link.active::after {
        left: 4px;
        right: 4px;
    }
}

@media (max-width: 480px) {

    .brand-name {
        font-size: 16px;
    }

    .top-nav__link {
        padding: 0 2px;
        font-size: 11px;
    }
}


/* ========================================
   ヘッダー下の全体レイアウト
======================================== */

.app-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}


/* ========================================
   サイドバー
======================================== */

.sidebar {
    width: 230px;
    flex-shrink: 0;

    padding: 24px 16px;

    background-color: #ffffff;

    border-right: 1px solid #e2e8f0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav a {
    display: block;

    padding: 11px 14px;

    color: #475569;

    font-size: 14px;
    font-weight: 600;

    text-decoration: none;

    border-radius: 8px;

    transition:
        background-color 0.2s,
        color 0.2s;
}

.sidebar-nav a:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.sidebar-nav a.active {
    background-color: #fff7ed;
    color: #ea580c;
}


/* ========================================
   メインコンテンツ
======================================== */

.app-main {
    flex: 1;
    min-width: 0;

    padding: 32px;

    background-color: #f5f7fa;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.page-title {
    margin-bottom: 24px;
    font-size: 28px;
}


/* ========================================
   カード
======================================== */

.card {
    padding: 24px;

    background-color: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.card-title {
    margin-bottom: 20px;
    font-size: 20px;
}


/* ========================================
   フォーム
======================================== */

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    padding: 10px 12px;

    border: 1px solid #d1d5db;
    border-radius: 6px;

    background-color: #ffffff;

    font: inherit;
}

input:focus,
select:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
}


/* ========================================
   ボタン
======================================== */

.btn {
    display: inline-block;

    padding: 10px 18px;

    border: 0;
    border-radius: 6px;

    font: inherit;
    font-weight: 700;

    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-danger {
    background-color: #dc2626;
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #b91c1c;
}


/* ========================================
   AI解析結果
======================================== */

.result {
    margin-top: 24px;
}

.preview {
    display: block;

    max-width: 300px;
    max-height: 300px;

    margin-bottom: 24px;

    border: 1px solid #e5e7eb;
    border-radius: 8px;
}


/* ========================================
   メッセージ
======================================== */

.error {
    margin-bottom: 20px;
    padding: 12px 16px;

    border-radius: 6px;

    background-color: #fee2e2;
    color: #b91c1c;
}


/* ========================================
   スマートフォン
======================================== */

@media (max-width: 768px) {

    .app-layout {
        display: block;
    }

    .sidebar {
        width: 100%;

        padding: 12px 16px;

        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .sidebar-nav a {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .app-main {
        padding: 20px 16px;
    }

    .page-title {
        font-size: 24px;
    }

    .card {
        padding: 18px;
    }
}

/* ========================================
   CSV期間指定
======================================== */

.export-card {
    margin-bottom: 24px;
}

.export-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: end;
}

.export-form .form-group {
    margin-bottom: 0;
}

.export-action {
    display: flex;
    align-items: end;
}


/* スマートフォン */
@media (max-width: 768px) {

    .export-form {
        grid-template-columns: 1fr;
    }

    .export-action .btn {
        width: 100%;
    }
}