/* =========================================================
   Work Plan M System - Main Stylesheet
   Brand colors: #030303 (dark) + #FC951C (orange)
   ========================================================= */
:root {
    --dark: #030303;
    --dark-2: #121212;
    --dark-3: #1c1c1c;
    --orange: #FC951C;
    --orange-dark: #e0800e;
    --green: #1fbf75;
    --red: #e74c3c;
    --gray-bg: #f4f5f7;
    --gray-border: #e6e8ec;
    --text-muted: #8a8f98;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', 'Inter', Arial, sans-serif;
    background: var(--gray-bg);
    color: #1a1a1a;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: 10px; border: none; font-weight: 600; font-size: 14px;
    transition: 0.2s ease;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-dark:hover { background: #222; }
.btn-outline { background: #fff; border: 1px solid var(--gray-border); color: #333; }
.btn-outline:hover { background: #f2f2f2; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.btn-danger { background: #fdeceb; color: var(--red); }
.btn-danger:hover { background: #fadedb; }
.btn-edit { background: #fff4e6; color: var(--orange-dark); }
.btn-edit:hover { background: #ffe7c7; }
.btn-block { width: 100%; }

/* ---------- Login Page ---------- */
.login-wrapper { display: flex; min-height: 100vh; }
.login-left {
    flex: 1.1; background: linear-gradient(160deg, #0a0a0a 60%, #1a1208 100%);
    color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.login-left::after {
    content: ""; position: absolute; bottom: -80px; right: -80px; width: 320px; height: 320px;
    background: radial-gradient(circle, var(--orange) 0%, transparent 70%); opacity: 0.35; border-radius: 50%;
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 40px; }
.login-logo .logo-mark {
    width: 54px; height: 54px; border-radius: 12px;
    background: linear-gradient(135deg, var(--orange), #ffcf8a);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; color: var(--dark);
}
.login-logo .logo-text { font-size: 20px; font-weight: 700; }
.login-left h1 { font-size: 42px; margin: 0 0 6px; line-height: 1.15; }
.login-left .tagline { color: #b8b8b8; letter-spacing: 3px; font-size: 12px; margin-bottom: 40px; }
.login-left h2 { font-size: 30px; font-weight: 700; max-width: 380px; margin: 0 0 16px; }
.login-left .bar { width: 60px; height: 4px; background: var(--orange); border-radius: 4px; }

.login-right { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.login-card { width: 100%; max-width: 380px; }
.login-card h3 { font-size: 24px; margin-bottom: 4px; }
.login-card p.sub { color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #333; }
.input-icon { position: relative; }
.input-icon input {
    width: 100%; padding: 12px 42px 12px 14px; border-radius: 10px; border: 1px solid var(--gray-border);
    font-size: 14px; outline: none; transition: 0.2s;
}
.input-icon input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(252,149,28,0.15); }
.input-icon .icon-right { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #999; cursor: pointer; }
.form-row-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; font-size: 13px; }
.form-row-between a { color: var(--orange); font-weight: 600; }
.checkbox-label { display: flex; align-items: center; gap: 8px; color: #555; }
.login-footer-text { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.login-footer-text a { color: var(--orange); font-weight: 600; }
.login-brand-footer { text-align: center; margin-top: 50px; color: #666; font-size: 12px; }
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 18px; }
.alert-error { background: #fdeceb; color: #c0392b; border: 1px solid #f5c6c1; }
.alert-success { background: #e9f9f0; color: #17915a; border: 1px solid #bdf0d3; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: var(--dark); color: #ddd; flex-shrink: 0;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 22px 20px; border-bottom: 1px solid #1e1e1e; }
.sidebar-logo .logo-mark {
    width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, var(--orange), #ffcf8a);
    display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--dark); font-size: 14px;
}
.sidebar-logo .logo-text { font-weight: 700; color: #fff; font-size: 15px; }
.sidebar-menu { flex: 1; padding: 14px 12px; overflow-y: auto; }
.sidebar-menu li { margin-bottom: 4px; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
    color: #bfbfbf; font-size: 14px; font-weight: 500; transition: 0.15s;
}
.sidebar-menu a:hover { background: #161616; color: #fff; }
.sidebar-menu a.active { background: var(--orange); color: #fff; }
.sidebar-menu .icon { width: 18px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid #1e1e1e; font-size: 12px; color: #888; }
.sidebar-footer .date-badge { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: #ccc; }

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 14px 26px; background: #fff; border-bottom: 1px solid var(--gray-border);
    position: sticky; top: 0; z-index: 20;
}
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search input {
    width: 100%; padding: 10px 14px 10px 38px; border-radius: 10px; border: 1px solid var(--gray-border);
    background: var(--gray-bg); font-size: 14px; outline: none;
}
.topbar-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #999; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar-icon-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; background: var(--gray-bg); display: flex; align-items: center; justify-content: center; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--orange); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.user-chip .name { font-size: 13px; font-weight: 700; line-height: 1.1; }
.user-chip .role { font-size: 11px; color: var(--text-muted); }
.user-menu-wrap { position: relative; }
.user-dropdown {
    display: none; position: absolute; right: 0; top: 48px; background: #fff; border: 1px solid var(--gray-border);
    border-radius: 12px; box-shadow: var(--shadow); min-width: 180px; overflow: hidden; z-index: 30;
}
.user-dropdown.show { display: block; }
.user-dropdown a, .user-dropdown button {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; width: 100%;
    background: none; border: none; text-align: left; color: #333;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--gray-bg); }

.page-content { padding: 26px; }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; margin: 0 0 4px; }
.breadcrumb { font-size: 13px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { margin: 0 6px; }

.page-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }

/* ---------- Cards ---------- */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.cards-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1100px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-icon.blue { background: #e8f1ff; color: #2f7ff0; }
.stat-icon.amber { background: #fff2df; color: #d98a1a; }
.stat-icon.green { background: #e3f9ee; color: #17a35a; }
.stat-icon.orange { background: #ffe9d6; color: var(--orange-dark); }
.stat-icon.red { background: #fdeceb; color: var(--red); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.stat-value { font-size: 22px; font-weight: 800; }
.stat-trend { font-size: 11px; margin-top: 2px; }
.stat-trend.up { color: var(--green); }
.stat-trend.down { color: var(--red); }

.charts-grid { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .charts-grid { grid-template-columns: 1fr; } }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-bar select, .filter-bar input {
    padding: 10px 14px; border-radius: 10px; border: 1px solid var(--gray-border); font-size: 13px; background: #fff;
}
.filter-bar .spacer { flex: 1; }

/* ---------- Table ---------- */
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-wrap .table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; min-width: 700px; }
table.data-table thead th {
    text-align: left; padding: 14px 16px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--text-muted); border-bottom: 1px solid var(--gray-border); white-space: nowrap;
}
table.data-table tbody td { padding: 14px 16px; font-size: 13.5px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
table.data-table tbody tr:hover { background: #fafafa; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; flex-wrap: wrap; gap: 10px; }

.badge { padding: 5px 12px; border-radius: 20px; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.badge-completed { background: #e3f9ee; color: #17a35a; }
.badge-pending { background: #fff2df; color: #d98a1a; }
.badge-cancelled { background: #fdeceb; color: var(--red); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }

.progress-track { width: 100%; height: 8px; border-radius: 6px; background: #eee; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; background: var(--orange); }
.progress-row { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress-row .pct { font-size: 12px; font-weight: 700; width: 34px; text-align: right; }

.action-btns { display: flex; gap: 6px; }

.pagination { display: flex; align-items: center; gap: 6px; }
.pagination a, .pagination span {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 13px; color: #555;
}
.pagination a.active, .pagination span.active { background: var(--orange); color: #fff; font-weight: 700; }
.pagination a:hover { background: #f2f2f2; }

/* ---------- Modal ---------- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100;
    align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; padding: 26px; max-height: 90vh; overflow-y: auto; }
.modal-box.wide { max-width: 640px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--gray-bg); font-size: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
select.form-control, input.form-control, textarea.form-control {
    width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--gray-border); font-size: 14px; outline: none;
}
select.form-control:focus, input.form-control:focus, textarea.form-control:focus { border-color: var(--orange); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--gray-border); margin-bottom: 20px; }
.tabs a { padding: 10px 18px; font-size: 13px; font-weight: 700; color: #888; border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--orange-dark); border-color: var(--orange); }
.mini-table td, .mini-table th { padding: 12px 14px; }
.access-denied-box { max-width: 480px; margin: 100px auto; text-align: center; background: #fff; padding: 40px; border-radius: 16px; box-shadow: var(--shadow); }
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th, .perm-table td { padding: 12px 14px; border-bottom: 1px solid #f0f1f3; font-size: 13px; text-align: left; }
.tag { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.tag-full { background: #e3f9ee; color: #17a35a; }
.tag-limited { background: #fff2df; color: #d98a1a; }
.tag-view { background: #e8f1ff; color: #2f7ff0; }
.tag-none { background: #f1f1f1; color: #888; }
@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: 0.25s; }
    .sidebar.open { left: 0; }
    .form-grid-2 { grid-template-columns: 1fr; }
}

/* =========================================================
   v2 ADDITIONS - Sidebar submenu, flash toast, sections,
   roles matrix, profile / 2FA, activity log, mobile layout.
   (Existing rules above are unchanged.)
   ========================================================= */

/* ---------- Sidebar submenu (Users Role > Users / Users Role) ---------- */
.sidebar-menu .sub-toggle { cursor: pointer; }
.sidebar-menu .sub-toggle .sub-chev { margin-left: auto; font-size: 11px; transition: transform .2s; }
.sidebar-menu .has-sub.open > .sub-toggle .sub-chev { transform: rotate(180deg); }
.sidebar-menu .sub-toggle.active-parent { color: #fff; background: #161616; }
.sidebar-submenu { display: none; padding: 4px 0 4px 18px; }
.sidebar-menu .has-sub.open > .sidebar-submenu { display: block; }
.sidebar-submenu li { margin-bottom: 2px; }
.sidebar-submenu a { padding: 9px 14px; font-size: 13px; }
.sidebar-close { display: none; margin-left: auto; background: none; border: none; color: #bbb; font-size: 26px; line-height: 1; }
.sidebar-backdrop { display: none; }

/* ---------- Flash toast ---------- */
.flash-toast-wrap { position: fixed; top: 76px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.flash-toast { margin: 0; box-shadow: var(--shadow); cursor: pointer; animation: flashIn .25s ease; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Sections ---------- */
.section-chip { display: inline-block; padding: 3px 9px; margin: 2px 4px 2px 0; border-radius: 999px; background: #fff4e6; color: var(--orange-dark); font-size: 11.5px; font-weight: 600; }
.section-sub { font-size: 11px; color: var(--text-muted, #6b7280); }
.dept-cards-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; align-items: flex-start; }
.dept-cards-row > .card { flex: 1 1 340px; max-width: 520px; margin-bottom: 0 !important; }
.section-select-wrap select:disabled { background: #f7f7f8; color: #9a9a9a; }

/* ---------- Roles & permissions matrix ---------- */
.perm-matrix { width: 100%; border-collapse: collapse; min-width: 640px; }
.perm-matrix th, .perm-matrix td { padding: 10px 8px; border-bottom: 1px solid #f0f1f3; font-size: 12.5px; text-align: center; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; font-weight: 600; white-space: nowrap; }
.perm-matrix thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-muted); white-space: nowrap; }
.perm-matrix input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--orange); cursor: pointer; }
.perm-matrix .na { color: #ccc; }
.perm-matrix tr.row-on td:first-child { color: var(--orange-dark); }
.role-check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: #444; }
.role-check input { width: 17px; height: 17px; accent-color: var(--orange); }
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Profile / 2FA ---------- */
.profile-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 20px; align-items: start; }
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-head .user-avatar { width: 56px; height: 56px; font-size: 22px; }
.profile-head .p-name { font-weight: 800; font-size: 17px; }
.profile-head .p-meta { font-size: 12.5px; color: var(--text-muted); }
.twofa-status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.twofa-status.on { background: #e3f9ee; color: #17a35a; }
.twofa-status.off { background: #f1f1f1; color: #777; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #d5d7db; border-radius: 28px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.twofa-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border: 1px solid var(--gray-border); border-radius: 12px; margin-bottom: 16px; }
.twofa-steps { counter-reset: st; margin: 0 0 16px; }
.twofa-steps li { counter-increment: st; position: relative; padding: 0 0 14px 40px; font-size: 13.5px; line-height: 1.5; color: #333; }
.twofa-steps li::before { content: counter(st); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.twofa-qr-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 16px; background: var(--gray-bg); border-radius: 12px; margin-bottom: 16px; }
.twofa-qr { background: #fff; padding: 10px; border-radius: 10px; line-height: 0; }
.twofa-secret { font-family: Consolas, 'Courier New', monospace; font-size: 15px; font-weight: 700; letter-spacing: 1px; background: #fff; padding: 8px 12px; border-radius: 8px; border: 1px dashed var(--orange); word-break: break-all; display: inline-block; }
.twofa-req { background: #fff8ee; border: 1px solid #ffe2bd; border-radius: 12px; padding: 14px 16px; font-size: 13px; color: #5b4425; margin-bottom: 16px; }
.twofa-req ul { list-style: disc; padding-left: 18px; margin: 6px 0 0; }
.twofa-req li { margin-bottom: 4px; }
.otp-input { letter-spacing: 8px; font-size: 22px !important; text-align: center; font-weight: 700; font-family: Consolas, monospace; }

/* ---------- Activity Log ---------- */
.log-action { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
.log-action.view { background: #e8f1ff; color: #2f7ff0; }
.log-action.create { background: #e3f9ee; color: #17a35a; }
.log-action.update { background: #fff2df; color: #c27410; }
.log-action.delete { background: #fdeceb; color: var(--red); }
.log-action.upload { background: #efe9ff; color: #7c3aed; }
.log-action.export { background: #e6fafa; color: #0f8a8a; }
.log-action.login, .log-action.logout, .log-action.twofa { background: #1c1c1c; color: #fff; }
.log-action.failed { background: #fdeceb; color: #c0392b; }
.log-desc { max-width: 460px; font-size: 13px; line-height: 1.45; }
.log-user .n { font-weight: 700; }
.log-user .r { font-size: 11px; color: var(--text-muted); }
.log-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.log-filter { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 10px; align-items: end; }
.log-filter .form-group { margin-bottom: 0; }
.log-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }

/* =========================================================
   MOBILE RESPONSIVE
   ========================================================= */
html, body { max-width: 100%; overflow-x: hidden; }
.table-scroll { -webkit-overflow-scrolling: touch; }
.modal-box { max-width: calc(100vw - 24px); }

@media (max-width: 1100px) {
    .profile-grid { grid-template-columns: 1fr; }
    .log-filter { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    /* off-canvas sidebar with backdrop */
    #sidebarToggle { display: inline-flex !important; flex-shrink: 0; font-size: 18px; }
    .sidebar { top: 0; height: 100vh; height: 100dvh; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
    .sidebar-close { display: block; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 45; }
    .sidebar.open + .sidebar-backdrop { display: block; }
    body.sidebar-open { overflow: hidden; }

    .topbar { padding: 12px 14px; gap: 10px; }
    .topbar-search { display: none; }
    .page-content { padding: 16px 14px; }
    .page-header h1 { font-size: 20px; }

    .log-stats { grid-template-columns: repeat(2, 1fr); }
    .dept-cards-row > .card { max-width: 100%; }
}

@media (max-width: 700px) {
    .user-chip-text { display: none; }
    .user-dropdown { right: -4px; }

    .page-header-row { flex-direction: column; align-items: stretch; }
    .page-header-row > .btn, .page-header-row > button { width: 100%; }
    .page-header-row .filter-bar { flex-direction: column; align-items: stretch; }
    .page-header-row .filter-bar select { min-width: 0 !important; width: 100%; }

    /* toolbars & inline search forms wrap to full width */
    .table-toolbar { padding: 12px; }
    .table-toolbar form { width: 100%; flex-wrap: wrap; }
    .table-toolbar form .form-control { min-width: 0 !important; flex: 1 1 100%; }
    .table-toolbar form .btn { flex: 1 1 auto; }
    .table-toolbar > div:not(.pagination) { width: 100%; }
    .pagination { flex-wrap: wrap; }

    /* filter grids (Reports, Activity Log) */
    form.card .form-grid-2 { grid-template-columns: 1fr 1fr !important; }
    .log-filter { grid-template-columns: 1fr 1fr; }

    /* modals become near full screen */
    .modal-overlay { padding: 10px; align-items: flex-end; }
    .modal-box { padding: 18px; border-radius: 16px; max-height: 94vh; }
    .modal-box.wide { max-width: 100%; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1 1 auto; }

    /* Add Objective: each activity row stacks */
    .activity-row-repeater .repeater-row { grid-template-columns: 1fr 1fr !important; padding: 10px; border: 1px solid var(--gray-border); border-radius: 10px; }
    .activity-row-repeater .repeater-row > input[type=text] { grid-column: 1 / -1; }
    .activity-row-repeater .repeater-row > .btn-danger { grid-column: 1 / -1; width: 100%; }

    /* accordion headers */
    .obj-group-header, .dept-group-header { padding: 12px; gap: 8px; }
    .obj-group-title, .dept-group-title { flex-wrap: wrap; font-size: 14px; }
    .obj-group-meta { margin-left: 0; width: 100%; }

    /* charts + cards */
    .dash-chart-wrap, .rpt-chart-wrap { height: 240px !important; }
    .rpt-stat-card .rpt-stat-value, .dash-stat-value { font-size: 20px; }
    .card { padding: 16px; }
    .tabs { overflow-x: auto; }
    .tabs a { white-space: nowrap; }

    .twofa-row { flex-direction: row; }
    .twofa-qr-box { justify-content: center; text-align: center; }
    .flash-toast-wrap { left: 12px; right: 12px; top: 66px; max-width: none; }
    .access-denied-box { margin: 40px 14px; padding: 28px 20px; }
}

@media (max-width: 420px) {
    form.card .form-grid-2 { grid-template-columns: 1fr !important; }
    .log-filter, .log-stats { grid-template-columns: 1fr; }
    .dash-stats, .rpt-stats { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
    .activity-row-repeater .repeater-row { grid-template-columns: 1fr !important; }
}

@media print {
    .sidebar-backdrop, .flash-toast-wrap, #sidebarToggle { display: none !important; }
}
