/* ============================================
   COMPONENTS — Reusable UI Components
   ============================================ */

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0) scale(0.96);
    transition-duration: 0.1s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 6px -1px rgba(20, 184, 166, 0.4), 0 2px 4px -1px rgba(20, 184, 166, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .btn-primary {
    /* Ensure visibility on light mode */
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-surface-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--border-color-strong);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    color: white;
    box-shadow: var(--shadow-glow-danger);
}

.btn-warning {
    background: var(--warning);
    color: #0f172a;
}

.btn-warning:hover {
    background: #d97706;
    color: #0f172a;
}

[data-theme="dark"] .btn-warning {
    color: var(--text-inverse);
}

[data-theme="dark"] .btn-warning:hover {
    color: var(--text-inverse);
}

.btn-info {
    background: var(--info);
    color: white;
}

[data-theme="light"] .btn-info {
    color: white;
}

.btn-info:hover {
    background: #2563eb;
    color: white;
    box-shadow: var(--shadow-glow-info);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-sm i {
    font-size: 0.75rem;
}

/* ---- Outline Buttons ---- */
.btn-outline-primary {
    background: transparent;
    color: var(--primary-500);
    border: 1px solid var(--primary-500);
}

.btn-outline-primary:hover {
    background: var(--primary-500);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color-strong);
}

.btn-outline-secondary:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-outline-success {
    background: transparent;
    color: var(--success);
    border: 1px solid var(--success);
}

.btn-outline-success:hover {
    background: var(--success);
    color: white;
}

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-outline-warning {
    background: transparent;
    color: var(--warning);
    border: 1px solid var(--warning);
}

.btn-outline-warning:hover {
    background: var(--warning);
    color: #0f172a;
}

.btn-outline-info {
    background: transparent;
    color: var(--info);
    border: 1px solid var(--info);
}

.btn-outline-info:hover {
    background: var(--info);
    color: white;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-color-strong);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

.card-chart {
    flex: 1.5;
}

/* ---- Stat Cards ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    border-radius: 0;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-primary::before {
    background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
}

.stat-success::before {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.stat-warning::before {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.stat-danger::before {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.stat-info::before {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-primary .stat-icon {
    background: rgba(20, 184, 166, 0.15);
    color: var(--primary-text-active, var(--primary-400));
}

.stat-success .stat-icon {
    background: var(--success-bg);
    color: var(--success);
}

.stat-warning .stat-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-danger .stat-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-info .stat-icon {
    background: var(--info-bg);
    color: var(--info);
}

.stat-info-text {
    display: flex;
    flex-direction: column;
}

/* rename to avoid collision with .stat-info */
.stat-card .stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Stat Card Entrance Animation ---- */
@keyframes statCardEntrance {
    0% {
        opacity: 0;
        transform: translateY(24px) scale(0.95);
    }

    60% {
        opacity: 1;
        transform: translateY(-4px) scale(1.01);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.stat-card {
    animation: statCardEntrance 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--card-index, 0) * 0.1s);
}

/* ---- Icon Keyframe Animations ---- */
@keyframes iconPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.18);
    }
}

@keyframes iconShake {

    0%,
    100% {
        transform: rotate(0deg);
    }

    15% {
        transform: rotate(-8deg);
    }

    30% {
        transform: rotate(8deg);
    }

    45% {
        transform: rotate(-5deg);
    }

    60% {
        transform: rotate(5deg);
    }

    75% {
        transform: rotate(-2deg);
    }

    90% {
        transform: rotate(2deg);
    }
}

@keyframes iconBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }

    50% {
        transform: translateY(0);
    }

    70% {
        transform: translateY(-3px);
    }
}

@keyframes iconFlip {
    0% {
        transform: rotateX(0deg);
    }

    50% {
        transform: rotateX(180deg);
    }

    100% {
        transform: rotateX(360deg);
    }
}

@keyframes iconGlow {

    0%,
    100% {
        box-shadow: 0 0 0 0 currentColor;
    }

    50% {
        box-shadow: 0 0 12px 2px currentColor;
    }
}

/* Icon Animation Classes */
.stat-icon.anim-pulse i {
    display: inline-block;
    animation: iconPulse 2s ease-in-out infinite;
    animation-delay: calc(var(--card-index, 0) * 0.15s + 0.6s);
}

.stat-icon.anim-shake i {
    display: inline-block;
    animation: iconShake 2.5s ease-in-out infinite;
    animation-delay: calc(var(--card-index, 0) * 0.15s + 0.6s);
}

.stat-icon.anim-bounce i {
    display: inline-block;
    animation: iconBounce 2s ease-in-out infinite;
    animation-delay: calc(var(--card-index, 0) * 0.15s + 0.6s);
}

.stat-icon.anim-flip i {
    display: inline-block;
    animation: iconFlip 3s ease-in-out infinite;
    animation-delay: calc(var(--card-index, 0) * 0.15s + 0.6s);
}

/* Glow effect on icon container */
.stat-icon.anim-pulse,
.stat-icon.anim-shake {
    animation: iconGlow 2.5s ease-in-out infinite;
    animation-delay: calc(var(--card-index, 0) * 0.15s + 0.8s);
}

/* ---- Desktop-only Hover Effects ---- */
@media (hover: hover) {
    .stat-card:hover .stat-icon i {
        transform: scale(1.25) rotate(8deg);
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .stat-card:hover .stat-icon {
        box-shadow: 0 0 16px 3px currentColor;
        transition: box-shadow 0.3s ease;
    }

    /* Pause continuous animation on hover for clean effect */
    .stat-card:hover .stat-icon.anim-pulse i,
    .stat-card:hover .stat-icon.anim-shake i,
    .stat-card:hover .stat-icon.anim-bounce i,
    .stat-card:hover .stat-icon.anim-flip i {
        animation-play-state: paused;
    }
}

/* ---- Mobile Tap/Active Effects ---- */
.stat-card:active {
    transform: scale(0.96) !important;
    transition: transform 0.15s ease;
}

.stat-card:active .stat-icon {
    box-shadow: 0 0 14px 3px currentColor;
    transition: box-shadow 0.15s ease;
}

.stat-card:active .stat-icon i {
    transform: scale(1.3) !important;
    transition: transform 0.15s ease;
}

/* ---- Reduced Motion Accessibility ---- */
@media (prefers-reduced-motion: reduce) {

    .stat-card,
    .stat-icon.anim-pulse i,
    .stat-icon.anim-shake i,
    .stat-icon.anim-bounce i,
    .stat-icon.anim-flip i,
    .stat-icon.anim-pulse,
    .stat-icon.anim-shake {
        animation: none !important;
    }
}

/* ---- Tables ---- */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    box-sizing: border-box;
}

.table thead th,
.table tbody td {
    box-sizing: border-box;
}

.table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table thead th.text-right {
    text-align: right;
    width: 135px;
}

.table thead th.text-center {
    text-align: center;
    width: 100px;
}

.table tbody td {
    padding: 0.7rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table tbody td.text-right {
    text-align: right;
    width: 135px;
}

.table tbody td.text-center {
    text-align: center;
    width: 100px;
}

.table tbody tr {
    transition: var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tfoot td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-top: 2px solid var(--border-color-strong);
}

.actions {
    white-space: nowrap;
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.row-highlight {
    background: rgba(245, 158, 11, 0.05);
}

.text-right {
    text-align: right;
}

.nowrap {
    white-space: nowrap;
}

/* ---- Mobile Card View for Tables ---- */
@media (max-width: 768px) {

    .table-responsive .table thead {
        display: none;
        /* Hide headers */
    }

    .table-responsive .table tbody tr,
    .table-responsive .table tfoot tr {
        display: block;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: var(--shadow-sm);
    }

    .table-responsive .table td {
        display: flex;
        justify-content: flex-start;
        /* Changed from space-between */
        gap: 0.5rem;
        /* Add gap between label and value */
        align-items: center;
        border: none;
        padding: 0.5rem 0;
        text-align: left;
        /* Changed from right */
        border-bottom: 1px dashed var(--border-color);
        flex-wrap: wrap;
        /* Allow wrapping if needed */
    }

    .table-responsive .table td.text-right {
        text-align: right;
        justify-content: flex-end;
    }

    .table-responsive .table td.text-center {
        text-align: center;
        justify-content: center;
    }

    .table-responsive .table td:last-child {
        border-bottom: none;
    }

    /* Label from data-label */
    .table-responsive .table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-muted);
        text-align: left;
        margin-right: 0.5rem;
        min-width: 100px;
        /* Ensure labels have consistent width for alignment */
        flex-shrink: 0;
    }

    /* Specific adjustments */
    .table tbody td[data-label="Nama"] {
        font-weight: 700;
        color: var(--primary-500);
        font-size: 1rem;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .table tbody td[data-label="Nama"]::before {
        display: none;
        /* Hide "Nama" label as it's the title */
    }

    /* Actions Column - Side-by-Side Buttons (anti salah tekan) */
    .table-responsive .table tbody td.actions {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.75rem;
        align-items: stretch;
        margin-top: 0.5rem;
        border-top: 1px dashed var(--border-color);
        padding-top: 1rem;
    }

    .table-responsive .table tbody td.actions::before {
        display: none !important;
    }

    .table-responsive .table tbody td.actions .btn,
    .table-responsive .table tbody td.actions form {
        flex: 1 1 calc(50% - 0.5rem) !important;
        min-width: max-content !important;
        width: auto !important;
        display: block !important;
    }

    .table-responsive .table tbody td.actions form .btn {
        width: 100%;
        display: inline-flex !important;
        justify-content: center;
    }

    .table-responsive .table tbody td.actions a.btn {
        width: 100%;
        display: inline-flex !important;
        justify-content: center;
    }

    /* Mobile Filter Bar - Stacked & Full Width */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .filter-bar input,
    .filter-bar select,
    .filter-bar button {
        width: 100% !important;
        flex-basis: auto !important;
        min-width: 0;
    }

    /* Card Header - Side-by-Side Buttons */
    .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card-header h3 {
        flex: 1;
        min-width: 0;
    }

    .header-actions {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.5rem;
        align-items: center;
        flex-shrink: 0;
    }

    .header-actions .dropdown {
        margin-left: 0 !important;
    }

    /* Modal Footer - Side-by-Side Buttons */
    .modal-footer {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1 1 calc(30% - 0.5rem);
    }

    /* Form Actions - Side-by-Side Buttons */
    .form-actions {
        flex-direction: row !important;
        flex-wrap: nowrap;
        gap: 0.75rem;
    }

    .form-actions .btn {
        flex: 1;
        justify-content: center;
        width: 100%;
    }

    /* Card Header Actions - Stack vertically on mobile */
    .card-header-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        margin-top: 0.5rem;
    }

    .card-header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .btn-mobile-block {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Dashboard Grid Responsive */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ---- Forms ---- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.form-row-responsive {
    grid-column: span 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {

    .form-row-responsive,
    div.form-row-responsive,
    .form-grid>.form-row-responsive {
        grid-template-columns: 1fr !important;
        grid-column: span 1 !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }
}

.grand-total-input {
    font-size: 1.5rem;
    height: 3.5rem;
    font-weight: 700;
    color: var(--primary-500);
    border: 2px solid var(--primary-500);
    background: var(--bg-surface);
}

[data-theme="dark"] .grand-total-input {
    background: var(--bg-surface-2);
}

@media (max-width: 640px) {
    .grand-total-input {
        font-size: 1.25rem;
        height: 3.25rem;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    padding: 0.65rem 0.9rem;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.form-control {
    width: 100%;
}

/* ---- Input Group ---- */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.search-bar .input-group {
    max-width: 400px;
    /* Shorten the search field as requested */
}

.input-group .form-control,
.input-group input[type="text"],
.input-group input[type="number"],
.input-group select {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    margin-left: -1px;
}

.input-sm {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    width: 120px;
}

textarea {
    resize: vertical;
}

.checkbox-label {
    flex-direction: row !important;
    gap: 0.5rem !important;
    cursor: pointer;
    padding: 0.5rem 0;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary-500);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

/* ---- Filters ---- */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
    width: auto;
    min-width: 160px;
}

.filter-bar button {
    flex-basis: 48px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

[data-theme="dark"] .badge {
    background: rgba(255, 255, 255, 0.08);
}

.badge-primary {
    background: color-mix(in srgb, var(--primary-500) 15%, transparent);
    color: var(--primary-600);
}

[data-theme="dark"] .badge-primary {
    background: color-mix(in srgb, var(--primary-500) 20%, transparent);
    color: var(--primary-400);
}

.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-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-secondary {
    background: rgba(148, 163, 184, 0.15);
    color: var(--gray-400);
}

/* ---- Alerts ---- */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    margin: 0 1.5rem 1rem;
    font-size: 0.875rem;
    animation: slideDown 0.3s ease;
    position: relative;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 1rem;
}

.alert-close:hover {
    opacity: 1;
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ---- Activity List ---- */
.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    color: var(--primary-400);
    font-size: 0.5rem;
    padding-top: 0.4rem;
}

.activity-content {
    display: flex;
    flex-direction: column;
}

.activity-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Info Grid ---- */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.info-item {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .info-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.info-item strong {
    color: var(--text-primary);
}

/* ---- Modal ---- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    animation: modalIn 0.3s ease;
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---- Utility Classes ---- */
.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.font-bold {
    font-weight: 700;
}

@media (max-width: 640px) {

    .form-grid,
    form.form-grid,
    body .form-grid {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
    }

    .form-group,
    .form-grid>.form-group {
        width: 100% !important;
        grid-column: span 1 !important;
    }

    .stat-value {
        font-size: 1.1rem;
    }
}

/* ============================================
   OPNAME COUNTING — Mobile-Optimized UX
   ============================================ */

/* ---- Progress Tracker ---- */
.opname-progress {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    position: sticky;
    top: 60px;
    z-index: 20;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

.opname-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.opname-progress-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.opname-progress-label i {
    color: var(--primary-500);
}

.opname-progress-pct {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-500);
}

.opname-progress-bar {
    height: 6px;
    background: var(--bg-surface-hover);
    border-radius: 3px;
    overflow: hidden;
}

.opname-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary-600), var(--primary-500));
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.4s ease;
}

.opname-progress-legend {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.legend-item {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-match i {
    color: #22c55e;
    font-size: 0.45rem;
}

.legend-surplus i {
    color: #f59e0b;
    font-size: 0.45rem;
}

.legend-minus i {
    color: #ef4444;
    font-size: 0.45rem;
}

.legend-untouched i {
    color: var(--text-muted);
    font-size: 0.45rem;
}

/* ---- Search & Filter Toolbar ---- */
.opname-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.opname-search {
    position: relative;
    display: flex;
    align-items: center;
}

.opname-search>i {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.opname-search input {
    width: 100%;
    padding: 0.6rem 2.2rem 0.6rem 2.2rem;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.opname-search input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.opname-search-clear {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    transition: var(--transition-fast);
}

.opname-search-clear:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.opname-filters {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.opname-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.opname-filter-btn:hover {
    border-color: var(--primary-500);
    color: var(--primary-500);
}

.opname-filter-btn.active {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
}

.filter-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.opname-filter-btn:not(.active) .filter-count {
    background: var(--bg-surface-hover);
}

/* ---- Draft Banner ---- */
.opname-draft-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--info-bg);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    transition: opacity 0.3s ease;
    flex-wrap: wrap;
}

.draft-banner-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--info);
}

.draft-banner-content i {
    font-size: 1rem;
}

/* ---- Stepper Group ---- */
.stepper-group {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    overflow: hidden;
    background: var(--bg-surface-hover);
}

.stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
    flex-shrink: 0;
    line-height: 1;
}

.stepper-btn:hover {
    background: var(--primary-500);
    color: white;
}

.stepper-btn:active {
    transform: scale(0.9);
}

.stepper-group .opname-stock-input {
    width: 60px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0.3rem 0.2rem;
    font-weight: 700;
    font-size: 0.95rem;
    background: var(--bg-surface-hover);
    -moz-appearance: textfield;
    appearance: textfield;
}

.stepper-group .opname-stock-input::-webkit-outer-spin-button,
.stepper-group .opname-stock-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* ---- Difference Badge ---- */
.diff-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 32px;
    text-align: center;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.diff-match {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.diff-surplus {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.diff-minus {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

/* ---- Row States ---- */
.opname-row.opname-editing {
    background: rgba(20, 184, 166, 0.06) !important;
}

.opname-row.opname-scanned {
    background: rgba(34, 197, 94, 0.15) !important;
    transition: background 0.3s ease;
}

.opname-row.item-surplus {
    border-left: 3px solid #f59e0b;
}

.opname-row.item-minus {
    border-left: 3px solid #ef4444;
}

/* ---- Empty State ---- */
.opname-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    text-align: center;
    gap: 0.75rem;
}

.opname-empty i {
    font-size: 2.5rem;
    opacity: 0.4;
}

.opname-empty p {
    font-size: 0.9rem;
    margin: 0;
}

/* ---- Floating Action Button ---- */
.opname-fab {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 50;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 0.5rem;
}

.opname-fab-main {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(20, 184, 166, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.opname-fab-main:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(20, 184, 166, 0.5);
}

.opname-fab-main.open {
    transform: rotate(45deg);
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.opname-fab-menu {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    opacity: 0;
    transform: translateY(10px) scale(0.8);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.opname-fab-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.opname-fab-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 24px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
    white-space: nowrap;
    transition: var(--transition-fast);
    border: 1px solid var(--border-color);
}

.opname-fab-item:hover {
    transform: translateX(-4px);
    box-shadow: var(--shadow-lg);
}

.opname-fab-item i {
    font-size: 0.9rem;
    width: 20px;
    text-align: center;
}

.fab-submit i {
    color: #22c55e;
}

.fab-scan i {
    color: var(--primary-500);
}

.fab-top i {
    color: var(--info);
}

/* ---- Auto-save Toast ---- */
.opname-autosave-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-surface);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 60;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.opname-autosave-toast i {
    color: var(--primary-500);
}

.opname-autosave-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- Mobile Card View (hidden on desktop) ---- */
.opname-cards-mobile {
    display: none;
}

/* ---- Mobile Overrides ---- */
@media (max-width: 768px) {

    /* Hide desktop table, show mobile cards */
    .opname-table-desktop {
        display: none !important;
    }

    .opname-cards-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* Progress sticky adjustment */
    .opname-progress {
        top: 56px;
        margin-left: -1.25rem;
        margin-right: -1.25rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 0.6rem 1rem;
    }

    /* Toolbar */
    .opname-toolbar {
        gap: 0.5rem;
    }

    .opname-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .opname-filters::-webkit-scrollbar {
        display: none;
    }

    /* Card Styles */
    .opname-card {
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        overflow: visible;
        transition: all 0.2s ease;
    }

    .opname-card.opname-editing {
        border-color: var(--primary-500);
        box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.15);
    }

    .opname-card.opname-scanned {
        border-color: #22c55e;
        box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
        background: rgba(34, 197, 94, 0.05);
    }

    .opname-card.item-surplus {
        border-left: 3px solid #f59e0b;
    }

    .opname-card.item-minus {
        border-left: 3px solid #ef4444;
    }

    .opname-card.item-match {
        border-left: 3px solid #22c55e;
    }

    .opname-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.75rem 0.75rem 0.4rem;
        gap: 0.5rem;
    }

    .opname-card-title {
        flex: 1;
        min-width: 0;
    }

    .opname-card-name {
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--text-primary);
        display: block;
        line-height: 1.3;
    }

    .opname-card-meta {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        margin-top: 0.2rem;
    }

    .opname-card-code {
        font-size: 0.72rem;
        padding: 0.1rem 0.35rem;
        border-radius: 4px;
        background: var(--bg-surface-hover);
    }

    .opname-card-unit {
        font-size: 0.72rem;
        color: var(--text-muted);
    }

    .opname-card-diff-indicator {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 1.1rem;
        flex-shrink: 0;
        color: var(--text-muted);
    }

    .opname-card-diff-indicator.indicator-match {
        color: #22c55e;
    }

    .opname-card-diff-indicator.indicator-surplus {
        color: #f59e0b;
    }

    .opname-card-diff-indicator.indicator-minus {
        color: #ef4444;
    }

    .opname-card-body {
        padding: 0 0.75rem 0.5rem;
    }

    .opname-card-stock-row {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 0.5rem;
    }

    .opname-card-system {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }

    .opname-card-stock-label {
        font-size: 0.7rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        font-weight: 600;
    }

    .opname-card-stock-value {
        font-family: 'Outfit', sans-serif;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--text-primary);
    }

    .opname-card-unit-inline {
        font-size: 0.7rem;
        color: var(--text-muted);
        font-weight: 400;
    }

    .opname-card-arrow {
        display: none;
    }

    .opname-card-physical {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        min-width: 0;
    }

    .stepper-group-mobile {
        width: 100% !important;
        display: flex !important;
        border: 2px solid var(--border-color-strong) !important;
        border-radius: var(--radius-xs) !important;
        overflow: hidden !important;
        min-width: 0;
    }

    .stepper-group-mobile .stepper-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        font-size: 1.2rem !important;
        font-weight: 900 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: var(--primary-500) !important;
        color: white !important;
        border: none !important;
        cursor: pointer;
        flex-shrink: 0 !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
    }

    .stepper-group-mobile .stepper-btn:active {
        background: var(--primary-600) !important;
        transform: scale(0.92);
    }

    .stepper-group-mobile .opname-stock-input {
        flex: 1 1 0% !important;
        width: 0 !important;
        min-width: 0 !important;
        font-size: 1.1rem !important;
        height: 40px !important;
        font-weight: 700 !important;
        text-align: center !important;
        border: none !important;
        border-left: 2px solid var(--border-color-strong) !important;
        border-right: 2px solid var(--border-color-strong) !important;
        border-radius: 0 !important;
        padding: 0 0.2rem !important;
        background: var(--bg-surface) !important;
        color: var(--text-primary) !important;
    }

    .opname-card-diff-row {
        display: flex;
        justify-content: center;
        margin-top: 0.4rem;
    }

    .diff-badge-card {
        font-size: 0.8rem;
        padding: 0.2rem 0.75rem;
    }

    /* Notes (collapsible) */
    .opname-card-notes {
        border-top: 1px solid var(--border-color);
        overflow: hidden;
    }

    .opname-notes-toggle {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        width: 100%;
        padding: 0.5rem 0.75rem;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 0.78rem;
        font-weight: 500;
        cursor: pointer;
        transition: var(--transition-fast);
    }

    .opname-notes-toggle:hover {
        color: var(--text-secondary);
        background: var(--bg-surface-hover);
    }

    .opname-notes-chevron {
        margin-left: auto;
        font-size: 0.65rem;
        transition: transform 0.2s ease;
    }

    .opname-card.notes-open .opname-notes-chevron {
        transform: rotate(180deg);
    }

    .opname-notes-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease, padding 0.25s ease;
        padding: 0 0.75rem;
    }

    .opname-card.notes-open .opname-notes-content {
        max-height: 80px;
        padding: 0 0.75rem 0.6rem;
    }

    .opname-notes-content input {
        width: 100%;
        font-size: 0.85rem;
    }

    /* FAB positioning */
    .opname-fab {
        bottom: 80px;
        right: 16px;
    }

    .opname-fab-main {
        width: 48px;
        height: 48px;
        font-size: 1.1rem;
    }

    /* Autosave toast position */
    .opname-autosave-toast {
        bottom: 72px;
    }

    /* Draft banner */
    .opname-draft-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}