:root {
    --primary: #227b4f;
    --primary-dark: #1b6340;
    --secondary: #205879;
    --accent: #8fbf49;
    --bg-light: #f4f7f6;
    --bg-dark: #1e1e2d;
    --card-bg: #ffffff;
    --text-main: #3f4254;
    --text-muted: #a1a5b7;
    --border-color: #eff2f5;
    --danger: #f1416c;
    --success: #50cd89;
    --sidebar-bg: #1e1e2d;
    --sidebar-text: #9899ac;
    --sidebar-active: #227b4f;
    --shadow: 0px 5px 15px rgba(0,0,0,0.05);
    --transition: all 0.3s ease;
}

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

body { font-family: 'Outfit', sans-serif; background: var(--bg-light); color: var(--text-main); line-height: 1.6; overflow: hidden; height: 100vh; display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent; }

.screen { display: none; height: 100%; width: 100%; }
.screen.active { display: flex; }
#app-screen { flex-direction: row; height: 100vh; overflow: hidden; }

/* Login Screen */
#login-screen { justify-content: center; align-items: center; background: linear-gradient(135deg, var(--sidebar-bg), var(--primary)); }
.login-card { background: var(--card-bg); padding: 50px 40px; border-radius: 15px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); width: 100%; max-width: 400px; text-align: center; }
.login-header h2 { font-size: 28px; color: var(--primary); margin-bottom: 5px; }
.login-header p { color: var(--text-muted); margin-bottom: 30px; }
.input-group { position: relative; margin-bottom: 20px; }
.input-group i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 18px; }
.input-group input { width: 100%; padding: 15px 15px 15px 45px; border: 1px solid var(--border-color); border-radius: 8px; outline: none; font-size: 15px; transition: var(--transition); }
.input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(34,123,79,0.1); }
.error-msg { color: var(--danger); margin-top: 15px; font-size: 13px; }

/* Buttons */
.btn { padding: 12px 25px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; transition: var(--transition); display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: var(--border-color); }
.btn-pdf { background: #e74c3c; color: white; }
.btn-pdf:hover { background: #c0392b; }
.btn-block { width: 100%; justify-content: center; }

/* Admin Only */
.admin-only { display: none; }

/* App Screen */
.sidebar { width: 280px; background: var(--sidebar-bg); display: flex; flex-direction: column; color: var(--sidebar-text); }
.sidebar-header { padding: 30px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px dashed rgba(255,255,255,0.1); }
.sidebar-header h2 { color: #fff; font-size: 20px; }
.role-badge { background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 20px; font-size: 11px; color: var(--accent); }
.nav-menu { flex: 1; padding: 20px 0; list-style: none; }
.nav-menu li { padding: 15px 25px; cursor: pointer; display: flex; align-items: center; gap: 15px; transition: var(--transition); border-left: 3px solid transparent; }
.nav-menu li:hover { color: #fff; background: rgba(255,255,255,0.02); }
.nav-menu li.active { color: #fff; background: rgba(34,123,79,0.1); border-left-color: var(--primary); }
.nav-menu li i { font-size: 20px; }
.sidebar-footer { padding: 20px; border-top: 1px dashed rgba(255,255,255,0.1); }
.sidebar-footer .btn { width: 100%; border-color: rgba(255,255,255,0.1); color: #fff; }
.sidebar-footer .btn:hover { background: rgba(255,255,255,0.1); }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.top-header { height: 80px; background: var(--card-bg); display: flex; align-items: center; justify-content: space-between; padding: 0 30px; box-shadow: var(--shadow); z-index: 10; }
.top-header h1 { font-size: 22px; font-weight: 600; color: var(--secondary); }

.content-wrapper { flex: 1; padding: 30px; overflow-y: auto; }
.view { display: none; animation: fadeIn 0.3s; }
.view.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 25px; margin-bottom: 30px; }
.stat-card { background: var(--card-bg); padding: 25px; border-radius: 12px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 20px; }
.stat-icon { width: 60px; height: 60px; border-radius: 12px; background: rgba(34,123,79,0.1); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.stat-details h3 { font-size: 14px; color: var(--text-muted); font-weight: 500; margin-bottom: 5px; }
.stat-details p { font-size: 24px; font-weight: 700; color: var(--text-main); }
.quick-actions { display: flex; gap: 15px; }

/* Tables & Toolbar */
.toolbar { display: flex; gap: 15px; margin-bottom: 25px; align-items: center; }
.search-input { flex: 1; max-width: 400px; padding: 12px 20px; border: 1px solid var(--border-color); border-radius: 8px; outline: none; }
.search-input:focus { border-color: var(--primary); }

.table-container { background: var(--card-bg); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: #f8f9fa; padding: 15px 20px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border-color); }
td { padding: 15px 20px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover { background: #fdfdfd; }

/* Modals */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(5px); align-items: center; justify-content: center; }
.modal-content { background: var(--card-bg); padding: 35px; border-radius: 15px; width: 100%; max-width: 500px; position: relative; box-shadow: 0 25px 50px rgba(0,0,0,0.2); animation: scaleUp 0.3s; }
.close { position: absolute; right: 25px; top: 25px; font-size: 28px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.close:hover { color: var(--danger); }
.modal h2 { margin-bottom: 25px; color: var(--secondary); font-size: 22px; }

@keyframes scaleUp { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.form-group { margin-bottom: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--text-main); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px 15px; border: 1px solid var(--border-color); border-radius: 8px; outline: none; font-family: inherit; font-size: 14px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }

/* Mobile App Native Feel */
@media (max-width: 768px) {
    .main-content { padding-bottom: 70px; }
    .top-header { height: 65px; padding: 0 20px; }
    .content-wrapper { padding: 15px; }
    
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: calc(70px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        flex-direction: row;
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
        z-index: 1000;
    }
    .sidebar-header { display: none; }
    .sidebar-footer { display: none; }
    .nav-menu {
        display: flex;
        flex-direction: row;
        width: 100%;
        padding: 0;
        justify-content: space-around;
        align-items: center;
    }
    .nav-menu li {
        flex: 1;
        flex-direction: column;
        padding: 10px 5px;
        border-left: none;
        border-bottom: 3px solid transparent;
        font-size: 11px;
        color: var(--text-muted);
        gap: 5px;
        justify-content: center;
    }
    .nav-menu li i { font-size: 22px; margin-bottom: 2px; }
    .nav-menu li.active {
        background: transparent;
        color: var(--primary);
        border-bottom: none;
        border-top: 3px solid var(--primary);
    }
    
    .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 25px 20px;
    }
    
    .table-container { background: transparent; box-shadow: none; }
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { display: none; }
    tr {
        background: var(--card-bg);
        margin-bottom: 15px;
        border-radius: 12px;
        padding: 15px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        border: 1px solid var(--border-color);
    }
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px dashed var(--border-color);
        text-align: right;
    }
    td:last-child { border-bottom: none; }
    td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--text-muted);
        text-align: left;
    }
    
    .toolbar { flex-direction: column; gap: 10px; }
    .search-input { width: 100%; max-width: none; }
    .btn { width: 100%; justify-content: center; padding: 15px; font-size: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .quick-actions { flex-direction: column; }
}
