/* AINet Activation Mobile */

.app-logo {
    display: block;
    width: min(280px, 82%);
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    background: transparent;
}

:root {
    --primary: #0092e7;
    --primary-dark: #006aad;
    --primary-light: #33aae9;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --dark: #343a40;
    --border: #dee2e6;
    --bottom-nav-h: 64px;
    --header-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #212529;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

#loginScreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.login-logo-wrap {
    text-align: center;
    margin-bottom: 20px;
}

.login-card h1 {
    font-size: 1.4rem;
    text-align: center;
    margin-bottom: 4px;
    color: var(--dark);
}

.login-card .subtitle {
    text-align: center;
    color: #6c757d;
    font-size: .85rem;
    margin-bottom: 24px;
}

.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #495057;
}

.form-group label .req { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .92rem;
    outline: none;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 146, 231, .12);
}

.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    border-radius: 8px;
}

.password-toggle:active {
    background: rgba(0, 146, 231, .1);
}

.form-group .hint {
    display: block;
    font-size: .75rem;
    color: #6c757d;
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input { flex: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s, transform .1s;
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: #495057; }
.btn-sm { padding: 8px 10px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; flex-shrink: 0; }

#appShell {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    height: var(--header-h);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    flex-shrink: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header .user-name {
    font-size: .72rem;
    opacity: .85;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.stat-card .value { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: .68rem; color: #6c757d; margin-top: 2px; }

.filter-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.filter-bar-3 {
    grid-template-columns: 1fr;
}

@media (min-width: 420px) {
    .filter-bar-3 {
        grid-template-columns: 1fr 1fr;
    }
}

.filter-bar select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .85rem;
    background: #fff;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .9rem;
    margin-bottom: 12px;
    background: #fff;
}

.filter-hint {
    font-size: .78rem;
    color: #6c757d;
    margin: -4px 0 12px;
    padding: 0 2px;
}

.filter-hint i { color: var(--primary); margin-right: 4px; }

.item-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border-left: 4px solid var(--primary);
    cursor: pointer;
}

.item-card.inactive { border-left-color: var(--danger); opacity: .85; }

.item-card .card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.item-card .card-title { font-weight: 700; font-size: .92rem; }
.item-card .card-code { font-size: .78rem; color: #6c757d; font-family: monospace; }
.item-card .card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: .68rem;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-primary { background: #d6ecfa; color: #006aad; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; display: block; }

.form-card {
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.section-title {
    font-size: .9rem;
    color: var(--primary);
    margin: 16px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

.section-title:first-child { margin-top: 0; }

.photo-upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.photo-upload-grid .form-group {
    position: relative;
}

.photo-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.photo-upload-card {
    display: block;
    position: relative;
    min-height: 148px;
    border: 1.5px dashed var(--border);
    border-radius: 14px;
    background: rgba(0, 146, 231, .06);
    overflow: hidden;
}

.photo-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 148px;
    padding: 12px 8px;
    color: #6c757d;
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.35;
}

.photo-upload-placeholder i {
    font-size: 1.35rem;
    color: var(--primary);
}

.photo-upload-img {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 148px;
    object-fit: cover;
    background: #d7e5f0;
    z-index: 1;
}

.photo-upload-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}

.photo-upload-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 36px;
    padding: 7px 6px;
    border: 1px solid rgba(0, 146, 231, .22);
    border-radius: 8px;
    background: rgba(0, 146, 231, .06);
    color: var(--primary-dark);
    font-size: .7rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
}

.photo-upload-action i {
    font-size: .78rem;
}

.photo-upload-remove {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 7px 8px;
    border: 0;
    border-radius: 8px;
    background: #f8d7da;
    color: #721c24;
    font-size: .72rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.photo-upload-hint {
    display: block;
    margin: -4px 0 14px;
    font-size: .74rem;
    color: #6c757d;
}

.detail-profile {
    background: #fff;
    border-radius: 14px;
    padding: 20px 16px;
    text-align: center;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.detail-profile .avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 12px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
}

.detail-profile h2 { font-size: 1.1rem; margin-bottom: 4px; }
.detail-profile .code { font-family: monospace; color: #6c757d; font-size: .85rem; }

.detail-section {
    background: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.detail-section h3 {
    font-size: .88rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: .85rem;
    border-bottom: 1px solid #f0f0f0;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: #6c757d; }
.detail-row .value { font-weight: 600; text-align: right; max-width: 60%; word-break: break-word; }
.detail-wa-btn { margin-left: 8px; vertical-align: middle; }

.detail-photo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.detail-photo-item {
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.detail-photo-label {
    font-size: .75rem;
    color: #6c757d;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.detail-photo-item img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
}

.detail-photo-empty {
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: .8rem;
}

.detail-map-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.detail-map-frame {
    width: 100%;
    height: 240px;
    border: 0;
    display: block;
}

.detail-map-link {
    margin: 10px;
}

.detail-map-empty {
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    color: #6c757d;
    font-size: .85rem;
}

.pppoe-item {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.pppoe-item:last-child { border-bottom: none; }
.pppoe-item .username { font-weight: 700; font-family: monospace; font-size: .88rem; }
.pppoe-item .plan { font-size: .8rem; color: #6c757d; }

.detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: .65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
}

.nav-tab i { font-size: 1.15rem; }
.nav-tab.active { color: var(--primary); }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 360px) {
    .form-row { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}
