:root {
    /* スタンダードカラーパレット - デフォルト */
    --bg: #f8fafc;
    --bg-secondary: #f1f5f9;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-accent: #6366f1;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --cream: #f5f5f5;
    --peach: #f8fafc;
    --sky-blue: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

/* パステルテーマ */
[data-theme="pastel"] {
    --bg: #fef8f5;
    --bg-secondary: #f5f0ed;
    --primary: #f2b2b2;
    --primary-dark: #e8a0a0;
    --primary-light: #f8c8c8;
    --primary-accent: #d0e8f2;
    --danger: #ef9a9a;
    --danger-dark: #e57373;
    --success: #a5d6a7;
    --success-dark: #81c784;
    --warning: #ffcc80;
    --warning-dark: #ffb74d;
    --cream: #f5deb3;
    --peach: #f8e0e0;
    --sky-blue: #d0e8f2;
    --text: #5d4037;
    --text-secondary: #8d6e63;
    --muted: #a1887f;
    --card-bg: #ffffff;
    --border: #f5e6d3;
    --border-light: #faf5f0;
    --shadow-sm: 0 1px 2px 0 rgba(242, 178, 178, 0.1);
    --shadow: 0 4px 6px -1px rgba(242, 178, 178, 0.15), 0 2px 4px -1px rgba(242, 178, 178, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(242, 178, 178, 0.2), 0 4px 6px -2px rgba(242, 178, 178, 0.15);
    --shadow-lg: 0 20px 25px -5px rgba(242, 178, 178, 0.25), 0 10px 10px -5px rgba(242, 178, 178, 0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    margin: 0;
    color: var(--text);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* パステルテーマの背景グラデーション */
body[data-theme="pastel"],
[data-theme="pastel"] body,
body.app[data-theme="pastel"] {
    background: linear-gradient(135deg, #d0e8f2 0%, #f8e0e0 100%) !important;
    background-attachment: fixed !important;
}

.container {
    width: min(1200px, 94%);
    margin: 0 auto;
    padding: 0 1rem;
}

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

/* ========== ヘッダー ========== */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.app-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.brand:hover {
    opacity: 0.8;
}

.brand-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    position: relative;
}

.main-nav a:hover,
.main-nav a:focus {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.main-nav a:active {
    transform: translateY(1px);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.nav-toggle-bar {
    width: 20px;
    height: 2.5px;
    background: var(--text);
    border-radius: 2px;
    display: block;
    transition: all 0.3s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.logout-button {
    white-space: nowrap;
}

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

/* ========== メインコンテンツ ========== */
main.container {
    padding: 2.5rem 0 2rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-top: 0.5rem;
}

/* ========== グリッド ========== */
.grid.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ========== ダッシュボードヘッダー ========== */
.dashboard-header {
    margin-bottom: 2.5rem;
    padding: 2rem 0;
}

.welcome-section h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

/* ========== 統計カードグリッド ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.75rem;
    margin-bottom: 2.5rem;
}

/* ========== 統計カード ========== */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(242, 178, 178, 0.2) 0%, rgba(248, 200, 200, 0.2) 100%);
    color: var(--primary-dark);
    transition: all 0.3s ease;
}

.stat-card:hover .stat-card-icon {
    transform: scale(1.1) rotate(5deg);
}

.stat-card-primary .stat-card-icon {
    background: linear-gradient(135deg, rgba(242, 178, 178, 0.25) 0%, rgba(248, 200, 200, 0.25) 100%);
    color: var(--primary-dark);
}

.stat-card-success .stat-card-icon {
    background: linear-gradient(135deg, rgba(165, 214, 167, 0.25) 0%, rgba(129, 199, 132, 0.25) 100%);
    color: var(--success-dark);
}

.stat-card-warning .stat-card-icon {
    background: linear-gradient(135deg, rgba(255, 204, 128, 0.25) 0%, rgba(255, 183, 77, 0.25) 100%);
    color: var(--warning-dark);
}

.stat-card-primary::before {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
}

.stat-card-success::before {
    background: linear-gradient(90deg, var(--success) 0%, var(--success-dark) 100%);
}

.stat-card-warning::before {
    background: linear-gradient(90deg, var(--warning) 0%, var(--warning-dark) 100%);
}

.stat-card-content {
    flex: 1;
}

.stat-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.75rem 0;
}

.stat-card-metric {
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1;
    margin: 0 0 0.5rem 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card-primary .stat-card-metric {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card-success .stat-card-metric {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card-warning .stat-card-metric {
    background: linear-gradient(135deg, var(--warning) 0%, var(--warning-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card-unit {
    font-size: 1.5rem;
    font-weight: 500;
    opacity: 0.7;
}

.stat-card-desc {
    color: var(--muted);
    font-size: 0.875rem;
    margin: 0;
}

.stat-card-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    margin-top: auto;
}

.stat-card-link svg {
    transition: transform 0.2s ease;
}

.stat-card-link:hover {
    background: var(--primary);
    color: white;
    transform: translateX(4px);
}

.stat-card-link:hover svg {
    transform: translateX(4px);
}

.stat-card-primary .stat-card-link:hover {
    background: var(--primary-dark);
}

.stat-card-success .stat-card-link:hover {
    background: var(--success-dark);
}

.stat-card-warning .stat-card-link:hover {
    background: var(--warning-dark);
}

/* ========== カード ========== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.card:hover::before {
    opacity: 1;
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metric {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0.5rem 0;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ========== テーブル ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    position: relative;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.table th,
.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

.table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table tbody tr {
    transition: background 0.2s ease;
}

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

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

.table td.actions-cell {
    white-space: normal;
    min-width: 180px;
}

/* ライセンスキーセル */
.table td.license-key-cell {
    min-width: 280px;
}

/* ステータス列 */
.table th:nth-child(2),
.table td:nth-child(2) {
    min-width: 120px;
    white-space: nowrap;
}

.table td:nth-child(2) .badge {
    white-space: nowrap;
}

.license-key-display {
    margin-bottom: 0.5rem;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.875rem;
}

.license-key-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

.license-key-actions .button {
    flex: 0 0 auto;
    white-space: nowrap;
}

.license-key-actions .inline-form {
    margin: 0;
    display: inline-flex;
    flex: 0 0 auto;
}

.license-key-actions .inline-form .button {
    width: auto;
}

.table-container::before,
.table-container::after {
    content: '';
    position: absolute;
    top: 0;
    width: 30px;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
}

.table-container::before {
    left: 0;
    background: linear-gradient(to right, var(--card-bg), rgba(255, 255, 255, 0));
}

.table-container::after {
    right: 0;
    background: linear-gradient(to left, var(--card-bg), rgba(255, 255, 255, 0));
}

.table-container.is-scrollable::before,
.table-container.is-scrollable::after {
    opacity: 1;
}

.table-container.is-scrollable.is-at-start::before {
    opacity: 0;
}

.table-container.is-scrollable.is-at-end::after {
    opacity: 0;
}

.table-scroll-hint {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    display: none;
}

.table-container.is-scrollable + .table-scroll-hint {
    display: block;
}

/* ========== フォーム ========== */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.danger-zone-form {
    margin: 0 0 1.5rem;
    text-align: right;
}

.danger-zone-form .button {
    min-width: 160px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--card-bg);
    color: var(--text);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-error {
    color: var(--danger);
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-hint {
    color: var(--muted);
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
}

.required {
    color: var(--danger);
}

/* ========== ボタン ========== */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.button:hover::before {
    width: 300px;
    height: 300px;
}

.button.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(242, 178, 178, 0.4);
}

.button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(242, 178, 178, 0.5);
}

.button.primary:active {
    transform: translateY(0);
}

.button.secondary {
    background: rgba(242, 178, 178, 0.15);
    color: var(--primary-dark);
    border: 1px solid rgba(242, 178, 178, 0.3);
}

.button.secondary:hover {
    background: rgba(242, 178, 178, 0.2);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.button.danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(239, 154, 154, 0.4);
}

.button.danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(239, 154, 154, 0.5);
}

.button.link {
    background: rgba(242, 178, 178, 0.15);
    color: var(--primary-dark);
    border: 1px solid rgba(242, 178, 178, 0.3);
}

.button.link:hover {
    background: rgba(242, 178, 178, 0.2);
    border-color: var(--primary);
}

.button.small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.inline-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.inline-form select,
.inline-form input {
    max-width: 200px;
}

/* ========== アラート ========== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-dark);
    border-left-color: var(--danger);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-dark);
    border-left-color: var(--success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border-left-color: var(--warning);
}

/* ========== バッジ ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.status-active,
.badge.status-online {
    background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
}

.badge.status-trialing {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

.badge.status-past_due,
.badge.status-error {
    background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
}

.badge.status-canceled,
.badge.status-offline {
    background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%);
}

.badge.status-maintenance {
    background: linear-gradient(135deg, var(--warning) 0%, #fbbf24 100%);
}

.badge.status-active-canceling {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.badge.status-open {
    background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
}

.badge.status-in_progress {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    color: #fff;
}

.badge.status-closed {
    background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%);
}

/* ========== チェックボックス ========== */
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ========== フッター ========== */
.app-footer {
    padding: 2rem 0;
    background: transparent;
    color: var(--muted);
    text-align: center;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-light);
    margin-top: 2rem;
}

/* ========== ゲストページ ========== */
.guest {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow-y: auto;
    padding: 2rem 0;
}

.guest::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23ffffff" fill-opacity="0.05"><path d="M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z"/></g></g></svg>');
    opacity: 0.3;
}

.guest-container {
    width: min(440px, 92%);
    position: relative;
    z-index: 1;
}

.guest-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.guest-card .brand-logo {
    height: 60px;
    margin: 0 auto 2rem;
    display: block;
}

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

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

.small {
    font-size: 0.875rem;
}

.w-100 {
    width: 100%;
}

/* ========== 管理者ダッシュボード ========== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stats .card {
    text-align: center;
}

.metric {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.actions-cell {
    white-space: nowrap;
}

.inline-form {
    display: inline-block;
}

.link {
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.form-value {
    padding: 0.5rem 0;
    color: var(--text);
}

.form-select {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.message-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-top: 0.5rem;
}

.message-content {
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    color: var(--text);
}

.replies-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.reply-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    border-left: 4px solid var(--border);
}

.reply-item.reply-admin {
    border-left-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.reply-content {
    margin-top: 0.75rem;
}

.reply-content .message-content {
    background: transparent;
    padding: 0;
    border: none;
}

/* ========== レスポンシブ ========== */
@media (max-width: 768px) {
    .container {
        width: 98%;
        padding: 0 0.75rem;
    }

    main.container {
        padding: 1.5rem 0 1.5rem;
    }
    
    .app-footer {
        margin-top: 1.5rem;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .grid.stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .dashboard-header {
        padding: 1.5rem 0;
        margin-bottom: 2rem;
    }

    .welcome-section h1 {
        font-size: 1.75rem;
    }

    .stat-card {
        padding: 1.5rem;
    }

    .stat-card-metric {
        font-size: 2.25rem;
    }

    .card {
        padding: 1.5rem;
    }

    .metric {
        font-size: 2rem;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .license-key-actions {
        gap: 0.4rem;
    }

    .license-key-actions .button {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
        min-width: 70px;
    }

    .app-header .container {
        flex-wrap: wrap;
        gap: 0.75rem 1rem;
    }

    .nav-toggle {
        display: flex;
    }

    .header-actions {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
    }

    .header-actions.is-open {
        display: flex;
    }

    .main-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
    }

    .main-nav a {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-light);
        border-radius: 0;
    }

    .main-nav a:last-child {
        border-bottom: none;
    }

    .user-menu {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .header-actions .logout-button {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
        background: rgba(99, 102, 241, 0.1);
        border: 1px solid rgba(99, 102, 241, 0.2);
        color: var(--primary);
    }

    .header-actions .logout-button:hover,
    .header-actions .logout-button:focus {
        background: rgba(99, 102, 241, 0.15);
    }

    .danger-zone-form {
        text-align: left;
    }

    .danger-zone-form .button {
        width: 100%;
    }

    .guest-card {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    main.container {
        padding: 2.5rem 1rem 2rem;
    }
    
    .app-footer {
        margin-top: 2rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .dashboard-header {
        padding: 1rem 0;
    }

    .welcome-section h1 {
        font-size: 1.5rem;
    }

    .welcome-subtitle {
        font-size: 0.95rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-card-icon {
        width: 48px;
        height: 48px;
    }

    .stat-card-metric {
        font-size: 2rem;
    }

    .card {
        padding: 1.25rem;
    }

    .button {
        width: 100%;
        justify-content: center;
    }

    .license-key-actions {
        gap: 0.35rem;
    }

    .license-key-actions .button {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
        min-width: 60px;
        flex: 1 1 auto;
        max-width: calc(50% - 0.175rem);
    }

    .license-key-actions .inline-form {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .license-key-actions .inline-form .button {
        width: 100%;
        max-width: 100%;
    }

    /* スマホ表示での各列の調整 */
    .table th:nth-child(2),
    .table td:nth-child(2) {
        min-width: 140px;
    }

    /* プラン名（1列目）を少し広く */
    .table th:nth-child(1),
    .table td:nth-child(1) {
        min-width: 150px;
    }

    /* ライセンスキー（3列目）を少し狭く */
    .table td.license-key-cell {
        min-width: 240px;
    }

    /* 有効期限（4列目）を少し広く */
    .table th:nth-child(4),
    .table td:nth-child(4) {
        min-width: 160px;
    }

    /* 操作（5列目）を少し狭く */
    .table td.actions-cell {
        min-width: 150px;
    }

    /* お問い合わせ一覧のカテゴリ、ステータス、送信日時（作成日時）を狭く */
    /* 4列構成のテーブル（件名、カテゴリ、ステータス、送信日時）を対象 */
    /* 契約一覧は5列構成なので、4列目があり5列目がないテーブルを特定 */
    .table thead tr th:nth-child(4):not(:nth-child(5)) ~ *,
    .table-container .table thead tr th:nth-child(4):not(:nth-child(5)) ~ *,
    /* 4列構成のテーブルの2列目（カテゴリ） */
    .table-container .table:not(:has(th:nth-child(5))) th:nth-child(2),
    .table-container .table:not(:has(th:nth-child(5))) td:nth-child(2) {
        min-width: 70px !important;
        white-space: nowrap;
    }

    /* 4列構成のテーブルの3列目（ステータス） */
    .table-container .table:not(:has(th:nth-child(5))) th:nth-child(3),
    .table-container .table:not(:has(th:nth-child(5))) td:nth-child(3) {
        min-width: 80px !important;
        white-space: nowrap;
    }

    /* 4列構成のテーブルの4列目（送信日時/作成日時） */
    .table-container .table:not(:has(th:nth-child(5))) th:nth-child(4),
    .table-container .table:not(:has(th:nth-child(5))) td:nth-child(4) {
        min-width: 120px !important;
        white-space: nowrap;
        font-size: 0.85rem;
    }

    /* bot稼働状況のステータス、最終確認、操作を狭く */
    /* bot稼働状況のテーブルは4列構成（名前、ステータス、最終確認、操作） */
    /* 操作列に`.action-buttons`が含まれるテーブルを特定 */
    /* ステータス（2列目） */
    .table-container .table:has(.action-buttons) th:nth-child(2),
    .table-container .table:has(.action-buttons) td:nth-child(2) {
        min-width: 80px !important;
        white-space: nowrap;
    }

    /* 最終確認（3列目） */
    .table-container .table:has(.action-buttons) th:nth-child(3),
    .table-container .table:has(.action-buttons) td:nth-child(3) {
        min-width: 120px !important;
        white-space: nowrap;
        font-size: 0.85rem;
    }

    /* 操作（4列目） */
    .table-container .table:has(.action-buttons) td:nth-child(4) {
        min-width: 150px !important;
        white-space: nowrap;
    }

    /* bot設定画面の表の調整（スマホ向け） */
    /* 基本設定の表（3列：有効、設定項目、説明） */
    .table-bot-settings-basic th:nth-child(1),
    .table-bot-settings-basic td:nth-child(1) {
        min-width: 60px !important;
        width: 60px;
        padding: 0.5rem 0.25rem;
    }

    .table-bot-settings-basic th:nth-child(2),
    .table-bot-settings-basic td:nth-child(2) {
        min-width: 120px !important;
        font-size: 0.85rem !important;
        padding: 0.5rem 0.5rem;
    }

    .table-bot-settings-basic th:nth-child(3),
    .table-bot-settings-basic td:nth-child(3) {
        min-width: 180px !important;
        font-size: 0.85rem !important;
        padding: 0.5rem 0.5rem;
    }

    /* 読み上げチャンネル設定の表（2列：選択、チャンネル名） */
    .table-bot-settings-channels th:nth-child(1),
    .table-bot-settings-channels td:nth-child(1) {
        min-width: 50px !important;
        width: 50px;
        padding: 0.5rem 0.25rem;
    }

    .table-bot-settings-channels th:nth-child(2),
    .table-bot-settings-channels td:nth-child(2) {
        min-width: 150px !important;
        font-size: 0.85rem !important;
        padding: 0.5rem 0.5rem;
    }

    .table-bot-settings-channels td:nth-child(2) * {
        font-size: 0.85rem !important;
    }

    /* 辞書登録の表（3列：選択、単語、読み方） */
    .table-bot-settings-dict th:nth-child(1),
    .table-bot-settings-dict td:nth-child(1) {
        min-width: 50px !important;
        width: 50px;
        padding: 0.5rem 0.25rem;
    }

    .table-bot-settings-dict th:nth-child(2),
    .table-bot-settings-dict td:nth-child(2) {
        min-width: 100px !important;
        font-size: 0.85rem !important;
        padding: 0.5rem 0.5rem;
    }

    .table-bot-settings-dict th:nth-child(3),
    .table-bot-settings-dict td:nth-child(3) {
        min-width: 120px !important;
        font-size: 0.85rem !important;
        padding: 0.5rem 0.5rem;
    }

    .table-bot-settings-dict td:nth-child(3) * {
        font-size: 0.85rem !important;
    }
}

/* 利用規約ページ専用スタイル */
body.terms-page {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    min-height: 100vh;
}

body.terms-page[data-theme="pastel"] {
    background: linear-gradient(135deg, #d0e8f2 0%, #f8e0e0 100%);
    background-attachment: fixed;
}

body.terms-page .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

@media (max-width: 768px) {
    body.terms-page .container {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 480px) {
    body.terms-page .container {
        padding: 1rem 0.75rem;
    }
}
