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

:root {
    --primary: #2d8a4e;
    --primary-dark: #236b3d;
    --primary-light: #e8f5e9;
    --bg: #f5f5f5;
    --bg-white: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 62px;
    --topbar-height: 56px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    min-height: var(--topbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 24px;
    z-index: 100;
    gap: 16px;
}

.topbar-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-light);
}

.topbar-info .badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.topbar-info .user-name {
    font-weight: 600;
    color: var(--text);
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 101;
    overflow: hidden;
}

.sidebar-logo {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    justify-content: flex-start;
}

.sidebar-logo h1 {
    flex: 1;
    min-width: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    transition: opacity 0.2s ease, width 0.25s ease;
}

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-section {
    padding: 12px 12px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.sidebar-nav a, .sidebar-nav .submenu-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-light);
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-nav a:hover, .sidebar-nav .submenu-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    font-weight: 500;
}

.sidebar-nav .submenu {
    display: none;
    padding-left: 20px;
}

.sidebar-nav .submenu.open { display: block; }

.sidebar-nav .submenu a {
    padding: 7px 20px;
    font-size: 13px;
}

.sidebar-nav .icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 8px 0;
    flex-shrink: 0;
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-radius: 6px;
    margin: 4px 8px;
}

.sidebar-footer a:hover {
    background: rgba(46, 125, 50, 0.08);
    color: var(--primary);
}

.sidebar-footer a .icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 24px;
    min-height: calc(100vh - var(--topbar-height));
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

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

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding: 20px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.15s;
    background: var(--bg-white);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45,138,78,0.1);
}

textarea.form-control { min-height: 80px; resize: vertical; }

select.form-control {
    appearance: auto;
    cursor: pointer;
}

.form-control-compact {
    padding: 6px 8px;
    font-size: 14px;
    min-width: 0;
}

.form-control-sm {
    padding: 5px 8px;
    font-size: 12px;
    width: auto;
    min-width: 130px;
}

.company-links-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.company-link-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.company-link-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    min-width: 200px;
    font-size: 13px;
}

.company-link-check:hover {
    border-color: var(--primary);
}

.company-role-select:disabled {
    opacity: 0.4;
}

.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    background: var(--bg);
}

table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
}

table tr:hover td {
    background: var(--primary-light);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-active { background: #d4edda; color: #155724; }
.status-paused { background: #fff3cd; color: #856404; }
.status-completed { background: #cce5ff; color: #004085; }
.status-archived { background: #e2e3e5; color: #383d41; }

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    gap: 0;
}

.tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.radio-group {
    display: flex;
    gap: 16px;
    align-items: center;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

.company-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-white);
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    color: inherit;
    display: block;
}

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

.company-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.company-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.company-card p {
    font-size: 13px;
    color: var(--text-muted);
}

.auth-wrapper {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
}

.auth-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-right {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-light) 0%, #c8e6c9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-right::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(45,138,78,0.1);
    border-radius: 50%;
    top: -100px;
    right: -100px;
}

.auth-right::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(45,138,78,0.08);
    border-radius: 50%;
    bottom: -80px;
    left: -80px;
}

.auth-box {
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-box .logo-icon {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 22px;
    margin: 0 auto 20px;
}

.auth-box h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-box .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.auth-box .form-control {
    text-align: left;
}

.auth-box .btn { width: 100%; justify-content: center; }

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fde8e8;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 600; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
}

.chevron-icon { transition: transform 0.2s; }
.chevron-icon.open { transform: rotate(90deg); }

@media (max-width: 1024px) {
    .topbar {
        padding: 0 12px;
        gap: 8px;
    }
    .topbar-info {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
        font-size: 13px;
    }
    .topbar-info .badge {
        font-size: 11px;
        padding: 2px 8px;
    }
    .topbar-info .btn-sm {
        padding: 3px 8px;
        font-size: 12px;
    }
    .form-control {
        font-size: 14px;
        padding: 7px 10px;
    }
    .card-body { padding: 16px; }
    .form-group { margin-bottom: 12px; }
    .form-group label { font-size: 12px; }
    table td { padding: 10px 12px; font-size: 13px; }
    table th { padding: 8px 12px; font-size: 11px; }
    .btn { font-size: 13px; padding: 7px 14px; }
    .btn-sm { padding: 4px 10px; font-size: 12px; }
}

@media (max-width: 768px) {
    .auth-right { display: none; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .topbar-info > span:first-child { display: none; }
    .main-content { padding: 16px; }
    .page-header h1 { font-size: 18px; }
}

.sidebar,
.topbar,
.main-content {
    transition: all 0.25s ease;
}

.sidebar-nav .nav-label,
.sidebar-footer .nav-label {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.sidebar-lang-buttons {
    display: flex;
    gap: 6px;
    padding: 4px 16px;
    transition: padding 0.25s ease;
}

.sidebar-lang-buttons .btn {
    flex: 1;
    text-align: center;
}

@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar-logo h1 {
        opacity: 0;
        width: 0;
        overflow: hidden;
    }

    .sidebar-logo {
        justify-content: center;
        padding: 0 14px;
    }

    .sidebar-section {
        opacity: 0;
        height: 0;
        padding: 0;
        overflow: hidden;
    }

    .sidebar-nav a,
    .sidebar-nav .submenu-toggle {
        justify-content: center;
        padding: 10px 0;
    }

    .sidebar-nav .nav-label,
    .sidebar-footer .nav-label {
        opacity: 0;
        width: 0;
        position: absolute;
    }

    .sidebar-footer a {
        justify-content: center;
        padding: 10px 0;
        margin: 4px 6px;
    }

    .sidebar-lang-buttons {
        flex-direction: column;
        padding: 4px 10px;
        gap: 4px;
    }

    .sidebar-lang-buttons .btn {
        font-size: 11px;
        padding: 3px 4px;
    }

    .topbar {
        left: var(--sidebar-collapsed-width);
    }

    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .sidebar.expanded {
        width: var(--sidebar-width);
    }

    .sidebar.expanded .sidebar-logo {
        justify-content: flex-start;
        padding: 0 20px;
    }

    .sidebar.expanded .sidebar-logo h1 {
        opacity: 1;
        width: auto;
    }

    .sidebar.expanded .sidebar-section {
        opacity: 1;
        height: auto;
        padding: 12px 12px 4px;
    }

    .sidebar.expanded .sidebar-nav a,
    .sidebar.expanded .sidebar-nav .submenu-toggle {
        justify-content: flex-start;
        padding: 9px 20px;
    }

    .sidebar.expanded .sidebar-nav .nav-label,
    .sidebar.expanded .sidebar-footer .nav-label {
        opacity: 1;
        width: auto;
        position: static;
    }

    .sidebar.expanded .sidebar-footer a {
        justify-content: flex-start;
        padding: 10px 20px;
        margin: 4px 8px;
    }

    .sidebar.expanded .sidebar-lang-buttons {
        flex-direction: row;
        padding: 4px 16px;
        gap: 6px;
    }

    .sidebar.expanded .sidebar-lang-buttons .btn {
        font-size: 13px;
        padding: 5px 12px;
    }

    body.sidebar-expanded .topbar {
        left: var(--sidebar-width);
    }

    body.sidebar-expanded .main-content {
        margin-left: var(--sidebar-width);
    }
}

.sidebar-collapse-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 0;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 18px;
    font-weight: 600;
    transition: color 0.15s, background 0.15s;
    font-family: inherit;
}

.sidebar-collapse-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-collapse-btn .collapse-arrow-collapse {
    display: none;
}

@media (max-width: 1024px) {
    .sidebar-collapse-btn {
        display: flex;
    }

    .sidebar-collapse-btn .collapse-arrow-expand {
        display: inline;
    }

    .sidebar-collapse-btn .collapse-arrow-collapse {
        display: none;
    }

    .sidebar.expanded .sidebar-collapse-btn .collapse-arrow-expand {
        display: none;
    }

    .sidebar.expanded .sidebar-collapse-btn .collapse-arrow-collapse {
        display: inline;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 100;
}

@media (max-width: 768px) {
    body.sidebar-expanded .sidebar-overlay {
        display: block;
    }
}
