/* ========== GLOBAL RESET ========== */
*, *::before, *::after { box-sizing: border-box; }

:root { 
    --bg-body: #f8fafc; 
    --text-main: #0f172a; 
    --card-bg: #ffffff; 
    --border-subtle: #e5e7eb; 
    --primary: #2563eb;       
    --success: #16a34a;       
    --danger: #dc2626;        
    --warning: #d97706;       
    --insert: #4f46e5;        
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 
}

body { 
    margin: 0; 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
    font-family: var(--font-body); 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    overflow-x: hidden; 
}

.hidden { display: none !important; }

/* --- MASTHEAD --- */
.custom-masthead {
    background-color: #f0f0f0 !important;
    padding: 10px 0 !important;
    border-bottom: 1px solid #d1d1d1 !important;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    line-height: 1.5 !important;
}

.masthead-unified {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 20px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.masthead-left { display: flex !important; align-items: center !important; font-size: 14px !important; color: #333333 !important; }
.masthead-icon { margin-right: 8px !important; font-size: 18px !important; line-height: 1 !important; display: inline-block !important; }
.masthead-text { font-weight: 700 !important; color: #333333 !important; }
.masthead-right { display: flex !important; align-items: center !important; }

a.status-link { text-decoration: none !important; color: #333333 !important; display: flex !important; align-items: center !important; font-size: 13px !important; font-weight: 400 !important; white-space: nowrap !important; }
a.status-link:hover { opacity: 0.7 !important; color: #333333 !important; }
.status-dot-header { width: 8px !important; height: 8px !important; background-color: #22c55e !important; border-radius: 50% !important; display: inline-block !important; margin-right: 6px !important; }

/* --- APP CONTAINER --- */
.page-container { max-width: 1000px; width: 100%; margin: 32px auto; padding: 0 16px 32px; flex: 1; }
.main-card { background-color: var(--card-bg); border-radius: 16px; padding: 24px 24px 28px; box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08); border: 1px solid rgba(15, 23, 42, 0.05); }
.page-heading { margin-top: 0; margin-bottom: 4px; font-size: 1.4rem; font-weight: 800; color: #1d4ed8; }
.page-subtitle { margin-top: 0; margin-bottom: 16px; color: #6b7280; font-size: 0.9rem; }

/* --- INSTRUCTIONS BOXES --- */
.tip-box { background-color: #ffffff; border-radius: 12px; padding: 16px; border: 1px solid #e5e7eb; margin-bottom: 16px; transition: all 0.3s ease; }
.tip-box.urgent { border-color: #fca5a5; background-color: #fef2f2; margin-bottom: 16px; } 

.tip-header { display: flex; align-items: center; margin-bottom: 8px; }
.tip-icon { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 999px; background-color: #fff7cc; margin-right: 10px; font-size: 14px; }
.tip-title { font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: #374151; }

.tip-list-ol { margin: 4px 0 0; padding-left: 18px; font-size: 0.9rem; color: #4b5563; }
.tip-list-ol li + li { margin-top: 4px; }
.urgent-item { color: #dc2626; font-weight: 600; }

/* --- FORM ELEMENTS --- */
.structured-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }

.structured-field { min-width: 0; }
.structured-field label { 
    display: flex;
    align-items: flex-end; 
    min-height: 2.8em; 
    margin-bottom: 4px; 
    font-weight: 600; 
    font-size: 0.85rem; 
    color: #374151;
    line-height: 1.2;
}

/* --- STRICT INPUT UNIFORMITY --- */
input[type="text"], 
input[type="time"], 
select, 
textarea,
button { 
    font-family: var(--font-body) !important; 
    font-size: 16px !important; 
}

.structured-field input, 
.structured-field select { 
    width: 100%; 
    max-width: 100%;
    height: 40px; 
    padding: 0 12px; 
    border-radius: 8px; 
    border: 1px solid #d1d5db; 
    background-color: #fff;
    appearance: none; 
    -webkit-appearance: none; 
    box-sizing: border-box; 
    line-height: normal;
    transition: all 0.2s ease;
}

/* New: Disabled State */
.structured-field select:disabled,
.structured-field input:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.structured-field input:focus, 
.structured-field select:focus { 
    outline: none; 
    border-color: #2563eb; 
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3); 
}

.form-grid { display: grid; gap: 20px; margin-top: 8px; margin-bottom: 10px; }
.form-label { font-size: 0.9rem; font-weight: 700; margin-bottom: 4px; display: inline-block; color: #1e293b; }
.field-tip { font-size: 0.8rem; color: #64748b; margin-bottom: 6px; }

textarea { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #d1d5db; min-height: 160px; line-height: 1.6; resize: vertical; letter-spacing: 0.01em; }
textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3); }

/* --- BUTTONS --- */
.bottom-actions-container { margin-top: 32px; padding-top: 24px; border-top: 1px solid #e5e7eb; display: flex; flex-direction: column; gap: 16px; }
.draft-info { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.save-notice { font-size: 0.8rem; color: #64748b; line-height: 1.4; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }

.btn { border-radius: 8px; border: none; padding: 12px; font-size: 0.95rem; cursor: pointer; text-align: center; width: 100%; font-weight: 600; color: #ffffff; transition: all 0.2s ease; }
.btn:hover { filter: brightness(0.95); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-insert { background-color: var(--insert); width: 100%; margin-top: 8px; }
.btn-primary { background-color: var(--primary); }
.btn-success { background-color: var(--success); }
.btn-warning { background-color: var(--warning); }
.btn-danger { background-color: var(--danger); }

/* --- PREVIEW --- */
.preview-header-container { margin-top: 32px; margin-bottom: 0px; border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; }
.preview-section-title { font-size: 0.95rem; font-weight: 700; margin: 0; padding: 0; }
.preview-hint { font-size: 0.8rem; color: #64748b; margin-top: 4px; margin-bottom: 0; display: flex; align-items: center; gap: 6px; line-height: 1.2; }
.preview-box { background-color: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; padding: 20px; font-family: "Courier New", Courier, monospace !important; white-space: pre-wrap; min-height: 160px; display: flex; align-items: center; justify-content: center; text-align: center; color: #334155; margin-top: 16px; }
.highlight-missing { color: #dc2626; font-weight: 700; background-color: rgba(220, 38, 38, 0.1); padding: 0 2px; border-radius: 2px; }

/* --- MOBILE SMART GRID --- */
@media (max-width: 768px) { 
    .structured-row { grid-template-columns: 1fr 1fr !important; gap: 12px; } 
    .mobile-full { grid-column: 1 / -1; }
    .mobile-hide { display: none !important; }
    .page-container { margin: 16px auto 32px; padding: 0 16px 32px; }
}
