/* ==============================================================================
   SEMUT - SISTEM INFORMASI MUTU & KESELAMATAN PASIEN (INM 01 - INM 12)
   Stylesheet Desain Hospital Maroon & Soft Blue
   ============================================================================== */

* {
    box-sizing: border-box;
}

:root {
    --maroon: #8d1735;
    --maroon2: #a92749;
    --blue: #dff1fb;
    --line: #d9e3ea;
    --white: #fff;
    --slate-text: #263238;
    --slate-muted: #71808b;
    --bg-main: #eef6fb;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg-main);
    color: var(--slate-text);
}

header {
    min-height: 68px;
    height: auto;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
    gap: 12px;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mobile-toggle-btn {
    display: none;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: var(--maroon);
    width: 38px;
    height: 38px;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.mobile-toggle-btn:hover {
    background: #e2e8f0;
}

.logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--maroon);
    color: #fff;
    font-weight: 900;
    display: grid;
    place-items: center;
    font-size: 16px;
    margin-right: 6px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand b {
    display: block;
    color: var(--maroon);
    font-size: 17px;
    line-height: 1.25;
}

.brand span {
    font-size: 11.5px;
    color: var(--slate-muted);
    display: block;
    line-height: 1.25;
}

.header-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-badge-header {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 5px 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    max-width: 100%;
}

.user-badge-text {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

.header-badge {
    background: #e8f4fc;
    color: #17658c;
    border: 1px solid #b7ddf2;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.header-badge:hover {
    background: #d4ecfa;
}

.layout {
    display: flex;
    min-height: calc(100vh - 70px);
    position: relative;
}

/* ==============================================================================
   MODERN SIDEBAR NAVIGATION (INM & IKP)
   ============================================================================== */
aside {
    width: 280px;
    background: #600c22;
    background: linear-gradient(180deg, #570b20 0%, #76122d 40%, #500a1c 100%);
    color: white;
    padding: 16px 12px 28px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
    z-index: 20;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

aside::-webkit-scrollbar {
    width: 4px;
}
aside::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 12px;
}

.sidebar-tag {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #fca5a5;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 2px;
}

.sidebar-close-btn {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 13px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-menu {
    flex: 1;
}

.nav, .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: 11px;
    margin-bottom: 5px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    transition: all 0.18s ease;
    border: 1px solid transparent;
    user-select: none;
}

.nav:hover, .nav-item:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(2px);
}

.nav.active, .nav-item.active {
    background: #ffffff !important;
    color: #70112a !important;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    border-color: #ffffff;
    transform: none;
}

.nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    flex-shrink: 0;
    transition: all 0.18s ease;
}

.nav.active .nav-icon, .nav-item.active .nav-icon {
    background: #8d1735;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(141, 23, 53, 0.28);
}

.nav-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.nav-badge-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.inm-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.nav.active .inm-badge, .nav-item.active .inm-badge {
    background: #fee2e2;
    color: #991b1b;
}

.inm-target-tag {
    font-size: 9.5px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
}

.nav.active .inm-target-tag, .nav-item.active .inm-target-tag {
    color: #8d1735;
    font-weight: 700;
}

.nav-title {
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}

.nav-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.nav.active .nav-sub, .nav-item.active .nav-sub {
    color: #8d1735;
    opacity: 0.85;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 12px 4px;
}

.mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 998;
}
.mobile-sidebar-backdrop.active {
    display: block;
}

main {
    flex: 1;
    padding: 26px;
    max-width: 1400px;
    margin: auto;
    width: 100%;
}

.top {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    align-items: center;
    margin-bottom: 22px;
}

h1 {
    font-size: 25px;
    margin: 0 0 5px;
}

.sub {
    color: var(--slate-muted);
    font-size: 13px;
}

.user {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
}

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(40, 70, 90, .05);
    margin-bottom: 18px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

label {
    font-size: 12px;
    font-weight: 700;
    color: #52616b;
}

input, select, button {
    font: inherit;
}

input, select {
    border: 1px solid #cfdbe3;
    border-radius: 9px;
    padding: 10px;
    background: #fff;
    min-height: 40px;
}

input:focus, select:focus {
    outline: 2px solid #b9dff2;
    border-color: #7dbbd8;
}

.readonly {
    background: #f3f7f9;
}

.section-title {
    font-weight: 800;
    color: var(--maroon);
    margin-bottom: 13px;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

button {
    border: 0;
    border-radius: 9px;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 700;
}

.primary {
    background: var(--maroon);
    color: #fff;
}
.primary:hover {
    background: var(--maroon2);
}

.secondary {
    background: #e7f3fa;
    color: #27546c;
}
.secondary:hover {
    background: #d4eaf5;
}

.danger {
    background: #fee8ed;
    color: #8d1735;
}
.danger:hover {
    background: #fad2db;
}

.moments {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.moment {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: #fafcfd;
    cursor: pointer;
    font-size: 12px;
}

.moment input {
    min-height: auto;
    margin-right: 5px;
}

.moment:has(input:checked) {
    border-color: #86bed8;
    background: #e8f6fc;
}

.scorebox {
    background: #f4f9fb;
    border: 1px dashed #b9d3df;
    border-radius: 12px;
    padding: 14px;
    margin-top: 15px;
}

.score {
    font-size: 28px;
    font-weight: 900;
    color: var(--maroon);
}

.tablewrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th, td {
    padding: 11px 9px;
    border-bottom: 1px solid #e4eaee;
    text-align: left;
    white-space: nowrap;
}

th {
    background: #f5f8fa;
    color: #53616a;
}

.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.kpi {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
}

.kpi small {
    color: #74818a;
}

.kpi strong {
    display: block;
    font-size: 25px;
    margin-top: 5px;
    color: var(--maroon);
}

.patuh {
    color: #167b49;
    font-weight: 800;
}

.tidak {
    color: #a51f40;
    font-weight: 800;
}

.hidden {
    display: none !important;
}

.login {
    position: fixed;
    inset: 0;
    background: rgba(45, 54, 60, .55);
    display: grid;
    place-items: center;
    z-index: 20;
}

.loginbox {
    width: min(450px, 92vw);
    background: white;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, .25);
}

.loginbox h2 {
    margin-top: 0;
    color: var(--maroon);
}

.loginbox .field {
    margin: 12px 0;
}

.hint {
    font-size: 11px;
    color: #74818a;
    line-height: 1.5;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: #25323a;
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    display: none;
    z-index: 30;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    font-size: 13px;
}

/* Dashboard additions */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.dash-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 5px 20px rgba(40, 70, 90, .05);
}

.dash-card h3 {
    margin: 0 0 5px;
    font-size: 13px;
    color: #52616b;
}

.dash-value {
    font-size: 28px;
    font-weight: 900;
    color: var(--maroon);
    margin-top: 7px;
}

.dash-sub {
    font-size: 11px;
    color: #7b8790;
}

.dash-wide {
    grid-column: span 2;
}

.dash-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.progress {
    height: 9px;
    background: #edf2f5;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 10px;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--maroon);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.module-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px;
    margin-top: 9px;
    cursor: pointer;
}

.module-link:hover {
    background: #f7fbfd;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #7b8790;
    margin-right: 6px;
}

.status-dot.good {
    background: #198754;
}

.status-dot.warn {
    background: #d69e2e;
}

/* Indicator Specific Tables */
.inm04-table th, .inm04-table td {
    border: 1px solid #d7e0e6;
    padding: 8px 7px;
    vertical-align: middle;
    white-space: normal;
}
.inm04-table th {
    background: #6ea4d1;
    color: #fff;
    text-align: center;
    font-size: 11px;
}
.inm04-table td { background: #fff; }
.inm04-table input { width: 100%; min-width: 90px; }
.inm04-table .readonly { background: #f3f7f9; }

.status-badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 11px;
    margin-top: 5px;
}
.status-badge.good { background: #e7f7ee; color: #167b49; }
.status-badge.bad { background: #fde8ee; color: #a51f40; }
.status-badge.wait { background: #eef3f6; color: #66737c; }
.inm04-note { font-size: 11px; color: #71808b; line-height: 1.45; }
.dash-card.wide-title h3 { min-height: 32px; }

/* INM 05 */
.inm05-table th, .inm05-table td {
    border: 1px solid #7b8790;
    padding: 7px 6px;
    vertical-align: middle;
    white-space: normal;
}
.inm05-table th { background: #fff800; color: #111; text-align: center; font-size: 11px; }
.inm05-table td { background: #fff; }
.inm05-table input, .inm05-table select { width: 100%; min-width: 88px; }
.inm05-table .readonly { background: #f3f7f9; }
.inm05-result.good { background: #e7f7ee; color: #167b49; }
.inm05-result.bad { background: #fde8ee; color: #a51f40; }
.inm05-result.wait { background: #eef3f6; color: #66737c; }
.inm05-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }

.master-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.master-box { background: #f8fbfd; border: 1px solid var(--line); border-radius: 13px; padding: 15px; }

/* INM 06 */
.inm06-table th, .inm06-table td { border: 1px solid #7b8790; padding: 7px 6px; vertical-align: middle; white-space: normal; }
.inm06-table th { background: #fff800; color: #111; text-align: center; font-size: 11px; }
.inm06-table td { background: #fff; }
.inm06-table input, .inm06-table select { width: 100%; min-width: 88px; }
.inm06-table .readonly { background: #f3f7f9; }
.inm06-result.good { background: #e7f7ee; color: #167b49; }
.inm06-result.bad { background: #fde8ee; color: #a51f40; }
.inm06-result.wait { background: #eef3f6; color: #66737c; }
.inm06-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }
.inm06-target { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f7fbfd; border: 1px dashed #bfd3de; font-size: 12px; color: #52616b; }

/* INM 07 */
.inm07-table th, .inm07-table td { border: 1px solid #7b8790; padding: 8px 7px; vertical-align: middle; white-space: normal; }
.inm07-table th { background: #fff800; color: #111; text-align: center; font-size: 11px; }
.inm07-table td { background: #fff; }
.inm07-table input, .inm07-table select { width: 100%; min-width: 90px; }
.inm07-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }
.inm07-result.good { background: #e7f7ee; color: #167b49; }
.inm07-result.bad { background: #fde8ee; color: #a51f40; }
.inm07-result.wait { background: #eef3f6; color: #66737c; }
.inm07-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f7fbfd; border: 1px dashed #bfd3de; font-size: 12px; color: #52616b; }

/* INM 08 */
.inm08-table th, .inm08-table td { border: 1px solid #7b8790; padding: 8px 7px; vertical-align: middle; white-space: normal; }
.inm08-table th { background: #b9d6a5; color: #111; text-align: center; font-size: 11px; }
.inm08-table td { background: #fff; }
.inm08-table input, .inm08-table select { width: 100%; min-width: 90px; }
.inm08-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }
.inm08-result.good { background: #e7f7ee; color: #167b49; }
.inm08-result.bad { background: #fde8ee; color: #a51f40; }
.inm08-result.wait { background: #eef3f6; color: #66737c; }
.inm08-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f7fbfd; border: 1px dashed #bfd3de; font-size: 12px; color: #52616b; }

/* INM 09 */
.inm09-table th, .inm09-table td { border: 1px solid #7b8790; padding: 8px 7px; vertical-align: middle; white-space: normal; }
.inm09-table th { background: #f3d86b; color: #111; text-align: center; font-size: 11px; }
.inm09-table td { background: #fff; }
.inm09-table input, .inm09-table select { width: 100%; min-width: 95px; }
.inm09-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }
.inm09-result.good { background: #e7f7ee; color: #167b49; }
.inm09-result.wait { background: #eef3f6; color: #66737c; }
.inm09-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f7fbfd; border: 1px dashed #bfd3de; font-size: 12px; color: #52616b; }

/* INM 10 */
.inm10-table th, .inm10-table td { border: 1px solid #7b8790; padding: 8px 7px; vertical-align: middle; white-space: normal; }
.inm10-table th { background: #d2a6bd; color: #111; text-align: center; font-size: 11px; }
.inm10-table td { background: #fff; }
.inm10-table input, .inm10-table select { width: 100%; min-width: 95px; }
.inm10-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }
.inm10-result.good { background: #e7f7ee; color: #167b49; }
.inm10-result.bad { background: #fde8ee; color: #a51f40; }
.inm10-result.wait { background: #eef3f6; color: #66737c; }
.inm10-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f7fbfd; border: 1px dashed #bfd3de; font-size: 12px; color: #52616b; }

/* INM 11 */
.inm11-table th, .inm11-table td { border: 1px solid #7b8790; padding: 8px 7px; vertical-align: middle; white-space: normal; }
.inm11-table th { background: #ffe8a8; color: #111; text-align: center; font-size: 11px; }
.inm11-table td { background: #fff; }
.inm11-table input, .inm11-table select { width: 100%; min-width: 90px; }
.inm11-table input[type="checkbox"] { width: 18px; min-width: 18px; height: 18px; display: block; margin: auto; }
.inm11-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }
.inm11-result.good { background: #e7f7ee; color: #167b49; }
.inm11-result.bad { background: #fde8ee; color: #a51f40; }
.inm11-result.wait { background: #eef3f6; color: #66737c; }
.inm11-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f7fbfd; border: 1px dashed #bfd3de; font-size: 12px; color: #52616b; }
.i11-summary.hidden { display: none; }

/* INM 12 */
.inm12-table th, .inm12-table td { border: 1px solid #7b8790; padding: 8px 7px; vertical-align: middle; white-space: normal; }
.inm12-table th { background: #d7e6cf; color: #111; text-align: center; font-size: 11px; }
.inm12-table td { background: #fff; }
.inm12-table input, .inm12-table select { width: 100%; min-width: 95px; }
.inm12-table .readonly { background: #f3f7f9; }
.inm12-result { display: inline-block; padding: 5px 8px; border-radius: 999px; font-weight: 800; font-size: 11px; }
.inm12-result.good { background: #e7f7ee; color: #167b49; }
.inm12-result.bad { background: #fde8ee; color: #a51f40; }
.inm12-result.wait { background: #eef3f6; color: #66737c; }
.inm12-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f7fbfd; border: 1px dashed #bfd3de; font-size: 12px; color: #52616b; }
.i12-summary.hidden { display: none; }

/* Annual Charts */
.annual-chart-card { margin-top: 14px; }
.annual-chart-toolbar {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.annual-chart-note { font-size: 12px; color: #71808b; line-height: 1.5; max-width: 760px; }
.annual-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.annual-indicator {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 15px;
    background: #fff;
}
.annual-indicator h3 { margin: 0 0 4px; font-size: 14px; color: #52616b; }
.annual-indicator .chart-meta { font-size: 11px; color: #7b8790; margin-bottom: 8px; }
.annual-svg { display: block; width: 100%; height: 210px; }
.annual-legend { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 10px; color: #7b8790; }
.annual-no-data {
    height: 210px;
    display: grid;
    place-items: center;
    color: #8a969e;
    font-size: 12px;
    background: #f8fbfd;
    border-radius: 10px;
}
.annual-point-label { font-size: 9px; fill: #52616b; }
.annual-axis-label { font-size: 9px; fill: #7b8790; }
.annual-target { stroke-dasharray: 5 4; stroke: #a92749; stroke-width: 1.2; opacity: .65; }
.annual-line { fill: none; stroke: var(--maroon); stroke-width: 2.5; }
.annual-dot { fill: var(--maroon); }
.annual-gridline { stroke: #e7edf1; stroke-width: 1; }
.annual-year-select { min-height: 39px; }

/* ==============================================================================
   RESPONSIVE MODAL SYSTEM
   ============================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.68);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 1000;
    overflow-y: auto;
}

.modal-box {
    width: min(960px, 98vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.28);
    border: 1px solid #dce6eb;
    margin: auto 0;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #fafbfc;
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}

/* Modal responsive helpers */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.filter-grid {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr auto;
    gap: 14px;
    align-items: end;
}

/* ==============================================================================
   RESPONSIVE BREAKPOINTS & MOBILE OPTIMIZATIONS (iOS & Android)
   ============================================================================== */

:root {
    --sat: env(safe-area-inset-top, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Touch targets and interactions */
button, a, select, input[type="checkbox"], input[type="radio"], .nav, .tab-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Smooth horizontal touch scroll for tables & forms */
.tablewrap, .formwrap, .table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    position: relative;
}

.tablewrap::-webkit-scrollbar, .formwrap::-webkit-scrollbar {
    height: 5px;
}
.tablewrap::-webkit-scrollbar-thumb, .formwrap::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 4px;
}
.tablewrap::-webkit-scrollbar-track, .formwrap::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.6);
}

@media (max-width: 1200px) {
    .user-badge-text { max-width: 170px; }
    .grid { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 992px) {
    .mobile-toggle-btn { 
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 10px;
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        color: #0f172a;
        font-size: 16px;
        cursor: pointer;
        flex-shrink: 0;
    }
    
    aside {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 300px;
        max-width: 86vw;
        height: 100vh;
        height: 100dvh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 12px 0 35px rgba(0, 0, 0, 0.35);
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        will-change: transform;
    }
    aside.mobile-open {
        transform: translateX(0);
    }
    
    .mobile-sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .mobile-sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-close-btn { 
        display: flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.15);
        border: 0;
        color: #fff;
        font-size: 16px;
        cursor: pointer;
    }
    
    .filter-grid { grid-template-columns: 1fr 1fr; }
    .filter-grid > div:last-child { grid-column: span 2; }
    
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .dash-wide { grid-column: span 2; }
    .dash-row { grid-template-columns: 1fr; }
    
    .master-grid { grid-template-columns: 1fr; }
    .annual-charts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* Prevent iOS Safari Automatic Zoom on Inputs */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px !important;
        min-height: 42px;
    }

    header { 
        padding: max(10px, env(safe-area-inset-top)) 12px 10px;
        gap: 10px;
    }
    .brand-wrapper {
        gap: 9px;
    }
    .brand b { font-size: 15px; }
    .brand span { display: none; }
    .user-badge-header { display: none; }
    
    .header-links {
        gap: 6px;
    }
    .header-links a, .header-links button {
        padding: 7px 11px;
        font-size: 11.5px;
        min-height: 36px;
    }
    
    main { 
        padding: 14px 10px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
    .top { 
        align-items: flex-start; 
        flex-direction: column; 
        gap: 8px; 
    }
    
    .card {
        padding: 16px 14px;
        border-radius: 14px;
    }

    .grid, .grid-4, .grid-3, .grid-2 { 
        grid-template-columns: 1fr !important; 
        gap: 10px;
    }
    .kpis { 
        grid-template-columns: 1fr 1fr; 
        gap: 8px;
    }
    .moments { 
        grid-template-columns: 1fr; 
    }
    
    /* Native Mobile Bottom Sheet / Modal Dialog for iOS & Android */
    .modal {
        padding: 0;
        align-items: flex-end;
    }
    .modal-box { 
        width: 100% !important; 
        max-width: 100% !important;
        max-height: 92vh !important;
        max-height: 92dvh !important;
        border-radius: 22px 22px 0 0 !important;
        margin: 0 !important;
        padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25) !important;
    }
    .modal-body { padding: 16px 14px; }
    .modal-header { padding: 14px 16px; }
    .modal-footer { padding: 14px 16px; flex-direction: column-reverse; gap: 8px; }
    .modal-footer button { width: 100%; justify-content: center; min-height: 44px; }

    /* Action buttons on mobile */
    .actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    .actions button {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
}

@media (max-width: 600px) {
    .header-links { 
        width: 100%; 
        justify-content: space-between; 
    }
    .user-badge-header { 
        width: 100%; 
        justify-content: flex-start; 
    }
    .user-badge-text { max-width: 180px; }
    
    .filter-grid { grid-template-columns: 1fr; }
    .filter-grid > div:last-child { grid-column: span 1; }
    
    .dashboard-grid, .dash-row, .kpis { grid-template-columns: 1fr; }
    .dash-wide { grid-column: span 1; }
    
    .scorebox {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Tab-bar swipe on mobile */
    .tab-bar {
        display: flex;
        gap: 8px;
        border-bottom: 2px solid #e2e8f0;
        margin-bottom: 18px;
        overflow-x: auto;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        scrollbar-width: none;
    }
    .tab-bar::-webkit-scrollbar {
        display: none;
    }
    .tab-item {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 9px 14px;
        font-size: 12px;
    }
}

/* Very compact devices (iPhone SE, Galaxy Fold 320px) */
@media (max-width: 380px) {
    header { padding: max(8px, env(safe-area-inset-top)) 8px 8px; }
    .brand b { font-size: 14px; }
    .card { padding: 12px 10px; }
    .kpi { padding: 10px; }
    .kpi strong { font-size: 18px; }
}

/* ==========================================================================
   INM 01-12 Subtabs (Formulir Observasi vs Riwayat Pengisian)
   ========================================================================== */
.inm-subtabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eef2f6;
    padding: 5px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid #dce4ec;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.inm-subtab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
}
.inm-subtab:hover {
    color: #8d1735;
    background: rgba(255, 255, 255, 0.7);
}
.inm-subtab.active {
    background: #ffffff;
    color: #8d1735;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.inm-subtab .badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(141, 23, 53, 0.12);
    color: #8d1735;
    transition: all 0.2s ease;
}
.inm-subtab.active .badge-count {
    background: #8d1735;
    color: #ffffff;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.history-card-header .title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.history-card-header .title-group .title {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-card-header .title-group .subtitle {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}
.history-btn-new {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    background: #8d1735;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}
.history-btn-new:hover {
    background: #73122b;
}
.history-btn-new:active {
    transform: scale(0.98);
}

.badge-pill {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}
.badge-pill.patuh, .badge-pill.tercapai { background: #e7f7ee; color: #167b49; border: 1px solid #b7ebd0; }
.badge-pill.tidak { background: #fee8ed; color: #8d1735; border: 1px solid #f8b4c4; }
.badge-pill.wait { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }

.btn-del-entry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 6px;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-del-entry:hover {
    background: #dc2626;
    color: #ffffff;
}

@media (max-width: 768px) {
    .inm-subtabs {
        width: 100%;
        display: flex;
    }
    .inm-subtab {
        flex: 1;
        justify-content: center;
        padding: 9px 10px;
        font-size: 12px;
    }
}

