:root {
    --primary: #0f6e4f;
    --primary-dark: #0a5038;
    --primary-light: #e6f4ee;
    --accent: #1c8a5e;
    --ink: #14202b;
    --muted: #64748b;
    --border: #e4e9ee;
    --bg: #f4f6f8;
    --card: #ffffff;
    --danger: #d64545;
    --danger-bg: #fdecec;
    --warning: #b8860b;
    --warning-bg: #fdf3d9;
    --success: #0f6e4f;
    --success-bg: #e6f4ee;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16,24,32,.04), 0 8px 24px rgba(16,24,32,.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------------- Layout ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #0d3a29 0%, #0a2e20 100%);
    color: #dcefe6;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: margin-left .2s ease;
}
.sidebar.collapsed { margin-left: -250px; }

.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--accent); color: #fff; font-weight: 800;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; color: #fff; }
.brand-text span { font-size: 11px; color: #9fc7b4; }

.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px; color: #cfe6da; font-size: 13.5px; font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.side-link svg { opacity: .85; flex-shrink: 0; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link.active { background: var(--accent); color: #fff; }
.side-link.active svg { opacity: 1; }

.sidebar-footer { padding: 14px 20px; font-size: 11px; color: #7fa695; border-top: 1px solid rgba(255,255,255,.08); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 64px; background: var(--card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 16px;
    position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); display: none; }

.env-pill { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 5px 10px; border-radius: 999px; }
.env-sandbox { background: var(--warning-bg); color: var(--warning); }
.env-production { background: var(--success-bg); color: var(--success); }

.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.btn-link { color: var(--muted); font-weight: 600; font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.btn-link:hover { background: var(--bg); color: var(--ink); }

.app-content { padding: 24px; flex: 1; }

/* ---------------- Alerts ---------------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bfe3d1; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f3caca; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #eedca4; }
.alert-info { background: #e8f1fb; color: #2260a8; border-color: #c6dcf3; }

/* ---------------- Cards / Grid ---------------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-4, .grid-3 { grid-template-columns: 1fr; } }

.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-header p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.stat-card { display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.stat-card .stat-icon {
    position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; background: var(--primary-light); color: var(--primary);
}
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--ink); }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat-sub.up { color: var(--success); }
.stat-sub.down { color: var(--danger); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
    text-align: left; padding: 11px 14px; background: #fafbfc; color: var(--muted);
    font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:hover { background: #fafcfb; }
table.data-table tbody tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-secondary { background: #eef1f4; color: var(--muted); }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; transition: all .15s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b93838; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .form-row, .form-row.cols-3 { grid-template-columns: 1fr; } }
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
label .req { color: var(--danger); }
input[type=text], input[type=number], input[type=date], input[type=password],
input[type=email], input[type=file], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 18px; }
legend { font-weight: 700; font-size: 13px; padding: 0 8px; color: var(--primary); }

/* ---------------- Misc ---------------- */
.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 14px; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 7px 12px; border-radius: 6px; font-size: 13px; border: 1px solid var(--border); color: var(--ink);
}
.pagination a:hover { background: var(--bg); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }

.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at top left, #0d3a29, #071c15 60%);
    padding: 20px;
}
.login-card { width: 380px; background: #fff; border-radius: 16px; padding: 34px 30px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { margin: 0 auto 12px; }
.login-brand h1 { font-size: 18px; margin: 0; }
.login-brand p { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

.upload-drop {
    border: 2px dashed var(--border); border-radius: 12px; padding: 34px; text-align: center;
    background: #fafcfc; cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.upload-drop:hover, .upload-drop.dragover { border-color: var(--primary); background: var(--primary-light); }
.upload-drop svg { color: var(--primary); margin-bottom: 10px; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; }

.progress-track { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 999px; }

.detail-list { display: grid; grid-template-columns: 160px 1fr; row-gap: 10px; font-size: 13.5px; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; font-weight: 500; }

.timeline { border-left: 2px solid var(--border); margin-left: 8px; padding-left: 18px; }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -23px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

@media (max-width: 900px) {
    .sidebar { position: fixed; z-index: 40; margin-left: -250px; }
    .sidebar.show { margin-left: 0; }
    .btn-icon { display: block; }
}