/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.6;
    min-height: 100vh;
}

/* === Layout === */
.no-sidebar .content {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.has-sidebar {
    display: flex;
    min-height: 100vh;
}
.has-sidebar .content {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    max-width: 1100px;
}

/* === Sidebar === */
.sidebar {
    width: 240px;
    background: #1a1a2e;
    color: #c0c0d0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
    background: #4361ee;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}
.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: #b0b0c0;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav li a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.sidebar-nav li a.active {
    background: rgba(67,97,238,0.2);
    color: #7b9af7;
    border-right: 3px solid #4361ee;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666680;
    padding: 16px 20px 6px;
}
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
}
.user-email {
    color: #888;
    margin-bottom: 4px;
    word-break: break-all;
}
.logout-link { color: #ff6b6b; text-decoration: none; font-size: 12px; }
.logout-link:hover { text-decoration: underline; }

/* === Auth Pages === */
.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.auth-logo {
    background: #4361ee;
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.auth-card h1 {
    text-align: center;
    font-size: 22px;
    margin-bottom: 4px;
}
.auth-desc {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 24px;
}

/* === Forms === */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 13px;
    color: #444;
}
input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 14px;
    transition: border 0.15s;
    font-family: inherit;
}
input:focus {
    outline: none;
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67,97,238,0.12);
}
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.form-group { margin-bottom: 8px; }
.form-hint { font-size: 12px; color: #888; margin-top: -10px; margin-bottom: 12px; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 9px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    font-family: inherit;
    line-height: 1.4;
}
.btn-primary { background: #4361ee; color: #fff; }
.btn-primary:hover { background: #3451d1; }
.btn-secondary { background: #e9ecef; color: #333; }
.btn-secondary:hover { background: #d0d3d8; }
.btn-info { background: #17a2b8; color: #fff; }
.btn-info:hover { background: #128a9e; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #b52a37; }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* === Messages === */
.msg {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.msg.success { background: #d4edda; color: #155724; }
.msg.error { background: #f8d7da; color: #721c24; }

/* === Cards & Page === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; }

.card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card h2 {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* === Tables === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
th { background: #f8f9fa; font-weight: 600; color: #555; }
.slug-link { color: #4361ee; text-decoration: none; font-weight: 600; }
.slug-link:hover { text-decoration: underline; }
.target-url { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.click-count { font-weight: 700; color: #4361ee; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.empty { color: #999; text-align: center; padding: 40px; }

/* === Tool Grid === */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.tool-card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
}
.tool-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.tool-card-placeholder { cursor: default; }
.tool-card-placeholder:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.06); transform: none; }
.tool-icon { font-size: 32px; flex-shrink: 0; }
.tool-info h3 { font-size: 16px; margin-bottom: 2px; }
.tool-info p { font-size: 13px; color: #666; }

/* === Stats === */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}
.stat-item dt { font-size: 12px; color: #888; margin-bottom: 2px; }
.stat-item dd { font-size: 15px; }

/* === Misc === */
.text-link { color: #4361ee; text-decoration: none; font-size: 13px; }
.text-link:hover { text-decoration: underline; }

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .has-sidebar .content { margin-left: 200px; padding: 20px; }
    .form-row { flex-direction: column; }
}
@media (max-width: 600px) {
    .sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .has-sidebar .content { margin-left: 0; }
}
