:root {
    --app-bg: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #eef7f4;
    --text: #1f2933;
    --muted: #667085;
    --border: #e5e7eb;
    --primary: #1f8a70;
    --primary-dark: #146c57;
    --info: #2f6f9f;
    --warning: #f4b942;
    --danger: #ee6352;
    --radius: 14px;
    --shadow: 0 10px 24px rgba(31, 41, 51, 0.08);
    --sidebar-width: 252px;
    --sidebar-collapsed-width: 84px;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

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

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

.btn {
    min-height: 44px;
    border-radius: 12px;
    font-weight: 700;
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
}

.form-control,
.form-select {
    min-height: 44px;
    border-color: var(--border);
    border-radius: 12px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(31, 138, 112, 0.65);
    box-shadow: 0 0 0 0.2rem rgba(31, 138, 112, 0.16);
}

.form-label {
    color: #344054;
    font-weight: 700;
}

.app-alert {
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-shell {
    background: var(--app-bg);
}

.auth-page {
    display: grid;
    grid-template-columns: minmax(420px, 45vw) 1fr;
    min-height: 100vh;
}

.auth-brand-panel {
    align-items: center;
    padding: 64px;
    background: var(--primary);
    color: #ffffff;
}

.auth-brand-panel > div {
    max-width: 440px;
}

.brand-mark,
.auth-icon,
.sidebar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.brand-mark {
    width: 64px;
    height: 64px;
    margin-bottom: 28px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 30px;
}

.auth-brand-panel h1 {
    margin: 0 0 16px;
    font-size: 34px;
    line-height: 1.15;
    font-weight: 800;
}

.auth-brand-panel p {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 16px;
    line-height: 1.7;
}

.auth-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    padding: 32px 20px;
}

.auth-card {
    width: 100%;
    max-width: 470px;
    margin: 0 auto;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card-wide {
    max-width: 720px;
}

.auth-card-header {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 24px;
}

.auth-icon {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--primary);
    font-size: 22px;
}

.auth-card h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
    font-weight: 800;
}

.auth-card p {
    margin: 4px 0 0;
    color: var(--muted);
}

.auth-form-meta {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 18px;
    font-size: 14px;
    font-weight: 700;
}

.auth-submit {
    margin-top: 4px;
}

.auth-switch {
    margin-top: 22px;
    text-align: center;
    color: var(--muted);
}

.auth-switch a {
    font-weight: 800;
}

.responsive-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
}

.responsive-form-grid-full {
    grid-column: 1 / -1;
}

.app-shell {
    background: var(--app-bg);
}

.app-frame {
    display: flex;
    min-height: 100vh;
}

.desktop-sidebar {
    position: sticky;
    top: 0;
    flex: 0 0 var(--sidebar-width);
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 18px 16px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    transition: width 0.2s ease, flex-basis 0.2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    margin-bottom: 16px;
    overflow: hidden;
}

.sidebar-logo {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    color: #ffffff;
    font-size: 20px;
}

.sidebar-title {
    color: var(--text);
    font-size: 17px;
    font-weight: 800;
    white-space: nowrap;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #475467;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

.sidebar-link i {
    width: 24px;
    color: #667085;
    font-size: 20px;
    text-align: center;
}

.sidebar-link.active,
.sidebar-link:hover {
    background: var(--surface-soft);
    color: var(--primary-dark);
}

.sidebar-link.active i,
.sidebar-link:hover i {
    color: var(--primary);
}

.sidebar-link.muted {
    color: #98a2b3;
}

.sidebar-logout {
    margin-top: auto;
}

.logout-link {
    width: 100%;
    color: var(--danger);
}

body.sidebar-collapsed .desktop-sidebar {
    flex-basis: var(--sidebar-collapsed-width);
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .sidebar-link span {
    display: none;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-link {
    justify-content: center;
}

.app-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.desktop-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 76px;
    padding: 14px 28px;
    background: rgba(246, 247, 251, 0.92);
    border-bottom: 1px solid rgba(229, 231, 235, 0.85);
    backdrop-filter: blur(12px);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    margin-right: auto;
}

.topbar-title strong {
    font-size: 18px;
}

.topbar-title span {
    color: var(--muted);
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
}

.icon-button:hover {
    border-color: rgba(31, 138, 112, 0.35);
    color: var(--primary);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
}

.user-chip > span,
.stack-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eaf3fb;
    color: var(--info);
    font-weight: 800;
}

.user-chip strong,
.user-chip small {
    display: block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip small {
    color: var(--muted);
    font-size: 12px;
}

.app-content {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.page-heading p {
    margin: 0 0 4px;
    color: var(--muted);
    font-weight: 700;
}

.page-heading h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
    font-weight: 850;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.kpi-card,
.data-panel,
.mobile-greeting-card,
.mobile-stat,
.attendance-card,
.quick-action-grid a,
.mobile-list,
.auth-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 116px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.kpi-card p {
    margin: 0 0 4px;
    color: var(--muted);
    font-weight: 700;
}

.kpi-card strong {
    font-size: 30px;
    line-height: 1;
}

.kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 22px;
}

.bg-success-soft {
    background: #e7f6ef;
    color: var(--primary);
}

.bg-info-soft {
    background: #eaf3fb;
    color: var(--info);
}

.bg-warning-soft {
    background: #fff4d8;
    color: #946200;
}

.bg-danger-soft {
    background: #fdeceb;
    color: var(--danger);
}

.data-panel {
    padding: 18px;
    box-shadow: var(--shadow);
}

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

.panel-header h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 800;
}

.panel-link,
.panel-badge {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.panel-badge {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0 10px;
    border-radius: 999px;
    background: #f2f4f7;
}

.app-table {
    margin-bottom: 0;
}

.app-table thead th {
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.app-table td {
    border-color: #edf0f3;
}

.table-user,
.stack-item,
.mobile-list-item,
.attendance-location {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-user > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--primary);
    font-weight: 800;
}

.table-user strong,
.table-user small,
.stack-item strong,
.stack-item small,
.mobile-list-item strong,
.mobile-list-item small {
    display: block;
}

.table-user small,
.stack-item small,
.mobile-list-item small {
    color: var(--muted);
    font-size: 12px;
}

.status-pill {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-pill.success {
    background: #e7f6ef;
    color: var(--primary-dark);
}

.status-pill.neutral {
    background: #eef2f6;
    color: #344054;
}

.stack-list {
    display: grid;
    gap: 10px;
}

.stack-item {
    min-height: 52px;
    padding: 8px 0;
    border-bottom: 1px solid #edf0f3;
}

.stack-list .stack-item:last-child {
    border-bottom: 0;
}

.stack-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--primary);
}

.empty-row,
.empty-state {
    color: var(--muted);
    text-align: center;
}

.empty-state {
    padding: 18px;
}

.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 10px 16px;
    background: rgba(246, 247, 251, 0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.mobile-topbar strong {
    max-width: 48vw;
    overflow: hidden;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-topbar-actions {
    display: flex;
    gap: 8px;
}

.mobile-dashboard {
    display: grid;
    gap: 16px;
    padding-bottom: 86px;
}

.mobile-greeting-card {
    padding: 18px;
    background: var(--primary);
    color: #ffffff;
}

.mobile-greeting-card p {
    margin: 0 0 8px;
    font-size: 21px;
    line-height: 1.25;
    font-weight: 850;
}

.mobile-greeting-card span {
    color: rgba(255, 255, 255, 0.82);
    font-weight: 700;
}

.mobile-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.mobile-stat {
    min-height: 104px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.mobile-stat span {
    display: block;
    color: var(--muted);
    font-weight: 800;
}

.mobile-stat strong {
    display: block;
    margin-top: 10px;
    font-size: 32px;
    line-height: 1;
}

.mobile-section-title {
    margin: 4px 0 -4px;
    font-size: 18px;
    line-height: 1.3;
    font-weight: 850;
}

.attendance-card {
    display: grid;
    gap: 18px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.attendance-location i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: #eaf3fb;
    color: var(--info);
    font-size: 20px;
}

.attendance-location strong,
.attendance-location span {
    display: block;
}

.attendance-location span {
    color: var(--muted);
    font-size: 13px;
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.quick-action-grid a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 12px 14px;
    color: var(--text);
    box-shadow: var(--shadow);
    font-weight: 800;
}

.quick-action-grid i {
    color: var(--primary);
    font-size: 22px;
}

.mobile-list {
    display: grid;
    gap: 8px;
    padding: 8px 14px;
    box-shadow: var(--shadow);
}

.mobile-list-item {
    min-height: 58px;
    border-bottom: 1px solid #edf0f3;
}

.mobile-list-item:last-child {
    border-bottom: 0;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 16px;
}

.settings-panel {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.settings-panel:first-child {
    grid-row: span 2;
}

.settings-panel-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.settings-panel-header h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 850;
}

.settings-panel-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.settings-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 22px;
}

.settings-switch {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-left: 3rem;
    font-weight: 800;
}

.settings-switch .form-check-input {
    width: 2.7rem;
    height: 1.45rem;
    margin-left: -3rem;
}

.settings-submit {
    min-width: 180px;
}

.settings-test-form {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.settings-test-form .input-group .btn {
    min-width: 140px;
}

.mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 72px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 24px rgba(31, 41, 51, 0.08);
}

.mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    border-radius: 12px;
    color: #667085;
    font-size: 12px;
    font-weight: 800;
}

.mobile-bottom-nav i {
    font-size: 21px;
}

.mobile-bottom-nav a.active {
    background: var(--surface-soft);
    color: var(--primary);
}

.mobile-offcanvas {
    border-top-right-radius: 16px;
    border-bottom-right-radius: 16px;
}

.offcanvas-nav {
    display: grid;
    gap: 8px;
}

.offcanvas-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 12px;
    border-radius: 12px;
    color: var(--text);
    font-weight: 800;
}

.offcanvas-nav a:hover {
    background: var(--surface-soft);
    color: var(--primary);
}

@media (max-width: 1199.98px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-panel:first-child {
        grid-row: auto;
    }
}

@media (max-width: 991.98px) {
    .auth-page {
        display: block;
        min-height: 100vh;
    }

    .auth-content {
        min-height: 100vh;
        padding: 22px 16px;
    }

    .auth-card {
        padding: 22px;
    }

    .auth-card h2 {
        font-size: 23px;
    }

    .responsive-form-grid {
        grid-template-columns: 1fr;
    }

    .app-frame {
        display: block;
    }

    .app-content {
        padding: 16px;
    }

    .settings-test-form .input-group {
        display: grid;
        gap: 10px;
    }

    .settings-test-form .input-group .form-control,
    .settings-test-form .input-group .btn {
        width: 100%;
        border-radius: 12px;
    }
}

@media (max-width: 360px) {
    .quick-action-grid {
        grid-template-columns: 1fr;
    }

    .mobile-bottom-nav span {
        font-size: 11px;
    }
}

/* SETTINGS ACCORDION UI START */
.system-settings{width:100%}
.system-settings h1{margin:0 0 16px;color:#111827;font-size:22px;line-height:1.25;font-weight:850}
.settings-accordion{display:grid;gap:16px}
.setting-accordion-item{overflow:hidden;border:1px solid #dde5ef;border-radius:8px;background:#fff;box-shadow:0 8px 22px rgba(31,41,51,.06)}
.setting-accordion-header{display:flex;align-items:center;justify-content:space-between;width:100%;min-height:52px;padding:0 20px;border:0;background:#eaf3ff;color:#0457d7;font-size:16px;font-weight:800;text-align:left}
.setting-accordion-header.collapsed{background:#fff;color:#111827}
.setting-accordion-header i{color:#0f3f77;font-size:18px;transition:transform .18s ease}
.setting-accordion-header:not(.collapsed) i{transform:rotate(180deg)}
.setting-accordion-body{padding:22px 20px 20px}
.setting-note{margin:0 0 22px;color:#344054;font-size:13px;line-height:1.6}
.setting-note code,.settings-switch code{color:#d63384;font-size:.95em}
.setting-divider{margin:22px 0;border-color:#cbd5e1;opacity:1}
.settings-mail-grid{display:grid;grid-template-columns:minmax(260px,2fr) minmax(150px,1fr) minmax(180px,1fr);gap:18px 20px}
.settings-mail-grid .field-username{grid-column:span 1}
.settings-mail-grid .field-password{grid-column:span 2}
.settings-two-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 20px}
.setting-field .form-label{margin-bottom:9px;color:#111827;font-weight:500}
.setting-field .form-control,.setting-field .form-select,.setting-test-row .form-control{min-height:38px;border-color:#d0d7de;border-radius:6px}
.field-help{margin:6px 0 0;color:#344054;font-size:13px;line-height:1.45}
.setting-updated{margin:16px 0;color:#475467;font-size:13px}
.setting-save-btn{min-height:38px;padding:0 14px;border-radius:6px;font-weight:600}
.setting-test-block{margin-top:24px}
.setting-test-block strong{display:block;margin-bottom:8px;color:#667085;font-size:12px;font-weight:850;letter-spacing:.08em;text-transform:uppercase}
.setting-test-block p{margin:0 0 16px;color:#344054;font-size:13px}
.setting-test-row{display:grid;grid-template-columns:minmax(0,1fr) 312px;gap:20px;align-items:start}
.setting-test-row .btn{min-height:38px;border-radius:6px;font-weight:600}
@media (max-width:1199.98px){
  .settings-mail-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .settings-mail-grid .field-host,.settings-mail-grid .field-password{grid-column:1/-1}
  .setting-test-row{grid-template-columns:1fr;gap:10px}
}
@media (max-width:991.98px){
  .system-settings h1{font-size:21px}
  .setting-accordion-header{min-height:54px;padding:0 16px}
  .setting-accordion-body{padding:18px 16px}
  .settings-mail-grid,.settings-two-grid{grid-template-columns:1fr;gap:14px}
  .settings-mail-grid .field-password,.settings-mail-grid .field-username,.settings-mail-grid .field-host{grid-column:auto}
}
/* SETTINGS ACCORDION UI END */
