#avf-root, #avf-root * { box-sizing: border-box; }
#avf-root {
    max-width: 980px;
    margin: 20px auto;
    background: #FFFDF7;
    border: 1px solid #E8C77A;
    border-radius: 10px;
    padding: 24px;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: #4A3B22;
}
.avf-header { text-align: center; margin-bottom: 14px; }
.avf-header h2 {
    margin: 0;
    color: #B4530A;
    letter-spacing: 1px;
    font-size: 24px;
}
.avf-header .avf-sub { margin: 4px 0 0; color: #8A6D3B; font-size: 13px; letter-spacing: 2px; }

.avf-tabs { display: flex; gap: 8px; margin: 18px 0; flex-wrap: wrap; }
.avf-tab-btn {
    flex: 1;
    min-width: 140px;
    background: #FBEFD8;
    border: 1px solid #E8C77A;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;
    color: #6B4E1E;
    line-height: 1.4;
}
.avf-tab-btn span { font-size: 11px; color: #9A7A3E; }
.avf-tab-btn.active { background: linear-gradient(180deg,#F7A93B,#E8850F); color: #fff; border-color: #E8850F; }
.avf-tab-btn.active span { color: #FFF4E0; }

.avf-tab-panel { display: none; }
.avf-tab-panel.active { display: block; animation: avfFade .2s ease; }
@keyframes avfFade { from { opacity: 0; } to { opacity: 1; } }

.avf-note {
    background: #FFF6E5;
    border: 1px solid #F0D9A0;
    border-left: 4px solid #E8850F;
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.6;
}

.avf-field { margin-bottom: 16px; }
.avf-field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; color: #5C431C; }
.avf-field .req { color: #C0392B; }
.avf-field .avf-optional { font-weight: 400; color: #9A7A3E; font-size: 12px; }
.avf-field input[type=text],
.avf-field input[type=tel],
.avf-field input[type=password],
.avf-field input[type=file],
.avf-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #E3C98A;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    color: #4A3B22;
}
.avf-field textarea { resize: vertical; }
.avf-hint { font-size: 12px; color: #9A7A3E; margin: 5px 0 0; }
.avf-inline-msg { font-size: 13px; margin-top: 6px; min-height: 16px; }
.avf-inline-msg.err { color: #C0392B; }
.avf-inline-msg.ok { color: #1E8449; }

.avf-divider { border: none; border-top: 1px dashed #E3C98A; margin: 22px 0; }

.avf-mgmt-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.avf-mgmt-table th, .avf-mgmt-table td { border: 1px solid #EBD8A8; padding: 6px; font-size: 13px; }
.avf-mgmt-table th { background: #FBEFD8; color: #6B4E1E; }
.avf-mgmt-table input { width: 100%; border: 1px solid #E3C98A; border-radius: 4px; padding: 5px 6px; font-size: 13px; }
.avf-mgmt-count { font-size: 12px; color: #9A7A3E; margin-left: 8px; }
.avf-row-remove { background: #C0392B; color: #fff; border: none; border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 12px; }

.avf-btn { border: none; border-radius: 6px; padding: 9px 16px; font-size: 13px; cursor: pointer; font-weight: 600; }
.avf-btn-add { background: #FBEFD8; color: #B4530A; border: 1px solid #E8C77A; }
.avf-btn-primary { background: linear-gradient(180deg,#F7A93B,#E8850F); color: #fff; padding: 10px 26px; font-size: 15px; }
.avf-btn-logout { background: #6B4E1E; color: #fff; }
.avf-btn-approve { background: #2E9E4F; color: #fff; }
.avf-btn-reject { background: #D98A17; color: #fff; }
.avf-btn-delete { background: #C0392B; color: #fff; }
.avf-btn-edit { background: #E67E22; color: #fff; }

.avf-submit-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.avf-spinner { width: 18px; height: 18px; border: 3px solid #F0D9A0; border-top-color: #E8850F; border-radius: 50%; animation: avfSpin 0.8s linear infinite; }
@keyframes avfSpin { to { transform: rotate(360deg); } }
.avf-result-msg { margin-top: 14px; font-size: 14px; font-weight: 600; }
.avf-result-msg.ok { color: #1E8449; }
.avf-result-msg.err { color: #C0392B; }

.avf-list-toolbar, .avf-filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.avf-list-toolbar input, .avf-filter-bar input { padding: 8px 10px; border: 1px solid #E3C98A; border-radius: 6px; font-size: 13px; }
.avf-filter-btn { background: #FBEFD8; border: 1px solid #E8C77A; color: #6B4E1E; padding: 6px 14px; border-radius: 16px; font-size: 12px; cursor: pointer; }
.avf-filter-btn.active { background: #E8850F; color: #fff; border-color: #E8850F; }

.avf-table-scroll { overflow-x: auto; }
.avf-data-table { width: 100%; border-collapse: collapse; background: #fff; }
.avf-data-table th, .avf-data-table td {
    border: 1px solid #EEE0BC;
    padding: 8px;
    font-size: 13px;
    word-break: break-word;
}
.avf-data-table th { background: #FBEFD8; color: #6B4E1E; text-align: left; }
.avf-data-table tr:nth-child(even) td { background: #FFFBF0; }
.avf-empty { text-align: center; color: #9A7A3E; padding: 18px; }

.avf-status-badge { padding: 3px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #fff; }
.avf-status-pending { background: #D98A17; }
.avf-status-approved { background: #2E9E4F; }
.avf-status-rejected { background: #C0392B; }

.avf-stat-boxes { display: flex; gap: 10px; flex-wrap: wrap; }
.avf-stat {
    background: #FBEFD8; border: 1px solid #E8C77A; border-radius: 8px;
    padding: 8px 16px; text-align: center; min-width: 80px;
}
.avf-stat-num { display: block; font-size: 20px; font-weight: 700; color: #B4530A; }
.avf-stat-label { font-size: 11px; color: #8A6D3B; }
.avf-stat-pending .avf-stat-num { color: #D98A17; }
.avf-stat-approved .avf-stat-num { color: #2E9E4F; }
.avf-stat-rejected .avf-stat-num { color: #C0392B; }
.avf-admin-topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

.avf-bulk-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; font-size: 13px; }

#avf-admin-login-box { max-width: 320px; margin: 30px auto; text-align: center; }
#avf-admin-login-box label { display: block; margin-bottom: 8px; font-weight: 600; }
#avf-admin-login-box input { width: 100%; padding: 10px; border: 1px solid #E3C98A; border-radius: 6px; margin-bottom: 10px; text-align: center; letter-spacing: 4px; }

.avf-row-detail { background: #FFFBF0; }
.avf-row-detail td { padding: 14px; }
.avf-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.avf-detail-block h4 { margin: 0 0 6px; color: #B4530A; font-size: 13px; }
.avf-detail-block p { margin: 0; font-size: 13px; white-space: pre-wrap; }
.avf-file-chip {
    display: inline-flex; align-items: center; gap: 6px; background: #FBEFD8;
    border: 1px solid #E8C77A; border-radius: 6px; padding: 5px 9px; margin: 3px 4px 3px 0; font-size: 12px;
}
.avf-file-chip a { color: #B4530A; text-decoration: none; font-weight: 600; }
.avf-file-chip .avf-dl { color: #2E9E4F; text-decoration: none; font-weight: 700; }
.avf-nested-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.avf-nested-table th, .avf-nested-table td { border: 1px solid #EEE0BC; padding: 5px; font-size: 12px; }
.avf-nested-table th { background: #FBEFD8; }

.avf-edit-strip { background: #FFF6E5; padding: 10px; border-radius: 6px; margin-top: 8px; }
.avf-edit-strip input, .avf-edit-strip textarea { width: 100%; margin-bottom: 6px; padding: 6px; border: 1px solid #E3C98A; border-radius: 4px; font-size: 13px; }
.avf-edit-readonly { margin-top: 12px; border-top: 1px dashed #E3C98A; padding-top: 10px; }

.avf-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 99999; }
.avf-modal.open { display: flex; align-items: center; justify-content: center; }
.avf-modal-inner { background: #fff; width: 90%; max-width: 900px; height: 85%; border-radius: 8px; position: relative; padding: 16px; }
.avf-modal-close { position: absolute; top: 8px; right: 12px; background: none; border: none; font-size: 28px; cursor: pointer; color: #C0392B; z-index: 2; }
#avf-modal-body { width: 100%; height: 100%; overflow: auto; text-align: center; }
#avf-modal-body img { max-width: 100%; max-height: 100%; }
#avf-modal-body iframe { width: 100%; height: 100%; border: none; }

.avf-btn-show-record { background: #2E7DAF; color: #fff; }

.avf-record-view { text-align: left; height: 100%; display: flex; flex-direction: column; }
.avf-record-view h3 { margin: 4px 30px 10px 0; color: #B4530A; font-size: 17px; }
.avf-record-complaint {
    background: #FFF6E5; border: 1px solid #F0D9A0; border-radius: 6px; padding: 12px;
    font-size: 13px; white-space: pre-wrap; margin-bottom: 14px; max-height: 180px; overflow-y: auto;
}
.avf-record-files h4 { margin: 0 0 8px; font-size: 13px; color: #6B4E1E; }
.avf-record-file-grid { display: flex; flex-wrap: wrap; gap: 10px; overflow-y: auto; }
.avf-record-file-card {
    border: 1px solid #E8C77A; border-radius: 8px; padding: 10px; width: 150px;
    background: #FFFDF7; font-size: 12px; text-align: center;
}
.avf-record-file-card .avf-file-icon { font-size: 26px; display: block; margin-bottom: 6px; }
.avf-record-file-card .avf-file-name { display: block; word-break: break-word; margin-bottom: 8px; min-height: 30px; }
.avf-record-file-card .avf-file-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.avf-record-file-card .avf-btn { padding: 5px 9px; font-size: 11px; }
.avf-btn-zoom { background: #2E7DAF; color: #fff; }
.avf-btn-open { background: #E67E22; color: #fff; }
.avf-btn-download-file { background: #2E9E4F; color: #fff; text-decoration: none; display: inline-block; }

.avf-doc-view { height: 100%; display: flex; flex-direction: column; }
.avf-doc-view iframe { flex: 1; width: 100%; border: 1px solid #EEE0BC; border-radius: 6px; }
.avf-doc-toolbar, .avf-zoom-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }

.avf-zoom-view { height: 100%; display: flex; flex-direction: column; }
.avf-zoom-stage {
    flex: 1; overflow: hidden; border: 1px solid #EEE0BC; border-radius: 6px;
    background: #111; display: flex; align-items: center; justify-content: center;
    cursor: grab; position: relative;
}
.avf-zoom-stage.dragging { cursor: grabbing; }
.avf-zoom-stage img { max-width: none; max-height: none; user-select: none; -webkit-user-drag: none; transform-origin: center center; }
.avf-zoom-slider-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #6B4E1E; }
.avf-zoom-slider-wrap input[type=range] { width: 160px; }

@media (max-width: 640px) {
    .avf-detail-grid { grid-template-columns: 1fr; }
    #avf-root { padding: 14px; }
}
