:root {
    --theme: #00829A;
    --theme-light: #e0f4f8;
    --theme-dark: #006577;
    --sidebar-width: 240px;
    --topbar-height: 50px;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    font-size: 14px;
    background: #f0f2f5;
    color: #333;
    overflow-x: hidden;
}

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

.text-theme { color: var(--theme); }
.bg-theme { background: var(--theme); }
.btn-theme { background: var(--theme); color: #fff; border: none; }
.btn-theme:hover { background: var(--theme-dark); color: #fff; }
.btn-outline-theme { border-color: var(--theme); color: var(--theme); }
.btn-outline-theme:hover { background: var(--theme); color: #fff; }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--theme);
    z-index: 1000;
    overflow-y: auto;
    transition: transform .3s;
}
.sidebar-header {
    padding: 11px 20px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-user { border-bottom: 1px solid rgba(255,255,255,.1); }
.avatar-circle {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.sidebar .nav-link {
    color: rgba(255,255,255,.85);
    padding: 12px 20px;
    border-left: 3px solid transparent;
    transition: all .2s;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active {
    background: rgba(255,255,255,.15);
    border-left-color: #fff;
    color: #fff;
}
.sidebar .nav-link i { width: 20px; margin-right: 10px; text-align: center; }

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--theme);
    z-index: 999;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}
.badge-msg {
    position: absolute;
    top: -8px;
    right: -10px;
    font-size: 10px;
    padding: 2px 5px;
}

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

.footer {
    margin-left: var(--sidebar-width);
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #dee2e6;
    text-align: center;
    font-size: 12px;
}

/* Cards */
.card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 20px; }
.card-header {
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    font-weight: 600;
    padding: 12px 20px;
}
.stat-card {
    text-align: center;
    padding: 20px;
    border-radius: 8px;
}
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; margin: 0 auto 10px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 13px; color: #666; margin-top: 5px; }

/* Table */
.table th { background: #f8f9fa; font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-actions { white-space: nowrap; }

/* Form */
.form-label { font-weight: 500; }
.form-control:focus, .form-select:focus {
    border-color: var(--theme);
    box-shadow: 0 0 0 .2rem rgba(0,130,154,.25);
}
.form-section { 
    background: var(--theme-light);
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--theme);
}

/* Signature */
.signature-pad {
    border: 2px dashed #ccc;
    border-radius: 8px;
    background: #fff;
    touch-action: none;
}
.signature-pad.active { border-color: var(--theme); }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--theme) 0%, var(--theme-dark) 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card .logo {
    text-align: center;
    margin-bottom: 30px;
}
.login-card .logo i { font-size: 48px; color: var(--theme); }
.login-card .logo h3 { margin-top: 10px; font-weight: 700; color: var(--theme); }

/* Mobile */
@media (max-width: 767.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .topbar { left: 0; }
    .main-content { margin-left: 0; padding: 15px; }
    .footer { margin-left: 0; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 999;
    }
    .sidebar.show + .sidebar-overlay { display: block; }
}

/* Utility */
.cursor-pointer { cursor: pointer; }
.sortable-ghost { opacity: .5; background: var(--theme-light); }
.sortable-drag { opacity: .9; }

/* Timeline */
.timeline {
    position: relative;
    padding-left: 30px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dee2e6;
}
.timeline-item {
    position: relative;
    padding-bottom: 20px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--theme);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--theme);
}
.timeline-item .time { font-size: 12px; color: #999; }
.timeline-item .content { margin-top: 4px; }

/* Hazard board */
.hazard-board .board-item {
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hazard-board .board-item.red { background: #fce4e4; border-left: 3px solid #dc3545; }
.hazard-board .board-item.yellow { background: #fff8e1; border-left: 3px solid #ffc107; }
.hazard-board .board-item.green { background: #e8f5e9; border-left: 3px solid #28a745; }

/* Image preview */
.img-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform .2s;
}
.img-preview:hover { transform: scale(1.05); }

/* Print */
@media print {
    .sidebar, .topbar, .footer, .no-print { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
