:root {
    --primary: #0d2347;
    --primary-light: #16386e;
    --accent: #2563eb;
    --success: #059669;
    --danger: #dc2626;
    --bg-main: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 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.08);
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}
.sidebar {
    width: 280px;
    background: #0d2347;
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 10;
    transition: transform 0.3s ease-in-out;
}
.sidebar-header {
    padding: 24px 20px 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #0d2347;
}
.sidebar-brand {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.8px;
    margin-bottom: 4px;
    text-align: center;
}
.sidebar-header span {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #93c5fd;
    font-weight: 600;
}
.sidebar nav {
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.25s ease;
    font-weight: 500;
    font-size: 0.95rem;
}
.nav-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    opacity: 0.8;
}
.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.nav-link.active {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.nav-link.active svg {
    opacity: 1;
}
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: #f8fafc;
}
header {
    background: var(--card-bg);
    padding: 20px 36px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
header h1 {
    color: var(--primary);
    font-size: 1.6rem;
    font-weight: 700;
}
.tab-content {
    padding: 36px;
}
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}
.search-box {
    position: relative;
    width: 360px;
}
.search-box input {
    width: 100%;
    padding: 11px 16px 11px 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
}
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}
.btn-primary {
    background: linear-gradient(135deg, #0d2347 0%, #16386e 100%);
    color: white;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #16386e 0%, #1e3a6d 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}
.btn-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
}
.btn-success:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    transform: translateY(-1px);
}
.btn-secondary {
    background: #e2e8f0;
    color: #334155;
    box-shadow: none;
}
.btn-secondary:hover {
    background: #cbd5e1;
}
.btn-danger {
    background: #fee2e2;
    color: #991b1b;
    box-shadow: none;
}
.btn-danger:hover {
    background: #fecaca;
}
.table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 750px;
}
th, td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    white-space: nowrap;
}
th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 5;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td {
    background-color: #f8fafc;
}
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.badge-vapaana {
    background-color: #d1fae5;
    color: #065f46;
}
.badge-lainassa {
    background-color: #fee2e2;
    color: #991b1b;
}
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
}
.card {
    background: var(--card-bg);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: linear-gradient(90deg, #0d2347, #2563eb);
}
.card h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-top: 12px;
    letter-spacing: -1px;
}
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.modal-content {
    background: white;
    padding: 36px;
    border-radius: 16px;
    width: 440px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--shadow-lg);
}
.modal-content h3 {
    color: var(--primary);
    font-size: 1.3rem;
    font-weight: 700;
}
.modal-content input, .modal-content select {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    background: #f8fafc;
    transition: all 0.2s;
}
.modal-content input:focus, .modal-content select:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}
.tool-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #f1f5f9;
}
.category-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.category-chip {
    padding: 8px 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: var(--shadow);
}
.category-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.category-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.search-suggestions {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
}
.suggestion-item {
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
    font-size: 0.92rem;
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item:hover {
    background: #f8fafc;
    color: var(--accent);
}
.suggestion-category {
    font-size: 0.75rem;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 500;
}
.menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow);
}
.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
}
.menu-close {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    position: absolute;
    top: 15px;
    right: 15px;
    cursor: pointer;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 999;
}
@media screen and (max-width: 900px) {
    .menu-toggle {
        display: flex;
    }
    .menu-close {
        display: block;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 1000;
    }
    .sidebar.is-open {
        transform: translateX(0);
    }
    .sidebar-overlay.is-active {
        display: block;
    }
    header {
        padding: 20px 20px 20px 70px;
    }
    .tab-content {
        padding: 20px;
    }
    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box {
        width: 100%;
    }
    .table-container {
        max-height: 52vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}